]> git.pld-linux.org Git - packages/dovecot-antispam.git/blame - dovecot-antispam-git.patch
Release 77 (by relup.sh)
[packages/dovecot-antispam.git] / dovecot-antispam-git.patch
CommitLineData
e0859999
AM
1commit 98b5e06d18f6a95695833afaa4b9bc1f256648df
2Author: Johannes Berg <johannes@sipsolutions.net>
3Date: Mon Nov 7 11:00:25 2011 +0100
4
5 small whitespace fix
6
7diff --git a/antispam-storage-2.0.c b/antispam-storage-2.0.c
8index 5a089bc..3e67553 100644
9--- a/antispam-storage-2.0.c
10+++ b/antispam-storage-2.0.c
11@@ -472,7 +472,7 @@ static void antispam_mailbox_allocated(struct mailbox *box)
12
13 asbox->save_hack = FALSE;
14 asbox->movetype = MMT_APPEND;
15- asbox->cfg = asuser->cfg;
16+ asbox->cfg = asuser->cfg;
17
18 v->free = antispam_mailbox_free;
19
20
21commit ecaa554d472002a001bc2b91526cecaf2f21a480
22Author: Johannes Berg <johannes@sipsolutions.net>
23Date: Fri Feb 24 20:22:48 2012 +0100
24
25 allow multiple spam/not_spam arguments
26
27 Some tools need multiple different arguments,
28 so introduce configuration for that.
29
30diff --git a/antispam-plugin.h b/antispam-plugin.h
31index 280bb12..5bd3f06 100644
32--- a/antispam-plugin.h
33+++ b/antispam-plugin.h
34@@ -98,8 +98,10 @@ struct antispam_config {
35 int extra_env_num;
36 } crm;
37 struct {
38- const char *spam_arg;
39- const char *ham_arg;
40+ char **spam_args;
41+ int spam_args_num;
42+ char **ham_args;
43+ int ham_args_num;
44 const char *pipe_binary;// = "/usr/sbin/sendmail";
45 const char *tmpdir;// = "/tmp";
46 char **extra_args;
47diff --git a/antispam.7 b/antispam.7
48index 5e33e4c..d87db93 100644
49--- a/antispam.7
50+++ b/antispam.7
51@@ -228,6 +228,14 @@ plugin {
52 # "mailtrain" are still valid, these are, in the same order as
53 # above: antispam_mail_sendmail, antispam_mail_sendmail_args,
54 # antispam_mail_spam, antispam_mail_notspam and antispam_mail_tmpdir.
55+ #
56+ # Alternatively, if you need to give multiple options, you can use
57+ # the spam_args/notspam_args parameters (which are used in preference
58+ # of the singular form):
59+ # antispam_pipe_program_spam_args = --spam;--my-other-param1
60+ # antispam_pipe_program_notspam_args = --ham;--my-other-param2
61+ # which will then call
62+ # /path/to/mailtrain --for jberg --spam --my-other-param1
63
64 # temporary directory
65 antispam_pipe_tmpdir = /tmp
66diff --git a/pipe.c b/pipe.c
67index 18c2233..a20b4aa 100644
68--- a/pipe.c
69+++ b/pipe.c
70@@ -34,16 +34,19 @@
71 static int run_pipe(const struct antispam_config *cfg,
72 int mailfd, enum classification wanted)
73 {
74- const char *dest;
75+ char **dest;
76+ int dest_num;
77 pid_t pid;
78 int status;
79
80 switch (wanted) {
81 case CLASS_SPAM:
82- dest = cfg->pipe.spam_arg;
83+ dest = cfg->pipe.spam_args;
84+ dest_num = cfg->pipe.spam_args_num;
85 break;
86 case CLASS_NOTSPAM:
87- dest = cfg->pipe.ham_arg;
88+ dest = cfg->pipe.ham_args;
89+ dest_num = cfg->pipe.spam_args_num;
90 break;
91 }
92
93@@ -65,18 +68,23 @@ static int run_pipe(const struct antispam_config *cfg,
94 return WEXITSTATUS(status);
95 } else {
96 char **argv;
97- int sz = sizeof(char *) * (2 + cfg->pipe.extra_args_num + 1);
98- int i, fd;
99+ int sz = sizeof(char *) * (2 + cfg->pipe.extra_args_num + dest_num + 1);
100+ int i, j, fd;
101
102 argv = i_malloc(sz);
103 memset(argv, 0, sz);
104
105 argv[0] = (char *) cfg->pipe.pipe_binary;
106
107- for (i = 0; i < cfg->pipe.extra_args_num; i++)
108+ for (i = 0; i < cfg->pipe.extra_args_num; i++) {
109 argv[i + 1] = (char *) cfg->pipe.extra_args[i];
110+ debug(&cfg->dbgcfg, "running mailtrain backend program parameter %d %s", i + 1, argv[i + 1]);
111+ }
112
113- argv[i + 1] = (char *) dest;
114+ for (j = 0; j < dest_num; j++) {
115+ argv[i + 1 + j] = (char *) dest[j];
116+ debug(&cfg->dbgcfg, "running mailtrain backend program parameter %d %s", i + 1 + j, argv[i + 1 + j]);
117+ }
118
119 dup2(mailfd, 0);
120 fd = open("/dev/null", O_WRONLY);
121@@ -228,7 +236,7 @@ static int backend_handle_mail(const struct antispam_config *cfg,
122 return -1;
123 }
124
125- if (!cfg->pipe.ham_arg || !cfg->pipe.spam_arg) {
126+ if (!cfg->pipe.ham_args || !cfg->pipe.spam_args) {
127 mail_storage_set_error(t->box->storage,
128 ME(NOTPOSSIBLE)
129 "antispam plugin not configured");
130@@ -316,20 +324,50 @@ static void backend_init(struct antispam_config *cfg,
131 const char *tmp;
132 int i;
133
134- tmp = getenv("PIPE_PROGRAM_SPAM_ARG", getenv_data);
135- if (!tmp)
136- tmp = getenv("MAIL_SPAM", getenv_data);
137+ tmp = getenv("PIPE_PROGRAM_SPAM_ARGS", getenv_data);
138 if (tmp) {
139- cfg->pipe.spam_arg = tmp;
140- debug(&cfg->dbgcfg, "pipe backend spam argument = %s\n", tmp);
141+ cfg->pipe.spam_args = p_strsplit(cfg->mem_pool, tmp, ";");
142+ cfg->pipe.spam_args_num = str_array_length(
143+ (const char *const *)cfg->pipe.spam_args);
144+ for (i = 0; i < cfg->pipe.spam_args_num; i++)
145+ debug(&cfg->dbgcfg, "pipe backend spam arg[%d] = %s\n",
146+ i, cfg->pipe.spam_args[i]);
147+ } else {
148+ tmp = getenv("PIPE_PROGRAM_SPAM_ARG", getenv_data);
149+ if (!tmp)
150+ tmp = getenv("MAIL_SPAM", getenv_data);
151+ if (tmp) {
152+ /* bit of a hack */
153+ cfg->pipe.spam_args =
154+ p_strsplit(cfg->mem_pool, tmp, "\x01");
155+ cfg->pipe.spam_args_num = 1;
156+ debug(&cfg->dbgcfg,
157+ "pipe backend spam argument = %s\n", tmp);
158+ tmp = NULL;
159+ }
160 }
161
162- tmp = getenv("PIPE_PROGRAM_NOTSPAM_ARG", getenv_data);
163- if (!tmp)
164- tmp = getenv("MAIL_NOTSPAM", getenv_data);
165+ tmp = getenv("PIPE_PROGRAM_NOTSPAM_ARGS", getenv_data);
166 if (tmp) {
167- cfg->pipe.ham_arg = tmp;
168- debug(&cfg->dbgcfg, "pipe backend not-spam argument = %s\n", tmp);
169+ cfg->pipe.ham_args = p_strsplit(cfg->mem_pool, tmp, ";");
170+ cfg->pipe.ham_args_num = str_array_length(
171+ (const char *const *)cfg->pipe.ham_args);
172+ for (i = 0; i < cfg->pipe.ham_args_num; i++)
173+ debug(&cfg->dbgcfg, "pipe backend ham arg[%d] = %s\n",
174+ i, cfg->pipe.ham_args[i]);
175+ } else {
176+ tmp = getenv("PIPE_PROGRAM_NOTSPAM_ARG", getenv_data);
177+ if (!tmp)
178+ tmp = getenv("MAIL_NOTSPAM", getenv_data);
179+ if (tmp) {
180+ /* bit of a hack */
181+ cfg->pipe.ham_args =
182+ p_strsplit(cfg->mem_pool, tmp, "\x01");
183+ cfg->pipe.ham_args_num = 1;
184+ debug(&cfg->dbgcfg,
185+ "pipe backend not-spam argument = %s\n", tmp);
186+ tmp = NULL;
187+ }
188 }
189
190 tmp = getenv("PIPE_PROGRAM", getenv_data);
191
192commit d5f9b770ecc6cd6226d8d4806844eb615307e00e
193Author: Ron <ron@debian.org>
194Date: Sat Mar 24 22:12:45 2012 +1030
195
196 Fix dspam config example in antispam.7
197
198 Move some dspam configuration out of the crm114 section.
199 Thanks to Benoît Knecht for catching this. Closes: #663721
200
201diff --git a/antispam.7 b/antispam.7
202index d87db93..5d077f0 100644
203--- a/antispam.7
204+++ b/antispam.7
205@@ -1,4 +1,4 @@
206-.TH ANTISPAM 7 "15 October 2007" "" ""
207+.TH ANTISPAM 7 "24 March 2012" "" ""
208 .SH NAME
209 antispam \- The dovecot antispam plugin.
210
211@@ -206,6 +206,11 @@ plugin {
212 # semicolon-separated list of blacklisted results, case insensitive
213 # antispam_dspam_result_blacklist = Virus
214
215+ # semicolon-separated list of environment variables to set
216+ # (default unset i.e. none)
217+ # antispam_dspam_env =
218+ # antispam_dspam_env = HOME=%h;USER=%u
219+
220 #=====================
221 # pipe plugin
222 #
223@@ -255,7 +260,7 @@ plugin {
224 antispam_crm_binary = /bin/false
225 # antispam_crm_binary = /usr/share/crm114/mailreaver.crm
226
227- # semicolon-separated list of extra arguments to dspam
228+ # semicolon-separated list of extra arguments to crm114
229 # (default unset i.e. none)
230 # antispam_crm_args =
231 # antispam_crm_args = --config=/path/to/config
232@@ -265,11 +270,6 @@ plugin {
233 # antispam_crm_env =
234 # antispam_crm_env = HOME=%h;USER=%u
235
236- # semicolon-separated list of environment variables to set
237- # (default unset i.e. none)
238- # antispam_dspam_env =
239- # antispam_dspam_env = HOME=%h;USER=%u
240-
241 # NOTE: you need to set the signature for this backend
242 antispam_signature = X-CRM114-CacheID
243
244
245commit 83b0b4b8a5e85f70025fbb874c30d3e28ad01f56
246Author: Ron <ron@debian.org>
247Date: Thu Sep 27 11:27:20 2012 +0200
248
249 make it work for dovecot 2.1
250
251 This patch from me/Ron tweaks the code to use
252 the same backends for dovecot 2.1 as for 2.0.
253
254diff --git a/antispam-plugin.h b/antispam-plugin.h
255index 5bd3f06..72b906d 100644
256--- a/antispam-plugin.h
257+++ b/antispam-plugin.h
258@@ -262,7 +262,7 @@ o_stream_create_from_fd(int fd, pool_t pool ATTR_UNUSED)
259 {
260 return o_stream_create_fd(fd, 0, TRUE);
261 }
262-#elif DOVECOT_IS_EQ(2, 0)
263+#elif DOVECOT_IS_EQ(2, 0) || DOVECOT_IS_EQ(2, 1)
264 #define mempool_unref pool_unref
265 #define module_arg struct module *
266 #define ME(err) MAIL_ERROR_ ##err,
267diff --git a/dovecot-version.c b/dovecot-version.c
268index cbcb35b..0026fbf 100644
269--- a/dovecot-version.c
270+++ b/dovecot-version.c
271@@ -17,21 +17,24 @@ int main(int argc, char **argv)
272
273 maj = strtol(v, &e, 10);
274 if (v == e)
275- return 1;
276+ return 2;
277
278 v = e + 1;
279
280 min = strtol(v, &e, 10);
281 if (v == e)
282- return 1;
283+ return 3;
284
285 /* not end of string yet? */
286 if (*e) {
287 v = e + 1;
288
289- patch = strtol(v, &e, 10);
290- if (v == e)
291- return 1;
292+ if (isdigit(*v)) {
293+ patch = strtol(v, &e, 10);
294+ if (v == e)
295+ return 4;
296+ } else
297+ patch = 255;
298 }
299
300 printf("/* Auto-generated file, do not edit */\n\n");
301@@ -50,6 +53,11 @@ int main(int argc, char **argv)
302 "DOVECOT_VCODE < DOVECOT_VERSION_CODE(maj, min, 0)\n");
303 printf("#define DOVECOT_IS_LE(maj, min) "
304 "DOVECOT_VCODE <= DOVECOT_VERSION_CODE(maj, min, 0)\n");
305+
306+ /* Use the antispam-storage-2.0.c for dovecot 2.1 as well */
307+ if (maj == 2 && min == 1)
308+ min = 0;
309+
310 printf("#define ANTISPAM_STORAGE "
311 "\"antispam-storage-%d.%d.c\"\n", maj, min);
312
313
314commit 8e2caa4c2ad42feb65a0693711f73f17f417fb87
315Author: Johannes Berg <johannes@sipsolutions.net>
316Date: Wed Aug 21 22:33:37 2013 +0200
317
318 remove unnecessary dict code
319
320 I long removed the signature-log backend, so the support code
321 for it to use dovecot's dict API across multiple version is
322 really no longer needed - kill it.
323
324 This was reported to me (indirectly) by Micah Anderson, thanks.
325
326diff --git a/antispam-plugin.h b/antispam-plugin.h
327index 72b906d..0c3f18e 100644
328--- a/antispam-plugin.h
329+++ b/antispam-plugin.h
330@@ -10,7 +10,6 @@
331 #include "client.h"
332 #endif
333 #include "ostream.h"
334-#include "dict.h"
335 #include "imap-search.h"
336 #include <stdlib.h>
337
338@@ -206,12 +205,6 @@ o_stream_create_from_fd(int fd, pool_t pool)
339 return o_stream_create_file(fd, pool, 0, TRUE);
340 }
341
342-static inline struct dict *
343-string_dict_init(const char *uri, const char *username)
344-{
345- return dict_init(uri, username);
346-}
347-
348 static inline int _mail_get_stream(struct mail *mail,
349 struct message_size *hdr_size,
350 struct message_size *body_size,
351@@ -281,12 +274,6 @@ o_stream_create_from_fd(int fd, pool_t pool ATTR_UNUSED)
352 {
353 return o_stream_create_fd(fd, 0, TRUE);
354 }
355-
356-static inline struct dict *
357-string_dict_init(const char *uri, const char *username)
358-{
359- return dict_init(uri, DICT_DATA_TYPE_STRING, username, NULL);
360-}
361 #else
362 #error "Building against this dovecot version is not supported"
363 #endif
364
365commit c2d97b386177d945581574e74690d773a6231338
366Author: Micah Anderson <micah@riseup.net>
367Date: Wed Aug 21 21:25:41 2013 -0400
368
369 make things work for dovecot 2.2
370
371diff --git a/antispam-plugin.h b/antispam-plugin.h
372index 0c3f18e..a06f7be 100644
373--- a/antispam-plugin.h
374+++ b/antispam-plugin.h
375@@ -255,7 +255,7 @@ o_stream_create_from_fd(int fd, pool_t pool ATTR_UNUSED)
376 {
377 return o_stream_create_fd(fd, 0, TRUE);
378 }
379-#elif DOVECOT_IS_EQ(2, 0) || DOVECOT_IS_EQ(2, 1)
380+#elif DOVECOT_IS_EQ(2, 0) || DOVECOT_IS_EQ(2, 1) || DOVECOT_IS_EQ(2, 2)
381 #define mempool_unref pool_unref
382 #define module_arg struct module *
383 #define ME(err) MAIL_ERROR_ ##err,
384
385commit abdad24e671da556682fb1bca2a076bc8686025a
386Author: Ron <ron@debian.org>
387Date: Thu Sep 12 18:49:34 2013 +0930
388
389 More tweaks for dovecot 2.2
390
391 Use antispam-storage-2.0.c for 2.2 as well.
392 Dovecot 2.2 now checks for a real ABI version string rather than
393 just the release version.
394
4c03318d 395diff --git a/antispam-plugin.c b/antispam-plugin.c
e0859999
AM
396index 7756204..103b5fb 100644
397--- a/antispam-plugin.c
398+++ b/antispam-plugin.c
399@@ -392,4 +392,8 @@ void PLUGIN_FUNCTION(deinit)(void)
400 }
401
402 /* put dovecot version we built against into plugin for checking */
403+#if DOVECOT_IS_GE(2,2)
404+const char *PLUGIN_FUNCTION(version) = DOVECOT_ABI_VERSION;
405+#else
406 const char *PLUGIN_FUNCTION(version) = PACKAGE_VERSION;
407+#endif
408diff --git a/dovecot-version.c b/dovecot-version.c
409index 0026fbf..e7e7cf2 100644
410--- a/dovecot-version.c
411+++ b/dovecot-version.c
412@@ -54,8 +54,8 @@ int main(int argc, char **argv)
413 printf("#define DOVECOT_IS_LE(maj, min) "
414 "DOVECOT_VCODE <= DOVECOT_VERSION_CODE(maj, min, 0)\n");
415
416- /* Use the antispam-storage-2.0.c for dovecot 2.1 as well */
417- if (maj == 2 && min == 1)
418+ /* Use the antispam-storage-2.0.c for dovecot 2.1 and 2.2 as well */
419+ if (maj == 2 && min < 3)
420 min = 0;
421
422 printf("#define ANTISPAM_STORAGE "
423
424commit 446b62b634db89054073e0484626c5c4623d9903
425Author: Johannes Berg <johannes@sipsolutions.net>
426Date: Fri Oct 24 17:33:21 2014 +0200
427
428 add version check macros to check for dovecot patchlevel
429
430 Add a new set of version check macros that also take the patchlevel.
431
432diff --git a/dovecot-version.c b/dovecot-version.c
433index e7e7cf2..623461a 100644
434--- a/dovecot-version.c
435+++ b/dovecot-version.c
436@@ -34,7 +34,7 @@ int main(int argc, char **argv)
437 if (v == e)
438 return 4;
439 } else
440- patch = 255;
441+ patch = 0;
442 }
443
444 printf("/* Auto-generated file, do not edit */\n\n");
445@@ -43,6 +43,8 @@ int main(int argc, char **argv)
446
447 printf("#define DOVECOT_VCODE "
448 "0x%.2x%.2x%.2x\n", maj, min, 0);
449+ printf("#define DOVECOT_VCODE_PATCH "
450+ "0x%.2x%.2x%.2x\n", maj, min, patch);
451 printf("#define DOVECOT_IS_EQ(maj, min) "
452 "DOVECOT_VCODE == DOVECOT_VERSION_CODE(maj, min, 0)\n");
453 printf("#define DOVECOT_IS_GT(maj, min) "
454@@ -54,6 +56,17 @@ int main(int argc, char **argv)
455 printf("#define DOVECOT_IS_LE(maj, min) "
456 "DOVECOT_VCODE <= DOVECOT_VERSION_CODE(maj, min, 0)\n");
457
458+ printf("#define DOVECOT_P_IS_EQ(maj, min, patch) "
459+ "DOVECOT_VCODE_PATCH == DOVECOT_VERSION_CODE(maj, min, patch)\n");
460+ printf("#define DOVECOT_P_IS_GT(maj, min, patch) "
461+ "DOVECOT_VCODE_PATCH > DOVECOT_VERSION_CODE(maj, min, patch)\n");
462+ printf("#define DOVECOT_P_IS_GE(maj, min, patch) "
463+ "DOVECOT_VCODE_PATCH >= DOVECOT_VERSION_CODE(maj, min, patch)\n");
464+ printf("#define DOVECOT_P_IS_LT(maj, min, patch) "
465+ "DOVECOT_VCODE_PATCH < DOVECOT_VERSION_CODE(maj, min, patch)\n");
466+ printf("#define DOVECOT_P_IS_LE(maj, min, patch) "
467+ "DOVECOT_VCODE_PATCH <= DOVECOT_VERSION_CODE(maj, min, patch)\n");
468+
469 /* Use the antispam-storage-2.0.c for dovecot 2.1 and 2.2 as well */
470 if (maj == 2 && min < 3)
471 min = 0;
472
473commit eba2805c61c37cc006b9a90b43ba61f3256ee190
474Author: Ron <ron@debian.org>
475Date: Sat Oct 25 00:47:21 2014 +1030
476
477 Add a compatibility macro for t_push()
478
479 This should fix things for the API change in dovecot 2.2.14 reported in:
480 https://bugs.debian.org/765943
481
482diff --git a/antispam-plugin.h b/antispam-plugin.h
483index a06f7be..245393b 100644
484--- a/antispam-plugin.h
485+++ b/antispam-plugin.h
486@@ -260,6 +260,10 @@ o_stream_create_from_fd(int fd, pool_t pool ATTR_UNUSED)
487 #define module_arg struct module *
488 #define ME(err) MAIL_ERROR_ ##err,
489
490+#if DOVECOT_P_IS_GE(2,2,14)
491+#define t_push() t_push(__func__)
492+#endif
493+
494 static inline const char *const *
495 get_mail_headers(struct mail *mail, const char *hdr)
496 {
497
498commit 31c81ae3faa205c245b0245c027a9a4e2f72e504
499Author: Timo Sirainen <tss@iki.fi>
500Date: Mon Nov 10 11:57:28 2014 +0100
501
502 use T_BEGIN/T_END
503
504 Johannes: Timo's patch, adjusted to fix compilation and carry
505 a backport for dovecot 1.0 in case somebody still
506 uses that
507
508 For the original (although modified by somebody else to compile):
509 Acked-by: Phil Carmody <phil@dovecot.fi>
510
511diff --git a/antispam-plugin.c b/antispam-plugin.c
512index 103b5fb..76ced7b 100644
4c03318d
JR
513--- a/antispam-plugin.c
514+++ b/antispam-plugin.c
515@@ -90,7 +90,7 @@ static bool mailbox_patternmatch(struct mailbox *box,
516 return FALSE;
517 #endif
518
519- t_push();
520+ T_BEGIN {
521
522 boxname = mailbox_get_name(box);
523 if (lowercase) {
524@@ -110,7 +110,7 @@ static bool mailbox_patternmatch(struct mailbox *box,
525
526 rc = memcmp(name, boxname, len) == 0;
527
528- t_pop();
529+ } T_END;
530
531 return rc;
532 }
533@@ -257,7 +257,7 @@ static int parse_folder_setting(const struct antispam_config *cfg,
534 int cnt = 0;
535 enum match_type i;
536
537- t_push();
538+ T_BEGIN {
539
540 for (i = 0; i < NUM_MT; ++i) {
541 tmp = getenv(t_strconcat(setting, match_info[i].suffix, NULL),
542@@ -286,7 +286,7 @@ static int parse_folder_setting(const struct antispam_config *cfg,
543 }
544 }
545
546- t_pop();
547+ } T_END;
548
549 if (!cnt)
550 debug(&cfg->dbgcfg, "no %s folders\n", display_name);
33b8a89c 551diff --git a/antispam-plugin.h b/antispam-plugin.h
e0859999 552index 245393b..f813964 100644
33b8a89c
JR
553--- a/antispam-plugin.h
554+++ b/antispam-plugin.h
e0859999 555@@ -217,6 +217,11 @@ static inline int _mail_get_stream(struct mail *mail,
4c03318d
JR
556 return 0;
557 }
558 #define mail_get_stream _mail_get_stream
559+
560+#define T_BEGIN \
561+ STMT_START { t_push();
562+#define T_END \
563+ t_pop(); } STMT_END
564 #elif DOVECOT_IS_EQ(1, 1)
565 #define mempool_unref pool_unref
566 #define module_arg void
e0859999 567@@ -260,10 +265,6 @@ o_stream_create_from_fd(int fd, pool_t pool ATTR_UNUSED)
33b8a89c 568 #define module_arg struct module *
e0859999
AM
569 #define ME(err) MAIL_ERROR_ ##err,
570
571-#if DOVECOT_P_IS_GE(2,2,14)
572-#define t_push() t_push(__func__)
573-#endif
574-
575 static inline const char *const *
576 get_mail_headers(struct mail *mail, const char *hdr)
577 {
4c03318d
JR
578diff --git a/antispam-storage-1.1.c b/antispam-storage-1.1.c
579index f28a0cf..aab23d9 100644
580--- a/antispam-storage-1.1.c
581+++ b/antispam-storage-1.1.c
582@@ -508,10 +508,10 @@ void antispam_mail_storage_created(struct mail_storage *storage)
583
584 static const char *_getenv(const char *env, void *data ATTR_UNUSED)
585 {
586- t_push();
587+ T_BEGIN {
588 env = t_str_ucase(t_strconcat("antispam_", env, NULL));
589 env = getenv(env);
590- t_pop();
591+ } T_END;
592
593 return env;
594 }
595diff --git a/antispam-storage-1.2.c b/antispam-storage-1.2.c
596index 5e0cb97..269a373 100644
597--- a/antispam-storage-1.2.c
598+++ b/antispam-storage-1.2.c
599@@ -498,10 +498,10 @@ void antispam_mail_storage_created(struct mail_storage *storage)
600
601 static const char *_getenv(const char *env, void *data ATTR_UNUSED)
602 {
603- t_push();
604+ T_BEGIN {
605 env = t_str_ucase(t_strconcat("antispam_", env, NULL));
606 env = getenv(env);
607- t_pop();
608+ } T_END;
609
610 return env;
611 }
33b8a89c 612diff --git a/antispam-storage-2.0.c b/antispam-storage-2.0.c
e0859999 613index 3e67553..c3d6251 100644
33b8a89c
JR
614--- a/antispam-storage-2.0.c
615+++ b/antispam-storage-2.0.c
e0859999 616@@ -494,11 +494,11 @@ static const char *_getenv(const char *name, void *data)
4c03318d
JR
617 struct mail_user *user = data;
618 const char *env;
619
620- t_push();
621+ T_BEGIN {
622 env = t_strconcat("antispam_", t_str_lcase(name), NULL);
623
624 env = mail_user_plugin_getenv(user, env);
625- t_pop();
626+ } T_END;
627
628 return env;
629 }
4c03318d
JR
630diff --git a/crm114-exec.c b/crm114-exec.c
631index 5b39ca9..d786e04 100644
632--- a/crm114-exec.c
633+++ b/crm114-exec.c
634@@ -113,7 +113,7 @@ static int call_reaver(const struct antispam_config *cfg,
635
636 debugv(&cfg->dbgcfg, argv);
637
638- t_push();
639+ T_BEGIN {
640 for (i = 0; i < cfg->crm.extra_env_num; i++) {
641 char *name, *value;
642 name = t_strdup_noconst(cfg->crm.extra_env[i]);
643@@ -124,7 +124,7 @@ static int call_reaver(const struct antispam_config *cfg,
644 }
645 setenv(name, value, 1);
646 }
647- t_pop();
648+ } T_END;
649
650 execv(cfg->crm.reaver_binary, argv);
651 /* fall through if reaver can't be found */
652diff --git a/debug.c b/debug.c
e0859999 653index d2683fa..7a2353a 100644
4c03318d
JR
654--- a/debug.c
655+++ b/debug.c
e0859999 656@@ -14,7 +14,7 @@ static void _debug(const struct antispam_debug_config *cfg,
4c03318d
JR
657 if (cfg->target == ADT_NONE)
658 return;
659
660- t_push();
661+ T_BEGIN {
662
e0859999 663 fmt = t_strconcat("antispam: ", format, NULL);
4c03318d 664
e0859999 665@@ -30,7 +30,7 @@ static void _debug(const struct antispam_debug_config *cfg,
4c03318d
JR
666 break;
667 }
668
669- t_pop();
670+ } T_END;
671 }
672
673 void debug(const struct antispam_debug_config *cfg, const char *fmt, ...)
e0859999 674@@ -48,7 +48,7 @@ void debugv(const struct antispam_debug_config *cfg, char **args)
4c03318d
JR
675 char *buf;
676 const char *str;
677
678- t_push();
679+ T_BEGIN {
680 buf = t_buffer_get(buflen);
681
682 while (1) {
e0859999 683@@ -72,7 +72,7 @@ void debugv(const struct antispam_debug_config *cfg, char **args)
4c03318d
JR
684 t_buffer_alloc(pos);
685
686 debug(cfg, "%s", buf);
687- t_pop();
688+ } T_END;
689 }
690
691 void debugv_not_stderr(const struct antispam_debug_config *cfg, char **args)
4c03318d
JR
692diff --git a/dspam-exec.c b/dspam-exec.c
693index 2e353ce..856babb 100644
694--- a/dspam-exec.c
695+++ b/dspam-exec.c
696@@ -141,7 +141,7 @@ static int call_dspam(const struct antispam_config *cfg,
697 */
698 debugv_not_stderr(&cfg->dbgcfg, argv);
699
700- t_push();
701+ T_BEGIN {
702 for (i = 0; i < cfg->dspam.extra_env_num; i++) {
703 char *name, *value;
704 name = t_strdup_noconst(cfg->dspam.extra_env[i]);
705@@ -152,7 +152,7 @@ static int call_dspam(const struct antispam_config *cfg,
e0859999
AM
706 }
707 setenv(name, value, 1);
708 }
709- t_pop();
710+ } T_END;
33b8a89c 711
e0859999
AM
712 execv(cfg->dspam.binary, argv);
713 debug(&cfg->dbgcfg, "executing %s failed: %d (uid=%d, gid=%d)",
714diff --git a/pipe.c b/pipe.c
715index a20b4aa..1fc1904 100644
716--- a/pipe.c
717+++ b/pipe.c
718@@ -136,7 +136,7 @@ static int process_tmpdir(const struct antispam_config *cfg,
4c03318d
JR
719 enum classification wanted;
720 int rc = 0;
721
722- t_push();
723+ T_BEGIN {
724
725 buf = t_malloc(20 + ast->tmplen);
726
e0859999 727@@ -159,7 +159,7 @@ static int process_tmpdir(const struct antispam_config *cfg,
4c03318d
JR
728 close(fd);
729 }
730
731- t_pop();
732+ } T_END;
733
734 return rc;
735 }
e0859999 736@@ -168,7 +168,7 @@ static void clear_tmpdir(struct antispam_transaction_context *ast)
4c03318d
JR
737 {
738 char *buf;
739
740- t_push();
741+ T_BEGIN {
742
743 buf = t_malloc(20 + ast->tmplen);
744
e0859999 745@@ -180,7 +180,7 @@ static void clear_tmpdir(struct antispam_transaction_context *ast)
4c03318d
JR
746 }
747 rmdir(ast->tmpdir);
748
749- t_pop();
750+ } T_END;
751 }
752
753 static void backend_rollback(const struct antispam_config *cfg ATTR_UNUSED,
e0859999 754@@ -250,7 +250,7 @@ static int backend_handle_mail(const struct antispam_config *cfg,
4c03318d
JR
755 return -1;
756 }
757
758- t_push();
759+ T_BEGIN {
760
761 buf = t_malloc(20 + ast->tmplen);
762 i_snprintf(buf, 20 + ast->tmplen - 1, "%s/%d", ast->tmpdir, ast->count);
e0859999 763@@ -311,8 +311,8 @@ static int backend_handle_mail(const struct antispam_config *cfg,
4c03318d
JR
764 o_stream_destroy(&outstream);
765 out_close:
766 close(fd);
767- out:
768- t_pop();
769+ out: ;
770+ } T_END;
771
772 return ret;
773 }
4c03318d
JR
774diff --git a/spool2dir.c b/spool2dir.c
775index cbd1909..d304716 100644
776--- a/spool2dir.c
777+++ b/spool2dir.c
778@@ -165,7 +165,7 @@ static int backend_handle_mail(const struct antispam_config *cfg,
779 return -1;
780 }
781
782- t_push();
783+ T_BEGIN {
784
785 /* atomically create a _new_ file */
786 while (ast->count <= 9999) {
787@@ -174,9 +174,6 @@ static int backend_handle_mail(const struct antispam_config *cfg,
788 if (fd >= 0 || errno != EEXIST)
789 break;
790 /* current filename in buf already exists, zap it */
791- t_pop();
792- t_push();
793- /* buf is invalid now! */
794 }
795
796 if (fd < 0) {
797@@ -225,8 +222,8 @@ static int backend_handle_mail(const struct antispam_config *cfg,
798 close(fd);
799 if (ret)
800 unlink(buf);
801- out:
802- t_pop();
803+ out: ;
804+ } T_END;
805
806 return ret;
807 }
e0859999
AM
808
809commit 963c046c19b5d7019c607a8b648cae7b53d93ce2
810Author: Ron <ron@debian.org>
811Date: Sun Feb 22 08:58:23 2015 +1030
812
813 Use the correct argc for pipe.ham_args
814
815 This fixes a typo bug, where if the number of arguments set for
816 antispam_pipe_program_spam_arg is not the same as what was set
817 for antispam_pipe_program_notspam_arg, then we'll either scribble
818 past the end of the allocated argv array, or populate it with
819 pointers to whatever followed the real ham_args.
820
821 Thanks to Peter Colberg who reported this, including a correct
822 patch to fix it, to the security team. The security implications
823 of this seem somewhat limited, since you need to edit a config
824 file as root to create the bad situation, and there is no path
825 for remote injection of crafted data (whether it overflows or
826 underflows) if you do, the argv array will just get some 'random'
827 extra pointers to existing internal data.
828
829 However it does pose a potential problem for a legitimate user
830 who does legitimately need or want to pass a different number of
831 arguments for the spam and ham cases, since that could crash
832 dovecot, or confuse the hell out of their pipe program when it
833 gets some random extra arguments. It's probably gone unnoticed
834 for this long because most uses will pass the same number of
835 arguments for both of them, but that's not a necessary condition
836 in the general case.
837
838diff --git a/pipe.c b/pipe.c
839index 1fc1904..f9abef5 100644
840--- a/pipe.c
841+++ b/pipe.c
842@@ -46,7 +46,7 @@ static int run_pipe(const struct antispam_config *cfg,
843 break;
844 case CLASS_NOTSPAM:
845 dest = cfg->pipe.ham_args;
846- dest_num = cfg->pipe.spam_args_num;
847+ dest_num = cfg->pipe.ham_args_num;
848 break;
849 }
850
851
852commit 1ad6a9cf0dbed6cd51d3435a39fc5bfbfa2c27fd
853Author: Johannes Berg <johannes@sipsolutions.net>
854Date: Mon Jan 2 11:51:56 2017 +0100
855
856 fix mail_get_headers() return value usage
857
858 Dovecot 2.2.27 changed the mail_get_headers() return value
859 to be positive (not zero) for success, breaking everything.
860
861 Timo suggested to check for < 0, so do that.
862
863 Reported-by: Tom Talpey <tom@talpey.com>
864
865diff --git a/antispam-plugin.h b/antispam-plugin.h
866index f813964..a3a5c8d 100644
867--- a/antispam-plugin.h
868+++ b/antispam-plugin.h
869@@ -231,7 +231,7 @@ static inline const char *const *
870 get_mail_headers(struct mail *mail, const char *hdr)
871 {
872 const char *const *ret;
873- if (mail_get_headers(mail, hdr, &ret))
874+ if (mail_get_headers(mail, hdr, &ret) < 0)
875 return NULL;
876 return ret;
877 }
878@@ -250,7 +250,7 @@ static inline const char *const *
879 get_mail_headers(struct mail *mail, const char *hdr)
880 {
881 const char *const *ret;
882- if (mail_get_headers(mail, hdr, &ret))
883+ if (mail_get_headers(mail, hdr, &ret) < 0)
884 return NULL;
885 return ret;
886 }
887@@ -269,7 +269,7 @@ static inline const char *const *
888 get_mail_headers(struct mail *mail, const char *hdr)
889 {
890 const char *const *ret;
891- if (mail_get_headers(mail, hdr, &ret))
892+ if (mail_get_headers(mail, hdr, &ret) < 0)
893 return NULL;
894 return ret;
895 }
896
897commit 6b9003cb3a1b8f133ca70408b181109a48b10c57
898Author: Johannes Berg <johannes@sipsolutions.net>
899Date: Mon Jan 9 11:55:27 2017 +0100
900
901 make debug prefix configurable
902
903 The default remains "antispam: ", but you can now configure it
904 to include, for example, the logged-in username.
905
906diff --git a/antispam-plugin.h b/antispam-plugin.h
907index a3a5c8d..62a3eb3 100644
908--- a/antispam-plugin.h
909+++ b/antispam-plugin.h
910@@ -42,6 +42,7 @@ struct signature_config {
911 };
912
913 struct antispam_debug_config {
914+ const char *prefix;
915 enum antispam_debug_target target;
916 int verbose;
917 };
918diff --git a/antispam.7 b/antispam.7
919index 5d077f0..497da58 100644
920--- a/antispam.7
921+++ b/antispam.7
922@@ -120,6 +120,9 @@ plugin {
923 # antispam_debug_target = syslog
924 # antispam_debug_target = stderr
925 # antispam_verbose_debug = 1
926+ #
927+ # This can be used to get a prefix, e.g. by specifying %u in it
928+ # antispam_debug_prefix = "antispam: "
929
930 # backend selection, MUST be configured first,
931 # there's no default so you need to set one of
932diff --git a/debug.c b/debug.c
933index 7a2353a..e1f45a8 100644
934--- a/debug.c
935+++ b/debug.c
936@@ -16,7 +16,7 @@ static void _debug(const struct antispam_debug_config *cfg,
937
938 T_BEGIN {
939
940- fmt = t_strconcat("antispam: ", format, NULL);
941+ fmt = t_strconcat(cfg->prefix, format, NULL);
942
943 switch (cfg->target) {
944 case ADT_NONE:
945@@ -111,6 +111,10 @@ int debug_init(struct antispam_debug_config *cfg,
946 return -1;
947 }
948
949+ cfg->prefix = getenv("DEBUG_PREFIX", getenv_data);
950+ if (!cfg->prefix)
951+ cfg->prefix = "antispam: ";
952+
953 debug(cfg, "plugin initialising (%s)\n", ANTISPAM_VERSION);
954
955 tmp = getenv("VERBOSE_DEBUG", getenv_data);
956
957commit cf96d8d46fb98d81cc664e3dcee596af2b19628a
958Author: Ron <ron@debian.org>
959Date: Fri Jan 6 02:31:13 2017 +1030
960
961 Include ctype.h for isdigit
962
963 It's no longer pulled in implicitly with libc6 2.24 and gcc 6.3.
964
965diff --git a/dovecot-version.c b/dovecot-version.c
966index 623461a..fe9bc73 100644
967--- a/dovecot-version.c
968+++ b/dovecot-version.c
969@@ -1,6 +1,7 @@
970 #include <stdio.h>
971 #include <string.h>
972 #include <stdlib.h>
973+#include <ctype.h>
974 #include "config.h"
975
976 int main(int argc, char **argv)
977
978commit 649963a047ebad59f62b7cd620d6fe4329f392b2
979Author: Ron <ron@debian.org>
980Date: Fri Jan 6 02:49:19 2017 +1030
981
982 Drop the #define _BSD_SOURCE
983
984 In theory, it is needed for vsyslog(3), but glibc 2.20 deprecated it in
985 favour of _DEFAULT_SOURCE, and features.h in 2.24 now barks about it
986 being defined without _DEFAULT_SOURCE.
987
988 In practice, we don't need it at all here, since we aren't invoking the
989 compiler in a way that disables the default modes, so the "BSD" guarded
990 functions are already available to us by default anyway, and defining
991 _DEFAULT_SOURCE would be a no-op.
992
993diff --git a/debug.c b/debug.c
994index e1f45a8..77f0167 100644
995--- a/debug.c
996+++ b/debug.c
997@@ -1,4 +1,3 @@
998-#define _BSD_SOURCE
999 #include <syslog.h>
1000 #include <stdarg.h>
1001 #include <stdio.h>
1002
1003commit 0cab392a87b1d097fbd7a6cfcdfa29ad99ab78c9
1004Author: Johannes Berg <johannes.berg@intel.com>
1005Date: Sun Dec 24 14:15:57 2017 +0100
1006
1007 storage 2.0: abort COPY properly when errors happen
1008
1009diff --git a/antispam-storage-2.0.c b/antispam-storage-2.0.c
1010index c3d6251..3298908 100644
1011--- a/antispam-storage-2.0.c
1012+++ b/antispam-storage-2.0.c
1013@@ -108,6 +108,7 @@ antispam_copy(struct mail_save_context *ctx, struct mail *mail)
1014 if (mailbox_is_unsure(asbox->cfg, t->box)) {
1015 mail_storage_set_error(t->box->storage, MAIL_ERROR_NOTPOSSIBLE,
1016 "Cannot copy to unsure folder");
1017+ mailbox_save_cancel(&ctx);
1018 return -1;
1019 }
1020
1021
1022commit 713e9e9ffd4adfcc58c6e12470e87c9fd1b8af44
1023Author: Johannes Berg <johannes@sipsolutions.net>
1024Date: Thu Dec 28 18:51:12 2017 +0100
1025
1026 support dovecot 2.3
1027
1028 Tested by Björn Franke.
1029
1030diff --git a/antispam-plugin.h b/antispam-plugin.h
1031index 62a3eb3..c974129 100644
1032--- a/antispam-plugin.h
1033+++ b/antispam-plugin.h
1034@@ -280,6 +280,27 @@ o_stream_create_from_fd(int fd, pool_t pool ATTR_UNUSED)
1035 {
1036 return o_stream_create_fd(fd, 0, TRUE);
1037 }
1038+#elif DOVECOT_IS_EQ(2, 3)
1039+#define mempool_unref pool_unref
1040+#define module_arg struct module *
1041+#define ME(err) MAIL_ERROR_ ##err,
1042+
1043+static inline const char *const *
1044+get_mail_headers(struct mail *mail, const char *hdr)
1045+{
1046+ const char *const *ret;
1047+ if (mail_get_headers(mail, hdr, &ret) < 0)
1048+ return NULL;
1049+ return ret;
1050+}
1051+
1052+static inline struct ostream *
1053+o_stream_create_from_fd(int fd, pool_t pool ATTR_UNUSED)
1054+{
1055+ return o_stream_create_fd_autoclose(&fd, 0);
1056+}
1057+
1058+#define t_malloc t_malloc0
1059 #else
1060 #error "Building against this dovecot version is not supported"
1061 #endif
1062diff --git a/antispam-storage-2.0.c b/antispam-storage-2.0.c
1063index 3298908..ce522b1 100644
1064--- a/antispam-storage-2.0.c
1065+++ b/antispam-storage-2.0.c
1066@@ -379,14 +379,22 @@ antispam_mail_update_keywords(struct mail *mail,
1067
1068 static struct mailbox_transaction_context *
1069 antispam_mailbox_transaction_begin(struct mailbox *box,
1070- enum mailbox_transaction_flags flags)
1071+ enum mailbox_transaction_flags flags
1072+#if DOVECOT_IS_GE(2, 3)
1073+ , const char *reason
1074+#endif
1075+ )
1076 {
1077 struct antispam_mailbox *asbox = ANTISPAM_CONTEXT(box);
1078 struct mailbox_transaction_context *t;
1079 struct antispam_transaction_context *ast;
1080 struct antispam_internal_context *aic;
1081
1082- t = asbox->module_ctx.super.transaction_begin(box, flags);
1083+ t = asbox->module_ctx.super.transaction_begin(box, flags
1084+#if DOVECOT_IS_GE(2, 3)
1085+ , reason
1086+#endif
1087+ );
1088 aic = i_new(struct antispam_internal_context, 1);
1089 ast = antispam_transaction_begin(box);
1090 aic->backendctx = ast;
1091diff --git a/dovecot-version.c b/dovecot-version.c
1092index fe9bc73..d4744f0 100644
1093--- a/dovecot-version.c
1094+++ b/dovecot-version.c
1095@@ -68,8 +68,8 @@ int main(int argc, char **argv)
1096 printf("#define DOVECOT_P_IS_LE(maj, min, patch) "
1097 "DOVECOT_VCODE_PATCH <= DOVECOT_VERSION_CODE(maj, min, patch)\n");
1098
1099- /* Use the antispam-storage-2.0.c for dovecot 2.1 and 2.2 as well */
1100- if (maj == 2 && min < 3)
1101+ /* Use the antispam-storage-2.0.c for dovecot 2.1 - 2.3 as well */
1102+ if (maj == 2 && min < 4)
1103 min = 0;
1104
1105 printf("#define ANTISPAM_STORAGE "
This page took 0.300204 seconds and 5 git commands to generate.