]> git.pld-linux.org Git - packages/dovecot-antispam.git/blob - dovecot-antispam-git.patch
- release 36 (by relup.sh)
[packages/dovecot-antispam.git] / dovecot-antispam-git.patch
1 diff --git a/antispam-plugin.c b/antispam-plugin.c
2 index 7756204..76ced7b 100644
3 --- a/antispam-plugin.c
4 +++ b/antispam-plugin.c
5 @@ -90,7 +90,7 @@ static bool mailbox_patternmatch(struct mailbox *box,
6                 return FALSE;
7  #endif
8  
9 -       t_push();
10 +       T_BEGIN {
11  
12         boxname = mailbox_get_name(box);
13         if (lowercase) {
14 @@ -110,7 +110,7 @@ static bool mailbox_patternmatch(struct mailbox *box,
15  
16         rc = memcmp(name, boxname, len) == 0;
17  
18 -       t_pop();
19 +       } T_END;
20  
21         return rc;
22  }
23 @@ -257,7 +257,7 @@ static int parse_folder_setting(const struct antispam_config *cfg,
24         int cnt = 0;
25         enum match_type i;
26  
27 -       t_push();
28 +       T_BEGIN {
29  
30         for (i = 0; i < NUM_MT; ++i) {
31                 tmp = getenv(t_strconcat(setting, match_info[i].suffix, NULL),
32 @@ -286,7 +286,7 @@ static int parse_folder_setting(const struct antispam_config *cfg,
33                 }
34         }
35  
36 -       t_pop();
37 +       } T_END;
38  
39         if (!cnt)
40                 debug(&cfg->dbgcfg, "no %s folders\n", display_name);
41 @@ -392,4 +392,8 @@ void PLUGIN_FUNCTION(deinit)(void)
42  }
43  
44  /* put dovecot version we built against into plugin for checking */
45 +#if DOVECOT_IS_GE(2,2)
46 +const char *PLUGIN_FUNCTION(version) = DOVECOT_ABI_VERSION;
47 +#else
48  const char *PLUGIN_FUNCTION(version) = PACKAGE_VERSION;
49 +#endif
50 diff --git a/antispam-plugin.h b/antispam-plugin.h
51 index 280bb12..62a3eb3 100644
52 --- a/antispam-plugin.h
53 +++ b/antispam-plugin.h
54 @@ -10,7 +10,6 @@
55  #include "client.h"
56  #endif
57  #include "ostream.h"
58 -#include "dict.h"
59  #include "imap-search.h"
60  #include <stdlib.h>
61  
62 @@ -43,6 +42,7 @@ struct signature_config {
63  };
64  
65  struct antispam_debug_config {
66 +       const char *prefix;
67         enum antispam_debug_target target;
68         int verbose;
69  };
70 @@ -98,8 +98,10 @@ struct antispam_config {
71                         int extra_env_num;
72                 } crm;
73                 struct {
74 -                       const char *spam_arg;
75 -                       const char *ham_arg;
76 +                       char **spam_args;
77 +                       int spam_args_num;
78 +                       char **ham_args;
79 +                       int ham_args_num;
80                         const char *pipe_binary;// = "/usr/sbin/sendmail";
81                         const char *tmpdir;// = "/tmp";
82                         char **extra_args;
83 @@ -204,12 +206,6 @@ o_stream_create_from_fd(int fd, pool_t pool)
84         return o_stream_create_file(fd, pool, 0, TRUE);
85  }
86  
87 -static inline struct dict *
88 -string_dict_init(const char *uri, const char *username)
89 -{
90 -       return dict_init(uri, username);
91 -}
92 -
93  static inline int _mail_get_stream(struct mail *mail,
94                                    struct message_size *hdr_size,
95                                    struct message_size *body_size,
96 @@ -222,6 +218,11 @@ static inline int _mail_get_stream(struct mail *mail,
97         return 0;
98  }
99  #define mail_get_stream _mail_get_stream
100 +
101 +#define T_BEGIN \
102 +       STMT_START { t_push();
103 +#define T_END \
104 +       t_pop(); } STMT_END
105  #elif DOVECOT_IS_EQ(1, 1)
106  #define mempool_unref          pool_unref
107  #define module_arg             void
108 @@ -231,7 +232,7 @@ static inline const char *const *
109  get_mail_headers(struct mail *mail, const char *hdr)
110  {
111         const char *const *ret;
112 -       if (mail_get_headers(mail, hdr, &ret))
113 +       if (mail_get_headers(mail, hdr, &ret) < 0)
114                 return NULL;
115         return ret;
116  }
117 @@ -250,7 +251,7 @@ static inline const char *const *
118  get_mail_headers(struct mail *mail, const char *hdr)
119  {
120         const char *const *ret;
121 -       if (mail_get_headers(mail, hdr, &ret))
122 +       if (mail_get_headers(mail, hdr, &ret) < 0)
123                 return NULL;
124         return ret;
125  }
126 @@ -260,7 +261,7 @@ o_stream_create_from_fd(int fd, pool_t pool ATTR_UNUSED)
127  {
128         return o_stream_create_fd(fd, 0, TRUE);
129  }
130 -#elif DOVECOT_IS_EQ(2, 0)
131 +#elif DOVECOT_IS_EQ(2, 0) || DOVECOT_IS_EQ(2, 1) || DOVECOT_IS_EQ(2, 2)
132  #define mempool_unref          pool_unref
133  #define module_arg             struct module *
134  #define ME(err)                        MAIL_ERROR_ ##err,
135 @@ -269,7 +270,7 @@ static inline const char *const *
136  get_mail_headers(struct mail *mail, const char *hdr)
137  {
138         const char *const *ret;
139 -       if (mail_get_headers(mail, hdr, &ret))
140 +       if (mail_get_headers(mail, hdr, &ret) < 0)
141                 return NULL;
142         return ret;
143  }
144 @@ -279,12 +280,6 @@ o_stream_create_from_fd(int fd, pool_t pool ATTR_UNUSED)
145  {
146         return o_stream_create_fd(fd, 0, TRUE);
147  }
148 -
149 -static inline struct dict *
150 -string_dict_init(const char *uri, const char *username)
151 -{
152 -       return dict_init(uri, DICT_DATA_TYPE_STRING, username, NULL);
153 -}
154  #else
155  #error "Building against this dovecot version is not supported"
156  #endif
157 diff --git a/antispam-storage-1.1.c b/antispam-storage-1.1.c
158 index f28a0cf..aab23d9 100644
159 --- a/antispam-storage-1.1.c
160 +++ b/antispam-storage-1.1.c
161 @@ -508,10 +508,10 @@ void antispam_mail_storage_created(struct mail_storage *storage)
162  
163  static const char *_getenv(const char *env, void *data ATTR_UNUSED)
164  {
165 -       t_push();
166 +       T_BEGIN {
167         env = t_str_ucase(t_strconcat("antispam_", env, NULL));
168         env = getenv(env);
169 -       t_pop();
170 +       } T_END;
171  
172         return env;
173  }
174 diff --git a/antispam-storage-1.2.c b/antispam-storage-1.2.c
175 index 5e0cb97..269a373 100644
176 --- a/antispam-storage-1.2.c
177 +++ b/antispam-storage-1.2.c
178 @@ -498,10 +498,10 @@ void antispam_mail_storage_created(struct mail_storage *storage)
179  
180  static const char *_getenv(const char *env, void *data ATTR_UNUSED)
181  {
182 -       t_push();
183 +       T_BEGIN {
184         env = t_str_ucase(t_strconcat("antispam_", env, NULL));
185         env = getenv(env);
186 -       t_pop();
187 +       } T_END;
188  
189         return env;
190  }
191 diff --git a/antispam-storage-2.0.c b/antispam-storage-2.0.c
192 index 5a089bc..c3d6251 100644
193 --- a/antispam-storage-2.0.c
194 +++ b/antispam-storage-2.0.c
195 @@ -472,7 +472,7 @@ static void antispam_mailbox_allocated(struct mailbox *box)
196  
197         asbox->save_hack = FALSE;
198         asbox->movetype = MMT_APPEND;
199 -               asbox->cfg = asuser->cfg;
200 +       asbox->cfg = asuser->cfg;
201  
202         v->free = antispam_mailbox_free;
203  
204 @@ -494,11 +494,11 @@ static const char *_getenv(const char *name, void *data)
205         struct mail_user *user = data;
206         const char *env;
207  
208 -       t_push();
209 +       T_BEGIN {
210         env = t_strconcat("antispam_", t_str_lcase(name), NULL);
211  
212         env = mail_user_plugin_getenv(user, env);
213 -       t_pop();
214 +       } T_END;
215  
216         return env;
217  }
218 diff --git a/antispam.7 b/antispam.7
219 index 5e33e4c..497da58 100644
220 --- a/antispam.7
221 +++ b/antispam.7
222 @@ -1,4 +1,4 @@
223 -.TH ANTISPAM 7 "15 October 2007" "" ""
224 +.TH ANTISPAM 7 "24 March 2012" "" ""
225  .SH NAME
226  antispam \- The dovecot antispam plugin.
227  
228 @@ -120,6 +120,9 @@ plugin {
229      # antispam_debug_target = syslog
230      # antispam_debug_target = stderr
231      # antispam_verbose_debug = 1
232 +    #
233 +    # This can be used to get a prefix, e.g. by specifying %u in it
234 +    # antispam_debug_prefix = "antispam: "
235  
236      # backend selection, MUST be configured first,
237      # there's no default so you need to set one of
238 @@ -206,6 +209,11 @@ plugin {
239      # semicolon-separated list of blacklisted results, case insensitive
240      # antispam_dspam_result_blacklist = Virus
241  
242 +    # semicolon-separated list of environment variables to set
243 +    # (default unset i.e. none)
244 +    # antispam_dspam_env =
245 +    # antispam_dspam_env = HOME=%h;USER=%u
246 +
247      #=====================
248      # pipe plugin
249      #
250 @@ -228,6 +236,14 @@ plugin {
251      # "mailtrain" are still valid, these are, in the same order as
252      # above: antispam_mail_sendmail, antispam_mail_sendmail_args,
253      # antispam_mail_spam, antispam_mail_notspam and antispam_mail_tmpdir.
254 +    #
255 +    # Alternatively, if you need to give multiple options, you can use
256 +    # the spam_args/notspam_args parameters (which are used in preference
257 +    # of the singular form):
258 +    #   antispam_pipe_program_spam_args = --spam;--my-other-param1
259 +    #   antispam_pipe_program_notspam_args = --ham;--my-other-param2
260 +    # which will then call
261 +    #   /path/to/mailtrain --for jberg --spam --my-other-param1
262  
263      # temporary directory
264      antispam_pipe_tmpdir = /tmp
265 @@ -247,7 +263,7 @@ plugin {
266      antispam_crm_binary = /bin/false
267      # antispam_crm_binary = /usr/share/crm114/mailreaver.crm
268  
269 -    # semicolon-separated list of extra arguments to dspam
270 +    # semicolon-separated list of extra arguments to crm114
271      # (default unset i.e. none)
272      # antispam_crm_args =
273      # antispam_crm_args = --config=/path/to/config
274 @@ -257,11 +273,6 @@ plugin {
275      # antispam_crm_env =
276      # antispam_crm_env = HOME=%h;USER=%u
277  
278 -    # semicolon-separated list of environment variables to set
279 -    # (default unset i.e. none)
280 -    # antispam_dspam_env =
281 -    # antispam_dspam_env = HOME=%h;USER=%u
282 -
283      # NOTE: you need to set the signature for this backend
284      antispam_signature = X-CRM114-CacheID
285  
286 diff --git a/crm114-exec.c b/crm114-exec.c
287 index 5b39ca9..d786e04 100644
288 --- a/crm114-exec.c
289 +++ b/crm114-exec.c
290 @@ -113,7 +113,7 @@ static int call_reaver(const struct antispam_config *cfg,
291  
292                 debugv(&cfg->dbgcfg, argv);
293  
294 -               t_push();
295 +               T_BEGIN {
296                 for (i = 0; i < cfg->crm.extra_env_num; i++) {
297                         char *name, *value;
298                         name = t_strdup_noconst(cfg->crm.extra_env[i]);
299 @@ -124,7 +124,7 @@ static int call_reaver(const struct antispam_config *cfg,
300                         }
301                         setenv(name, value, 1);
302                 }
303 -               t_pop();
304 +               } T_END;
305  
306                 execv(cfg->crm.reaver_binary, argv);
307                 /* fall through if reaver can't be found */
308 diff --git a/debug.c b/debug.c
309 index d2683fa..77f0167 100644
310 --- a/debug.c
311 +++ b/debug.c
312 @@ -1,4 +1,3 @@
313 -#define _BSD_SOURCE
314  #include <syslog.h>
315  #include <stdarg.h>
316  #include <stdio.h>
317 @@ -14,9 +13,9 @@ static void _debug(const struct antispam_debug_config *cfg,
318         if (cfg->target == ADT_NONE)
319                 return;
320  
321 -       t_push();
322 +       T_BEGIN {
323  
324 -       fmt = t_strconcat("antispam: ", format, NULL);
325 +       fmt = t_strconcat(cfg->prefix, format, NULL);
326  
327         switch (cfg->target) {
328         case ADT_NONE:
329 @@ -30,7 +29,7 @@ static void _debug(const struct antispam_debug_config *cfg,
330                 break;
331         }
332  
333 -       t_pop();
334 +       } T_END;
335  }
336  
337  void debug(const struct antispam_debug_config *cfg, const char *fmt, ...)
338 @@ -48,7 +47,7 @@ void debugv(const struct antispam_debug_config *cfg, char **args)
339         char *buf;
340         const char *str;
341  
342 -       t_push();
343 +       T_BEGIN {
344         buf = t_buffer_get(buflen);
345  
346         while (1) {
347 @@ -72,7 +71,7 @@ void debugv(const struct antispam_debug_config *cfg, char **args)
348         t_buffer_alloc(pos);
349  
350         debug(cfg, "%s", buf);
351 -       t_pop();
352 +       } T_END;
353  }
354  
355  void debugv_not_stderr(const struct antispam_debug_config *cfg, char **args)
356 @@ -111,6 +110,10 @@ int debug_init(struct antispam_debug_config *cfg,
357                         return -1;
358         }
359  
360 +       cfg->prefix = getenv("DEBUG_PREFIX", getenv_data);
361 +       if (!cfg->prefix)
362 +               cfg->prefix = "antispam: ";
363 +
364         debug(cfg, "plugin initialising (%s)\n", ANTISPAM_VERSION);
365  
366         tmp = getenv("VERBOSE_DEBUG", getenv_data);
367 diff --git a/dovecot-version.c b/dovecot-version.c
368 index cbcb35b..fe9bc73 100644
369 --- a/dovecot-version.c
370 +++ b/dovecot-version.c
371 @@ -1,6 +1,7 @@
372  #include <stdio.h>
373  #include <string.h>
374  #include <stdlib.h>
375 +#include <ctype.h>
376  #include "config.h"
377  
378  int main(int argc, char **argv)
379 @@ -17,21 +18,24 @@ int main(int argc, char **argv)
380  
381         maj = strtol(v, &e, 10);
382         if (v == e)
383 -               return 1;
384 +               return 2;
385  
386         v = e + 1;
387  
388         min = strtol(v, &e, 10);
389         if (v == e)
390 -               return 1;
391 +               return 3;
392  
393         /* not end of string yet? */
394         if (*e) {
395                 v = e + 1;
396  
397 -               patch = strtol(v, &e, 10);
398 -               if (v == e)
399 -                       return 1;
400 +               if (isdigit(*v)) {
401 +                       patch = strtol(v, &e, 10);
402 +                       if (v == e)
403 +                               return 4;
404 +               } else
405 +                       patch = 0;
406         }
407  
408         printf("/* Auto-generated file, do not edit */\n\n");
409 @@ -40,6 +44,8 @@ int main(int argc, char **argv)
410         
411         printf("#define DOVECOT_VCODE                           "
412                 "0x%.2x%.2x%.2x\n", maj, min, 0);
413 +       printf("#define DOVECOT_VCODE_PATCH                     "
414 +               "0x%.2x%.2x%.2x\n", maj, min, patch);
415         printf("#define DOVECOT_IS_EQ(maj, min)                 "
416                 "DOVECOT_VCODE == DOVECOT_VERSION_CODE(maj, min, 0)\n");
417         printf("#define DOVECOT_IS_GT(maj, min)                 "
418 @@ -50,6 +56,22 @@ int main(int argc, char **argv)
419                 "DOVECOT_VCODE < DOVECOT_VERSION_CODE(maj, min, 0)\n");
420         printf("#define DOVECOT_IS_LE(maj, min)                 "
421                 "DOVECOT_VCODE <= DOVECOT_VERSION_CODE(maj, min, 0)\n");
422 +
423 +       printf("#define DOVECOT_P_IS_EQ(maj, min, patch)        "
424 +               "DOVECOT_VCODE_PATCH == DOVECOT_VERSION_CODE(maj, min, patch)\n");
425 +       printf("#define DOVECOT_P_IS_GT(maj, min, patch)        "
426 +               "DOVECOT_VCODE_PATCH > DOVECOT_VERSION_CODE(maj, min, patch)\n");
427 +       printf("#define DOVECOT_P_IS_GE(maj, min, patch)        "
428 +               "DOVECOT_VCODE_PATCH >= DOVECOT_VERSION_CODE(maj, min, patch)\n");
429 +       printf("#define DOVECOT_P_IS_LT(maj, min, patch)        "
430 +               "DOVECOT_VCODE_PATCH < DOVECOT_VERSION_CODE(maj, min, patch)\n");
431 +       printf("#define DOVECOT_P_IS_LE(maj, min, patch)        "
432 +               "DOVECOT_VCODE_PATCH <= DOVECOT_VERSION_CODE(maj, min, patch)\n");
433 +
434 +       /* Use the antispam-storage-2.0.c for dovecot 2.1 and 2.2 as well */
435 +       if (maj == 2 && min < 3)
436 +               min = 0;
437 +
438         printf("#define ANTISPAM_STORAGE                        "
439                 "\"antispam-storage-%d.%d.c\"\n", maj, min);
440  
441 diff --git a/dspam-exec.c b/dspam-exec.c
442 index 2e353ce..856babb 100644
443 --- a/dspam-exec.c
444 +++ b/dspam-exec.c
445 @@ -141,7 +141,7 @@ static int call_dspam(const struct antispam_config *cfg,
446                  */
447                 debugv_not_stderr(&cfg->dbgcfg, argv);
448  
449 -               t_push();
450 +               T_BEGIN {
451                 for (i = 0; i < cfg->dspam.extra_env_num; i++) {
452                         char *name, *value;
453                         name = t_strdup_noconst(cfg->dspam.extra_env[i]);
454 @@ -152,7 +152,7 @@ static int call_dspam(const struct antispam_config *cfg,
455                         }
456                         setenv(name, value, 1);
457                 }
458 -               t_pop();
459 +               } T_END;
460  
461                 execv(cfg->dspam.binary, argv);
462                 debug(&cfg->dbgcfg, "executing %s failed: %d (uid=%d, gid=%d)",
463 diff --git a/pipe.c b/pipe.c
464 index 18c2233..f9abef5 100644
465 --- a/pipe.c
466 +++ b/pipe.c
467 @@ -34,16 +34,19 @@
468  static int run_pipe(const struct antispam_config *cfg,
469                     int mailfd, enum classification wanted)
470  {
471 -       const char *dest;
472 +       char **dest;
473 +       int dest_num;
474         pid_t pid;
475         int status;
476  
477         switch (wanted) {
478         case CLASS_SPAM:
479 -               dest = cfg->pipe.spam_arg;
480 +               dest = cfg->pipe.spam_args;
481 +               dest_num = cfg->pipe.spam_args_num;
482                 break;
483         case CLASS_NOTSPAM:
484 -               dest = cfg->pipe.ham_arg;
485 +               dest = cfg->pipe.ham_args;
486 +               dest_num = cfg->pipe.ham_args_num;
487                 break;
488         }
489  
490 @@ -65,18 +68,23 @@ static int run_pipe(const struct antispam_config *cfg,
491                 return WEXITSTATUS(status);
492         } else {
493                 char **argv;
494 -               int sz = sizeof(char *) * (2 + cfg->pipe.extra_args_num + 1);
495 -               int i, fd;
496 +               int sz = sizeof(char *) * (2 + cfg->pipe.extra_args_num + dest_num + 1);
497 +               int i, j, fd;
498  
499                 argv = i_malloc(sz);
500                 memset(argv, 0, sz);
501  
502                 argv[0] = (char *) cfg->pipe.pipe_binary;
503  
504 -               for (i = 0; i < cfg->pipe.extra_args_num; i++)
505 +               for (i = 0; i < cfg->pipe.extra_args_num; i++) {
506                         argv[i + 1] = (char *) cfg->pipe.extra_args[i];
507 +                       debug(&cfg->dbgcfg, "running mailtrain backend program parameter %d %s", i + 1, argv[i + 1]);
508 +               }
509  
510 -               argv[i + 1] = (char *) dest;
511 +               for (j = 0; j < dest_num; j++) {
512 +                       argv[i + 1 + j] = (char *) dest[j];
513 +                       debug(&cfg->dbgcfg, "running mailtrain backend program parameter %d %s", i + 1 + j, argv[i + 1 + j]);
514 +               }
515  
516                 dup2(mailfd, 0);
517                 fd = open("/dev/null", O_WRONLY);
518 @@ -128,7 +136,7 @@ static int process_tmpdir(const struct antispam_config *cfg,
519         enum classification wanted;
520         int rc = 0;
521  
522 -       t_push();
523 +       T_BEGIN {
524  
525         buf = t_malloc(20 + ast->tmplen);
526  
527 @@ -151,7 +159,7 @@ static int process_tmpdir(const struct antispam_config *cfg,
528                 close(fd);
529         }
530  
531 -       t_pop();
532 +       } T_END;
533  
534         return rc;
535  }
536 @@ -160,7 +168,7 @@ static void clear_tmpdir(struct antispam_transaction_context *ast)
537  {
538         char *buf;
539  
540 -       t_push();
541 +       T_BEGIN {
542  
543         buf = t_malloc(20 + ast->tmplen);
544  
545 @@ -172,7 +180,7 @@ static void clear_tmpdir(struct antispam_transaction_context *ast)
546         }
547         rmdir(ast->tmpdir);
548  
549 -       t_pop();
550 +       } T_END;
551  }
552  
553  static void backend_rollback(const struct antispam_config *cfg ATTR_UNUSED,
554 @@ -228,7 +236,7 @@ static int backend_handle_mail(const struct antispam_config *cfg,
555                 return -1;
556         }
557  
558 -       if (!cfg->pipe.ham_arg || !cfg->pipe.spam_arg) {
559 +       if (!cfg->pipe.ham_args || !cfg->pipe.spam_args) {
560                 mail_storage_set_error(t->box->storage,
561                                        ME(NOTPOSSIBLE)
562                                        "antispam plugin not configured");
563 @@ -242,7 +250,7 @@ static int backend_handle_mail(const struct antispam_config *cfg,
564                 return -1;
565         }
566  
567 -       t_push();
568 +       T_BEGIN {
569  
570         buf = t_malloc(20 + ast->tmplen);
571         i_snprintf(buf, 20 + ast->tmplen - 1, "%s/%d", ast->tmpdir, ast->count);
572 @@ -303,8 +311,8 @@ static int backend_handle_mail(const struct antispam_config *cfg,
573         o_stream_destroy(&outstream);
574   out_close:
575         close(fd);
576 - out:
577 -       t_pop();
578 + out:  ;
579 +       } T_END;
580  
581         return ret;
582  }
583 @@ -316,20 +324,50 @@ static void backend_init(struct antispam_config *cfg,
584         const char *tmp;
585         int i;
586  
587 -       tmp = getenv("PIPE_PROGRAM_SPAM_ARG", getenv_data);
588 -       if (!tmp)
589 -               tmp = getenv("MAIL_SPAM", getenv_data);
590 +       tmp = getenv("PIPE_PROGRAM_SPAM_ARGS", getenv_data);
591         if (tmp) {
592 -               cfg->pipe.spam_arg = tmp;
593 -               debug(&cfg->dbgcfg, "pipe backend spam argument = %s\n", tmp);
594 +               cfg->pipe.spam_args = p_strsplit(cfg->mem_pool, tmp, ";");
595 +               cfg->pipe.spam_args_num = str_array_length(
596 +                                       (const char *const *)cfg->pipe.spam_args);
597 +               for (i = 0; i < cfg->pipe.spam_args_num; i++)
598 +                       debug(&cfg->dbgcfg, "pipe backend spam arg[%d] = %s\n",
599 +                             i, cfg->pipe.spam_args[i]);
600 +       } else {
601 +               tmp = getenv("PIPE_PROGRAM_SPAM_ARG", getenv_data);
602 +               if (!tmp)
603 +                       tmp = getenv("MAIL_SPAM", getenv_data);
604 +               if (tmp) {
605 +                       /* bit of a hack */
606 +                       cfg->pipe.spam_args =
607 +                               p_strsplit(cfg->mem_pool, tmp, "\x01");
608 +                       cfg->pipe.spam_args_num = 1;
609 +                       debug(&cfg->dbgcfg,
610 +                             "pipe backend spam argument = %s\n", tmp);
611 +                       tmp = NULL;
612 +               }
613         }
614  
615 -       tmp = getenv("PIPE_PROGRAM_NOTSPAM_ARG", getenv_data);
616 -       if (!tmp)
617 -               tmp = getenv("MAIL_NOTSPAM", getenv_data);
618 +       tmp = getenv("PIPE_PROGRAM_NOTSPAM_ARGS", getenv_data);
619         if (tmp) {
620 -               cfg->pipe.ham_arg = tmp;
621 -               debug(&cfg->dbgcfg, "pipe backend not-spam argument = %s\n", tmp);
622 +               cfg->pipe.ham_args = p_strsplit(cfg->mem_pool, tmp, ";");
623 +               cfg->pipe.ham_args_num = str_array_length(
624 +                                       (const char *const *)cfg->pipe.ham_args);
625 +               for (i = 0; i < cfg->pipe.ham_args_num; i++)
626 +                       debug(&cfg->dbgcfg, "pipe backend ham arg[%d] = %s\n",
627 +                             i, cfg->pipe.ham_args[i]);
628 +       } else {
629 +               tmp = getenv("PIPE_PROGRAM_NOTSPAM_ARG", getenv_data);
630 +               if (!tmp)
631 +                       tmp = getenv("MAIL_NOTSPAM", getenv_data);
632 +               if (tmp) {
633 +                       /* bit of a hack */
634 +                       cfg->pipe.ham_args =
635 +                               p_strsplit(cfg->mem_pool, tmp, "\x01");
636 +                       cfg->pipe.ham_args_num = 1;
637 +                       debug(&cfg->dbgcfg,
638 +                             "pipe backend not-spam argument = %s\n", tmp);
639 +                       tmp = NULL;
640 +               }
641         }
642  
643         tmp = getenv("PIPE_PROGRAM", getenv_data);
644 diff --git a/spool2dir.c b/spool2dir.c
645 index cbd1909..d304716 100644
646 --- a/spool2dir.c
647 +++ b/spool2dir.c
648 @@ -165,7 +165,7 @@ static int backend_handle_mail(const struct antispam_config *cfg,
649                 return -1;
650         }
651  
652 -       t_push();
653 +       T_BEGIN {
654  
655         /* atomically create a _new_ file */
656         while (ast->count <= 9999) {
657 @@ -174,9 +174,6 @@ static int backend_handle_mail(const struct antispam_config *cfg,
658                 if (fd >= 0 || errno != EEXIST)
659                         break;
660                 /* current filename in buf already exists, zap it */
661 -               t_pop();
662 -               t_push();
663 -               /* buf is invalid now! */
664         }
665  
666         if (fd < 0) {
667 @@ -225,8 +222,8 @@ static int backend_handle_mail(const struct antispam_config *cfg,
668         close(fd);
669         if (ret)
670                 unlink(buf);
671 - out:
672 -       t_pop();
673 + out:  ;
674 +       } T_END;
675  
676         return ret;
677  }
This page took 0.108494 seconds and 3 git commands to generate.