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