ze-filter  (ze-filter-0.8.0-develop-180218)
ze-filter.c
Go to the documentation of this file.
1 
2 /*
3  *
4  * ze-filter - Mail Server Filter for sendmail
5  *
6  * Copyright (c) 2001-2018 - Jose-Marcio Martins da Cruz
7  *
8  * Auteur : Jose Marcio Martins da Cruz
9  * jose.marcio.mc@gmail.org
10  *
11  * Historique :
12  * Creation : janvier 2002
13  *
14  * This program is free software, but with restricted license :
15  *
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20  *
21  * More details about ze-filter license can be found at ze-filter
22  * web site : http://foss.jose-marcio.org
23  */
24 
25 #include <ze-sys.h>
26 #include <libze.h>
27 #include <libml.h>
28 
29 #include "ze-filter.h"
30 #include "ze-filter-data.h"
31 #include "ze-spool.h"
32 #include "ze-chkcontent.h"
33 #include "ze-callbackchecks.h"
34 #include "ze-callbacklogs.h"
35 #include "ze-mxcheck.h"
36 
37 /* ****************************************************************************
38  * *
39  * *
40  ******************************************************************************/
41 #define _FFR_CTX_CONNECT TRUE
42 #ifndef _FFR_CTX_CONNECT
43 #define _FFR_CTX_CONNECT FALSE
44 #endif
45 
46 
47 #if _FFR_PREPEND_HEADERS
48 #if HAVE_SMFI_INSHEADER
49 #define smfi_addheader(a,b,c) smfi_insheader(a,0,b,c)
50 #endif /* HAVE_SMFI_INSHEADER */
51 #endif /* _FFR_PREPEND_HEADERS */
52 
53 static sfsistat mlfi_connect(SMFICTX *, char *, _SOCK_ADDR *);
54 static sfsistat mlfi_helo(SMFICTX *, char *);
55 static sfsistat mlfi_envfrom(SMFICTX *, char **);
56 static sfsistat mlfi_envto(SMFICTX *, char **);
57 static sfsistat mlfi_data(SMFICTX *);
58 static sfsistat mlfi_header(SMFICTX *, char *, char *);
59 static sfsistat mlfi_eoh(SMFICTX *);
60 static sfsistat mlfi_body(SMFICTX *, unsigned char *, size_t);
61 static sfsistat mlfi_eom(SMFICTX *);
62 static sfsistat mlfi_close(SMFICTX *);
63 static sfsistat mlfi_abort(SMFICTX *);
64 static sfsistat mlfi_unknown(SMFICTX *, const char *);
65 static sfsistat mlfi_negotiate(SMFICTX * ctx,
66  unsigned long f0,
67  unsigned long f1,
68  unsigned long f2,
69  unsigned long f3,
70  unsigned long *pf0,
71  unsigned long *pf1,
72  unsigned long *pf2, unsigned long *pf3);
73 
74 static sfsistat mlfi_cleanup(SMFICTX *, bool);
75 
76 
77 bool free_private_data(CTXPRIV_T *, bool);
78 
79 static int mime_encode2val(char *);
80 
81 static bool new_conn_id(CONNID_T *);
82 
83 int count_connections(int);
84 
85 static sfsistat check_filter_open_connections(SMFICTX *, char *, char *,
86  int);
87 static sfsistat check_cpu_load(SMFICTX *, char *, char *, int);
88 
89 char my_hostname[256];
90 
91 char *mlfi_result_string(sfsistat);
92 
93 time_t tlongconn = 120;
94 
95 static char *SYMPA_CMDS[] = {
96  "^hel(p)?",
97  "^info",
98  "^lis(ts)?",
99  "^rev(iew)?",
100  "^which",
101  "^sub(scribe)?",
102  "^uns(ubscribe)?",
103  "^set .+",
104  "^ind(ex)?",
105  "^get .+ .+",
106  "^last .+",
107  "^invite .+ .+",
108  "^confirm .+",
109  "^quit",
110  "^add .+",
111  "^del .+",
112  "^stats .+",
113  "^remind .+",
114  "^dist(ribute) .+",
115  "^rej(ect) .+",
116  "^modindex .+",
117  NULL
118 };
119 
120 
121 /* ****************************************************************************
122  * *
123  * *
124  ******************************************************************************/
125 #define INIT_CALLBACK(p, which) \
126  do { \
127  if (p != NULL) { \
128  p->callback_id = which; \
129  FREE(p->reply_code); \
130  } \
131  } while (0)
132 
133 #define JSM_TO ((time_t ) 10)
134 
135 #define INIT_CALLBACK_DELAY() \
136  time_t ti = time(NULL), tf = time(NULL); \
137  uint64_t tims = zeTime_ms(), tfms = zeTime_ms()
138 
139 #define UPDATE_SVCTIME() \
140  (void) smtprate_add_entry(RATE_SVCTIME, priv->peer_addr, \
141  priv->peer_name, (tfms - tims), time(NULL));
142 
143 #define CHECK_CALLBACK_NOW() (zeTime_ms() - tims)
144 
145 
146 #define CHECK_CALLBACK_DELAY() \
147  do { \
148  tf = time (NULL); \
149  if ((priv != NULL) && ((tf - ti) > JSM_TO)) { \
150  ZE_LogMsgNotice(0, "%s %s : callback handling time too long : " \
151  " %ld (threshold = %ld)", \
152  CONNID_STR (priv->id), priv->peer_addr, \
153  (long ) (tf - ti), (long ) JSM_TO); \
154  /* priv->save_msg = TRUE; */ \
155  } \
156  tfms = zeTime_ms(); \
157  if ((tfms - tims) > 1000 * JSM_TO) { \
158  } \
159  if (priv != NULL) { \
160  priv->t_callback += (tfms - tims); \
161  if (priv->peer_addr != NULL) \
162  (void) smtprate_add_entry(RATE_SVCTIME, priv->peer_addr, \
163  STRNULL(priv->peer_name, "UNKNOWN"), \
164  (tfms - tims), time(NULL)); \
165  /* UPDATE_SVCTIME(); */ \
166  (void) callback_stats_update(priv->callback_id, (tfms - tims)); \
167  } \
168  } while (0)
169 
170 
171 #define FREE_DELAYED_RESULT(dres) \
172  do { \
173  dres.result = SMFIS_CONTINUE; \
174  dres.callback = CALLBACK_CONNECT; \
175  FREE(dres.reply); \
176  FREE(dres.why); \
177  } while (0);
178 
179 
180 /* ****************************************************************************
181  * *
182  * *
183  ******************************************************************************/
184 char *
186  sfsistat code;
187 {
188  switch (code) {
189  case SMFIS_CONTINUE:
190  return "CONTINUE";
191  break;
192  case SMFIS_REJECT:
193  return "REJECT";
194  break;
195  case SMFIS_DISCARD:
196  return "DISCARD";
197  break;
198  case SMFIS_ACCEPT:
199  return "ACCEPT";
200  break;
201  }
202  return "UNKNOWN ???";
203 }
204 
205 /* ****************************************************************************
206  * *
207  * *
208  ******************************************************************************/
209 #include "mlfi_connect.c"
210 
211 #include "mlfi_helo.c"
212 
213 #include "mlfi_envfrom.c"
214 
215 #include "mlfi_envto.c"
216 
217 #include "mlfi_data.c"
218 
219 #include "mlfi_header.c"
220 
221 #include "mlfi_eoh.c"
222 
223 #include "mlfi_body.c"
224 
225 #include "mlfi_eom.c"
226 
227 #include "mlfi_close.c"
228 
229 #include "mlfi_abort.c"
230 
231 #include "mlfi_unknown.c"
232 
233 #include "mlfi_cleanup.c"
234 
235 #include "mlfi_negotiate.c"
236 
237 /* ****************************************************************************
238  * *
239  * *
240  ******************************************************************************/
241 static int
242 mime_encode2val(code)
243  char *code;
244 
245 {
246  if (code == NULL)
247  return MIME_ENCODE_OTHER;
248  if (strcasecmp(code, "7bit") == 0)
249  return MIME_ENCODE_7BIT;
250  if (strcasecmp(code, "8bit") == 0)
251  return MIME_ENCODE_8BIT;
252  if (strcasecmp(code, "binary") == 0)
253  return MIME_ENCODE_BINARY;
254  if (strcasecmp(code, "base64") == 0)
255  return MIME_ENCODE_BASE64;
256  if (strcasecmp(code, "quoted-printable") == 0)
258  return MIME_ENCODE_OTHER;
259 }
260 
261 /* ****************************************************************************
262  * *
263  * *
264  ******************************************************************************/
265 static CONNID_T sid = {
266  {
267  0, 0}
268 };
269 
270 static bool
271 new_conn_id(id)
272  CONNID_T *id;
273 
274 {
275  time_t now;
276  static pthread_mutex_t id_mutex = PTHREAD_MUTEX_INITIALIZER;
277 
278  if (id == NULL)
279  return FALSE;
280  MUTEX_LOCK(&id_mutex);
281  now = time(NULL);
282  if (now != sid.t[0]) {
283  sid.t[0] = now;
284  sid.t[1] = 0;
285  } else
286  sid.t[1]++;
287  snprintf(sid.id, sizeof (sid.id), "%08lX.%03lX", (long) sid.t[0],
288  (long) sid.t[1]);
289  *id = sid;
290  ZE_LogMsgInfo(12, "new id = %s", id->id);
291  MUTEX_UNLOCK(&id_mutex);
292  return TRUE;
293 }
294 
295 /* ****************************************************************************
296  * *
297  * *
298  ******************************************************************************/
299 int
301  int nb;
302 
303 {
304  static pthread_mutex_t cnt_mutex = PTHREAD_MUTEX_INITIALIZER;
305  static int cnt_conn = 0;
306  static time_t old = 0;
307  time_t new;
308 
309  MUTEX_LOCK(&cnt_mutex);
310  new = time(NULL);
311  if (old == 0)
312  old = new;
313  cnt_conn += nb;
314  if (cnt_conn < 0)
315  cnt_conn = 0;
316  nb = cnt_conn;
317  if ((new - old) > 60) {
318  ZE_MessageInfo(9, "Current open connections : %d", nb);
319  old = new;
320  }
321 
322  MUTEX_UNLOCK(&cnt_mutex);
323  return nb;
324 }
325 
326 
327 /* ****************************************************************************
328  * *
329  * *
330  ******************************************************************************/
331 static sfsistat
332 check_filter_open_connections(ctx, id, ip, ip_class)
333  SMFICTX *ctx;
334  char *id;
335  char *ip;
336  int ip_class;
337 
338 {
339 #if 0
340  CTXPRIV_T *priv = MLFIPRIV(ctx);
341 #endif
342  int nbcmax = cf_get_int(CF_MAX_OPEN_CONNECTIONS);
343  int nb_open = count_connections(0);
344 
345  if ((nbcmax > 0) && (nb_open > nbcmax)) {
346  ZE_MessageWarning(8, "%-12s Too many open connections : %d", id, nb_open);
347  (void) jsmfi_setreply(ctx, "421", "4.5.1",
348  "I'm too busy. Try again later !");
349  return SMFIS_TEMPFAIL;
350  }
351 
352  return SMFIS_CONTINUE;
353 }
354 
355 /* ****************************************************************************
356  * *
357  * *
358  ******************************************************************************/
359 static sfsistat
360 check_cpu_load(ctx, id, ip, ip_class)
361  SMFICTX *ctx;
362  char *id;
363  char *ip;
364  int ip_class;
365 {
366 #if 0
367  CTXPRIV_T *priv = MLFIPRIV(ctx);
368 #endif
369  bool reject = FALSE;
370  double load = get_cpu_load_info(JCPU_IDLE);
373 
374  if ((hard > 0) && (load < (double) hard))
375  reject = TRUE;
376  if (IS_UNKNOWN(ip_class) && (soft > 0) && (load < (double) soft))
377  reject = TRUE;
378  if (reject) {
379  ZE_MessageWarning(8, "%-12s Load Too High : %6.2f", id, load);
380  (void) jsmfi_setreply(ctx, "421", "4.5.1",
381  "I'm too busy. Try again later !");
382  return SMFIS_TEMPFAIL;
383  }
384 
385  return SMFIS_CONTINUE;
386 }
387 
388 
389 /* ****************************************************************************
390  * *
391  * *
392  ******************************************************************************/
393 #ifndef MAXINT
394 #define MAXINT 1 << 30
395 #endif
396 
397 static int
398 get_recipient_quarantine_threshold(rcpt)
399  char *rcpt;
400 
401 {
402 
403  return MAXINT;
404 }
405 
406 bool
408  rcpt_addr_T *head;
409  int score;
410 
411 {
412  rcpt_addr_T *rcpt;
413  bool result = FALSE;
414 
415  for (rcpt = head; rcpt != NULL; rcpt = rcpt->next) {
416  int threshold =
417  get_recipient_quarantine_threshold(rcpt->user);
418  if (score > threshold) {
419  /*
420  * XXX
421  */
422  rcpt->quarantine = TRUE;
423  rcpt->deleted = TRUE;
424  result = TRUE;
425  }
426  }
427 
428  return result;
429 }
430 
431 
432 /* ****************************************************************************
433  * *
434  * *
435  ******************************************************************************/
436 int
438  rcpt_addr_T *rcpt;
439 
440 {
441  int n = 0;
442  rcpt_addr_T *p = rcpt;
443 
444  while (p != NULL) {
445  n++;
446  p = p->next;
447  }
448  return n;
449 }
450 
451 /* ****************************************************************************
452  * *
453  * *
454  ******************************************************************************/
455 
456 struct smfiDesc smfilter = {
457  PACKAGE /* filter name */
458  , SMFI_VERSION /* version code -- do not change */
459  ,
460  SMFIF_ADDHDRS | SMFIF_CHGHDRS | SMFIF_CHGBODY | SMFIF_ADDRCPT | SMFIF_DELRCPT
461 #if HAVE_SMFI_CHGFROM
462  | SMFIF_CHGFROM
463 #endif
464 #if HAVE_SMFI_CHGFROM
465  | SMFIF_CHGFROM
466 #endif
467  /*
468  * flags
469  */
470  , mlfi_connect /* connection info filter */
471  , mlfi_helo /* SMTP HELO command filter */
472  , mlfi_envfrom /* envelope sender filter */
473  , mlfi_envto /* envelope recipient filter */
474  , mlfi_header /* header filter */
475  , mlfi_eoh /* end of header */
476  , mlfi_body /* body block filter */
477  , mlfi_eom /* end of message */
478  , mlfi_abort /* message aborted */
479  , mlfi_close /* connection cleanup */
480 #if HAVE_XXFI_UNKNOWN
481  , mlfi_unknown /* unknown command */
482 #endif
483 #if HAVE_XXFI_DATA && HAVE_XXFI_UNKNOWN
484  , mlfi_data /* data */
485 #endif
486 #if 0
487  , NULL
488 #else
489 #if HAVE_XXFI_NEGOTIATE && HAVE_XXFI_DATA && HAVE_XXFI_UNKNOWN
490  , mlfi_negotiate /* negotiate */
491 #endif
492 #endif
493 #if HAVE_XXFI_SIGNAL
494  , NULL /* signale */
495 #endif
496 };
497 
498 /* ****************************************************************************
499  * *
500  * *
501  ******************************************************************************/
502 
503 int
505 {
506  int r;
507  char *work_dir, *wdb_dir, *cf_dir, *cdb_dir, *root_dir;
508 
509  root_dir = work_dir = wdb_dir = cf_dir = cdb_dir = NULL;
510 
511  root_dir = cf_get_str(CF_WORKROOT);
512  root_dir = STREMPTY(root_dir, ZE_WORKROOT);
513  work_dir = cf_get_str(CF_WORKDIR);
514  work_dir = STREMPTY(work_dir, ZE_WORKDIR);
515  wdb_dir = cf_get_str(CF_WDBDIR);
516  wdb_dir = STREMPTY(wdb_dir, ZE_WDBDIR);
517  cdb_dir = cf_get_str(CF_CDBDIR);
518  cdb_dir = STREMPTY(cdb_dir, ZE_CDBDIR);
519  cf_dir = cf_get_str(CF_CONFDIR);
520  cf_dir = STREMPTY(cf_dir, ZE_CONFDIR);
521 
522  root_dir = cf_get_str(CF_WORKROOT);
523  work_dir = cf_get_str(CF_WORKDIR);
524  if (work_dir == NULL || strlen(work_dir) == 0)
525  work_dir = ZE_WORKDIR;
526  wdb_dir = cf_get_str(CF_WDBDIR);
527  if (wdb_dir == NULL || strlen(wdb_dir) == 0)
528  wdb_dir = work_dir;
529  cf_dir = cf_get_str(CF_CONFDIR);
530  if (cf_dir == NULL || strlen(cf_dir) == 0)
531  cf_dir = ZE_CONFDIR;
532  if (strlen(root_dir) > 0) {
533  if (*work_dir != '/')
534  ZE_LogMsgWarning(0, "WORKDIR doesn't begins with a / : %s", work_dir);
535  if (chdir(work_dir) != 0)
536  ZE_LogSysError("Error changing to dir %s", work_dir);
537  }
538 
539  {
540  char dbdir[256];
541 
542  wdb_dir = cf_get_str(CF_WDBDIR);
543  memset(dbdir, 0, sizeof (dbdir));
544  if (wdb_dir != NULL && strlen(wdb_dir) > 0)
545  snprintf(dbdir, sizeof (dbdir), "%s", wdb_dir);
546  if (!open_work_db_env(dbdir, ZE_WDBDIR, FALSE)) {
547  }
548  }
549 
552  /*
553  * alarm(2 * DT_SIGALRM);
554  */
556  init_proc_state();
557  (void) setup_control_handler();
558  (void) smtprate_init(0, 0);
559  ZE_LogMsgInfo(11, "Will read connection rate history...");
560  smtprate_read_table(NULL);
563 #if 0
565 #endif
566  memset(my_hostname, 0, sizeof (my_hostname));
567  if (!get_hostname(my_hostname, sizeof (my_hostname)))
568  ZE_LogMsgError(0, "Error getting host name");
569  else
570  ZE_MessageInfo(9, "Running on %s (nodename)", my_hostname);
571  (void) raw_history_open(FALSE);
572  (void) load_live_history(NULL, time(NULL), 5 HOURS);
573  umask(000);
574  (void) policy_init();
575  (void) rcpt_init();
576 
578  time_t dt_expire, dt_check, dt_sync;
579 
580  dt_expire = cf_get_int(CF_RESOLVE_CACHE_EXPIRE);
584  (void) resolve_cache_times(dt_sync, dt_check, dt_expire);
585  }
586 #if _FFR_MODULES
587  {
588  char *modcf = cf_get_str(CF_MODULES_CF);
589  char *moddir = cf_get_str(CF_MODDIR);
590 
591  if (!load_all_modules(cf_dir, modcf, moddir)) {
592  }
593  }
594 #endif /* _FFR_MODULES */
595 
596  {
597  int mode;
598 
599  mode = cf_get_int(CF_GREY_MODE);
600  (void) grey_init(cf_get_str(CF_WDBDIR), FALSE, mode);
601  }
602 
603  {
604  char path[1024];
605  char *dbname = ZE_CDBDIR "/ze-bayes.db";
606  char *cfdir;
607  bool crypt = FALSE;
608  size_t msgSize, partSize;
609  double rhs = 1.;
610 
611  memset(path, 0, sizeof (path));
612  cfdir = cf_get_str(CF_CDBDIR);
613  dbname = cf_get_str(CF_DB_BAYES);
614  ADJUST_FILENAME(path, dbname, cfdir, "ze-bayes.db");
615  if (strlen(path) > 0 && !bfilter_init(path)) {
616  ZE_LogMsgError(0, "Error while opening %s database\n", path);
617  }
618 #if 0
619  /*
620  * crypt = cf_get_int(CF_BAYES_DB_CRYPT);
621  */
622  (void) set_bfilter_db_crypt(crypt);
623 #endif
625  if (msgSize < 10000)
626  msgSize = 400000;
628  if (partSize < 10000)
629  partSize = 40000;
630  (void) set_bfilter_max_sizes(msgSize, partSize);
631  rhs = ((double) cf_get_int(CF_BAYES_HAM_SPAM_RATIO) / 1000);
632  if (rhs < 0.1 || rhs > 10.)
633  rhs = 1.;
634  (void) set_bfilter_ham_spam_ratio(rhs);
635  }
636 
637  {
638  char *env = NULL;
639  bool enable = FALSE;
640 
641  if ((env = getenv("LR_FILTER_ENABLE")) != NULL)
642  enable = (STRCASEEQUAL(env, "true") || STRCASEEQUAL(env, "yes"));
643 
644  enable = TRUE;
645  if (enable)
646  (void) lr_data_load(TRUE);
647  }
648 
649  (void) configure_msg_eval_function(NULL);
650 #if 0
651  db_map_open("to");
652  db_map_open("from");
653  db_map_open("spams");
654  db_map_open("hits");
655 #endif
656  /*
657  * Now let's finally launch the filter...
658  */
659  if (1) {
660  char *milter_debug = getenv("MILTER_DEBUG_LEVEL");
661 
662  ZE_MessageInfo(9, "MILTER_DEBUG_LEVEL = %s", STRNULL(milter_debug, "NULL"));
663  if (milter_debug != NULL) {
664  int level = atoi(milter_debug);
665 
666  if (level > 0) {
667  ZE_MessageInfo(9, "Setting milter debug level to %d", level);
668  (void) smfi_setdbg(level);
669  } else
670  ZE_LogMsgWarning(0, "Invalid MILTER_DEBUG_LEVEL value %s",
671  milter_debug);
672  }
673  }
674 
675  if (milter_sock_file != NULL && strlen(milter_sock_file) > 0) {
676  (void) smfi_setconn(milter_sock_file);
677  } else {
678  ZE_LogMsgError(0,
679  "FATAL ERROR Don't know how to communicate with sendmail");
680  exit(1);
681  }
682 
683  if (smfi_register(smfilter) == MI_FAILURE) {
684  ZE_LogMsgError(0, "smfi_register failed");
685  exit(EX_UNAVAILABLE);
686  }
687 #if HAVE_SMFI_SETBACKLOG
688  smfi_setbacklog(256);
689 #endif
690 #if HAVE_SMFI_SETMINWORKERS
691  {
692  int nw = 4;
693 
694  ZE_MessageInfo(9, "Setting the minimum number of workers in the pool to %d",
695  nw);
696  smfi_setminworkers(nw);
697  }
698 #endif
699  {
700  int smto = cf_get_int(CF_SM_TIMEOUT);
701 
702  if (smto > 0) {
703  ZE_MessageInfo(9, "Setting MTA communication timeout to %d s", smto);
704  (void) smfi_settimeout(smto);
705  }
706  }
707 
710  r = smfi_main();
711  ZE_MessageWarning(0, "Joe's ze-filter terminating : code=(%d) !", r);
712  if (r == 0)
714 end:
715 
716  if (!lr_data_close()) {
717  ;
718  }
719 
723  save_state();
724  smtprate_save_table(NULL);
725  return 0;
726 }
#define CF_RESOLVE_CACHE_ENABLE
Definition: cfh-defs.h:84
#define CF_CPU_IDLE_HARD_LIMIT
Definition: cfh-defs.h:44
void launch_periodic_tasks_thread(void)
Definition: ze-signal.c:705
bool check_recipient_quarantine(rcpt_addr_T *head, int score)
Definition: ze-filter.c:407
int smtprate_update_table(time_t)
Definition: ze-smtprate.c:598
struct smfiDesc smfilter
Definition: ze-filter.c:456
#define SMFIS_ACCEPT
#define CF_WORKROOT
Definition: cfh-defs.h:66
#define STAT_RESTART
Definition: ze-stats.h:26
void stats_inc(int, long)
Definition: ze-stats.c:401
void raw_history_close()
Definition: ze-history.c:296
bool set_bfilter_max_sizes(size_t msg, size_t mime)
Definition: ze-bfilter.c:486
#define CF_RESOLVE_CACHE_CHECK
Definition: cfh-defs.h:86
#define CF_BAYES_MAX_PART_SIZE
Definition: cfh-defs.h:107
#define ZE_WDBDIR
Definition: defs.h:35
#define CF_CDBDIR
Definition: cfh-defs.h:78
#define SMFIS_TEMPFAIL
#define CF_DB_BAYES
Definition: cfh-defs.h:112
#define ZE_WORKROOT
Definition: defs.h:32
sfsistat mlfi_envfrom(SMFICTX *ctx, char **envfrom)
Definition: mlfi_envfrom.c:32
bool resolve_cache_times(time_t dt_sync, time_t dt_check, time_t dt_expire)
double get_cpu_load_info(int)
Definition: ze-load.c:753
int jsmfi_setreply(SMFICTX *, char *, char *, char *)
Definition: ze-libmilter.c:99
sfsistat mlfi_cleanup(SMFICTX *ctx, bool ok)
Definition: mlfi_cleanup.c:31
#define ZE_WORKDIR
Definition: defs.h:33
void print_filter_stats_summary(void)
Definition: ze-stats.c:1146
#define ZE_CDBDIR
Definition: defs.h:34
bool lr_data_close()
Definition: ze-lr-funcs.c:350
#define MIME_ENCODE_7BIT
Definition: ze-demime.h:45
#define MUTEX_UNLOCK(mutex)
Definition: macros.h:101
unsigned int smtprate_window
Definition: ze-smtprate.c:119
bool resolve_cache_init(char *dbdir, int rwmode)
#define JCPU_IDLE
Definition: ze-load.h:33
#define STRNULL(x, r)
Definition: macros.h:81
bool configure_msg_eval_function(char *val)
Definition: ze-msg-score.c:450
sfsistat mlfi_close(SMFICTX *ctx)
Definition: mlfi_close.c:31
#define MUTEX_LOCK(mutex)
Definition: macros.h:93
#define ZE_LogMsgInfo(level,...)
Definition: zeSyslog.h:110
int zeFilter()
Definition: ze-filter.c:504
void zeLog_SetOutput(bool, bool)
Definition: zeSyslog.c:490
#define FALSE
Definition: macros.h:160
#define SMFIS_CONTINUE
#define SMFIS_REJECT
#define ZE_LogMsgError(level,...)
Definition: zeSyslog.h:113
#define ADJUST_FILENAME(path, fname, cfdir, defval)
Definition: macros.h:236
void log_counters(int, bool)
Definition: ze-stats.c:330
#define OPT_YES
Definition: ze-cf.h:45
bool load_live_history(History_T *, time_t, time_t)
Definition: ze-history.c:1184
bool open_work_db_env(char *defdir, char *cfdir, bool rdonly)
Definition: ze-databases.c:40
char * user
Definition: ze-rcpt-list.h:34
sfsistat mlfi_body(SMFICTX *ctx, unsigned char *bodyp, size_t bodylen)
Definition: mlfi_body.c:31
#define CF_CPU_IDLE_SOFT_LIMIT
Definition: cfh-defs.h:43
#define CF_BAYES_MAX_MESSAGE_SIZE
Definition: cfh-defs.h:106
char * milter_sock_file
bool raw_history_open(bool)
Definition: ze-history.c:227
void save_state()
Definition: ze-stats.c:430
void init_proc_state()
Definition: ze-stats.c:502
sfsistat mlfi_connect(SMFICTX *ctx, char *hostname, _SOCK_ADDR *hostaddr)
Definition: mlfi_connect.c:45
#define CF_RESOLVE_CACHE_SYNC
Definition: cfh-defs.h:85
int cf_get_int(int id)
Definition: ze-cf.c:803
#define MLFIPRIV(ctx)
bool quarantine
Definition: ze-rcpt-list.h:36
bool bfilter_init(char *dbname)
Definition: ze-bfilter.c:200
bool policy_init()
Definition: ze-policy.c:692
#define MIME_ENCODE_8BIT
Definition: ze-demime.h:46
sfsistat mlfi_abort(SMFICTX *ctx)
Definition: mlfi_abort.c:31
#define RESOLVE_CACHE_RW
int smtprate_read_table(char *)
Definition: ze-smtprate.c:784
bool rcpt_init()
Definition: ze-rcpt.c:552
#define CF_CONFDIR
Definition: cfh-defs.h:51
bool db_map_open(char *bl)
Definition: ze-dbbl.c:317
#define CF_MODDIR
Definition: cfh-defs.h:76
char my_hostname[256]
Definition: ze-filter.c:89
rcpt_addr_T * next
Definition: ze-rcpt-list.h:39
#define IS_UNKNOWN(class)
Definition: ze-netclass.h:51
bool CycTasks_Init(time_t interval)
Definition: zeCycTasks.c:63
char id[16]
Definition: ze-filter.h:41
#define ZE_MessageInfo(level,...)
Definition: zeSyslog.h:90
bool grey_init(char *, bool, int)
Definition: ze-grey.c:1326
int nb
Definition: ze-connopen.c:61
sfsistat mlfi_eom(SMFICTX *ctx)
Definition: mlfi_eom.c:107
bool set_bfilter_ham_spam_ratio(double ratio)
Definition: ze-bfilter.c:438
#define SMFIS_DISCARD
bool db_open_blacklist()
Definition: ze-dbbl.c:56
#define TRUE
Definition: macros.h:157
#define ZE_MessageWarning(level,...)
Definition: zeSyslog.h:92
sfsistat mlfi_header(SMFICTX *ctx, char *headerf, char *headerv)
Definition: mlfi_header.c:30
sfsistat mlfi_helo(SMFICTX *ctx, char *helohost)
Definition: mlfi_helo.c:30
bool get_hostname(char *, size_t)
Definition: ze-inet.c:181
bool lr_data_load(bool background)
Definition: ze-lr-init.c:48
#define CF_SM_TIMEOUT
Definition: cfh-defs.h:47
int count_rcpt(rcpt_addr_T *rcpt)
Definition: ze-filter.c:437
#define ZE_LogSysError(...)
Definition: zeSyslog.h:129
void remove_milter_sock()
char * cf_get_str(int id)
Definition: ze-cf.c:854
bool free_private_data(CTXPRIV_T *, bool)
Definition: mlfi_cleanup.c:66
int count_connections(int)
Definition: ze-filter.c:300
#define STREMPTY(x, r)
Definition: macros.h:82
#define CF_WDBDIR
Definition: cfh-defs.h:77
#define ZE_LogMsgWarning(level,...)
Definition: zeSyslog.h:112
char * mlfi_result_string(sfsistat)
Definition: ze-filter.c:185
#define CF_MAX_OPEN_CONNECTIONS
Definition: cfh-defs.h:45
#define CF_GREY_MODE
Definition: cfh-defs.h:191
#define PACKAGE
Definition: version.h:28
void smtprate_save_table(char *)
Definition: ze-smtprate.c:737
#define HOURS
Definition: macros.h:144
#define CF_DUMP_COUNTERS
Definition: cfh-defs.h:63
bool load_all_modules(char *cfdir, char *modcf, char *moddir)
Definition: ze-modules.c:318
#define STRCASEEQUAL(a, b)
Definition: macros.h:72
#define MAXINT
Definition: ze-filter.c:394
#define MIME_ENCODE_BINARY
Definition: ze-demime.h:47
bool set_bfilter_db_crypt(int crypt)
Definition: ze-bfilter.c:507
bool smtprate_init(size_t, size_t)
Definition: ze-smtprate.c:263
sfsistat mlfi_eoh(SMFICTX *ctx)
Definition: mlfi_eoh.c:31
bool db_close_blacklist()
Definition: ze-dbbl.c:83
#define MIME_ENCODE_OTHER
Definition: ze-demime.h:50
#define ZE_CONFDIR
Definition: defs.h:36
#define CF_MODULES_CF
Definition: cfh-defs.h:54
sfsistat mlfi_envto(SMFICTX *ctx, char **envto)
Definition: mlfi_envto.c:31
#define CF_WORKDIR
Definition: cfh-defs.h:67
bool setup_filter_signal_handler(void)
Definition: ze-signal.c:165
time_t tlongconn
Definition: ze-filter.c:93
#define CF_RESOLVE_CACHE_EXPIRE
Definition: cfh-defs.h:87
#define MIME_ENCODE_QUOTED_PRINTABLE
Definition: ze-demime.h:49
#define CF_BAYES_HAM_SPAM_RATIO
Definition: cfh-defs.h:108
#define MIME_ENCODE_BASE64
Definition: ze-demime.h:48
uint32_t t[2]
Definition: ze-filter.h:40
bool setup_control_handler()
#define SECONDS
Definition: macros.h:142