1 diff -u b/dovecot-antispam-2.0+20120225/antispam-plugin.h c/dovecot-antispam-2.0+20120225/antispam-plugin.h
2 --- b/dovecot-antispam-2.0+20120225/antispam-plugin.h 2013-07-30 05:22:21.248730740 +0200
3 +++ c/dovecot-antispam-2.0+20120225/antispam-plugin.h 2013-08-05 05:50:13.430597556 +0200
12 enum antispam_debug_target {
17 + char **unlearn_spam_args;
18 + int unlearn_spam_args_num;
19 + char **unlearn_ham_args;
20 + int unlearn_ham_args_num;
21 const char *pipe_binary;// = "/usr/sbin/sendmail";
22 const char *tmpdir;// = "/tmp";
24 diff -u b/dovecot-antispam-2.0+20120225/antispam-storage-2.0.c c/dovecot-antispam-2.0+20120225/antispam-storage-2.0.c
25 --- b/dovecot-antispam-2.0+20120225/antispam-storage-2.0.c 2013-07-31 14:52:43.277922438 +0200
26 +++ c/dovecot-antispam-2.0+20120225/antispam-storage-2.0.c 2013-08-05 07:51:45.235555750 +0200
31 - debug(&amail->cfg->dbgcfg, "keyword list:\n");
32 + debug(&amail->cfg->dbgcfg, "keyword list: modify_type=%s\n"
33 + , modify_type == MODIFY_ADD ? "MODIFY_ADD"
34 + : modify_type == MODIFY_REPLACE ? "MODIFY_REPLACE"
35 + : modify_type == MODIFY_REMOVE ? "MODIFY_REMOVE"
38 for (i = 0; i < keywords->count; i++) {
39 unsigned int idx = keywords->idx[i];
43 if (keyword_is_spam(amail->cfg, keyword_names[idx]))
44 - spam_class = CLASS_NOTSPAM;
45 + spam_class = previous_spam_keyword ? CLASS_UNSPAM : CLASS_UNSURE;
46 if (keyword_is_ham(amail->cfg, keyword_names[idx]))
47 - spam_class = CLASS_SPAM;
48 + spam_class = previous_ham_keyword ? CLASS_UNNOTSPAM : CLASS_UNSURE;
55 - debug(&amail->cfg->dbgcfg, "spam_class=%d previous_spam_keyword=%d previous_ham_keyword=%d\n",
56 - spam_class, previous_spam_keyword, previous_ham_keyword);
57 + debug(&amail->cfg->dbgcfg, "spam_class=%s previous_spam_keyword=%d previous_ham_keyword=%d\n"
58 + , spam_class == CLASS_UNSURE ? "CLASS_UNSURE"
59 + : spam_class == CLASS_SPAM ? "CLASS_SPAM"
60 + : spam_class == CLASS_NOTSPAM ? "CLASS_NOTSPAM"
61 + : spam_class == CLASS_UNSPAM ? "CLASS_UNSPAM"
62 + : spam_class == CLASS_UNNOTSPAM ? "CLASS_UNNOTSPAM"
64 + , previous_spam_keyword, previous_ham_keyword);
66 amail->module_ctx.super.update_keywords(mail, modify_type, keywords);
68 - if (previous_spam_keyword && previous_ham_keyword) {
69 - /* NOTE: avoid to call the backend two times for the same change
70 - * once when adding one spam or ham keyword
71 - * and once when removing the other.
73 - debug(&amail->cfg->dbgcfg, "does not run backend a second time\n");
76 + //if (previous_spam_keyword && previous_ham_keyword) {
77 + // /* NOTE: avoid to call the backend two times for the same change
78 + // * once when adding one spam or ham keyword
79 + // * and once when removing the other.
81 + // debug(&amail->cfg->dbgcfg, "does not run backend a second time\n");
85 if (spam_class != CLASS_UNSURE) {
86 /* NOTE: on error, backend uses mail_storage_set_error()
87 Les sous-répertoires b/dovecot-antispam-2.0+20120225/debian et c/dovecot-antispam-2.0+20120225/debian sont identiques
88 Les sous-répertoires b/dovecot-antispam-2.0+20120225/.pc et c/dovecot-antispam-2.0+20120225/.pc sont identiques
89 diff -u b/dovecot-antispam-2.0+20120225/pipe.c c/dovecot-antispam-2.0+20120225/pipe.c
90 --- b/dovecot-antispam-2.0+20120225/pipe.c 2013-07-31 14:16:12.164255967 +0200
91 +++ c/dovecot-antispam-2.0+20120225/pipe.c 2013-08-05 06:12:36.137800536 +0200
95 dest = cfg->pipe.ham_args;
96 - dest_num = cfg->pipe.spam_args_num;
97 + dest_num = cfg->pipe.ham_args_num;
100 + dest = cfg->pipe.unlearn_spam_args;
101 + dest_num = cfg->pipe.unlearn_spam_args_num;
103 + case CLASS_UNNOTSPAM:
104 + dest = cfg->pipe.unlearn_ham_args;
105 + dest_num = cfg->pipe.unlearn_ham_args_num;
113 + debug(&cfg->dbgcfg, "running mailtrain backend program %s", cfg->pipe.pipe_binary);
120 - debug(&cfg->dbgcfg, "running mailtrain backend program %s", cfg->pipe.pipe_binary);
123 if (waitpid(pid, &status, 0) == -1)
129 - if (!cfg->pipe.ham_args || !cfg->pipe.spam_args) {
130 + if (!cfg->pipe.ham_args || !cfg->pipe.spam_args || !cfg->pipe.unlearn_ham_args || !cfg->pipe.unlearn_spam_args) {
131 mail_storage_set_error(t->box->storage,
133 "antispam plugin not configured");
139 + tmp = getenv("PIPE_PROGRAM_UNLEARN_SPAM_ARGS", getenv_data);
141 + cfg->pipe.unlearn_spam_args = p_strsplit(cfg->mem_pool, tmp, ";");
142 + cfg->pipe.unlearn_spam_args_num = str_array_length(
143 + (const char *const *)cfg->pipe.unlearn_spam_args);
144 + for (i = 0; i < cfg->pipe.unlearn_spam_args_num; i++)
145 + debug(&cfg->dbgcfg, "pipe backend unlearn spam arg[%d] = %s\n",
146 + i, cfg->pipe.unlearn_spam_args[i]);
148 + tmp = getenv("PIPE_PROGRAM_UNLEARN_SPAM_ARG", getenv_data);
150 + tmp = getenv("MAIL_UNLEARN_SPAM", getenv_data);
152 + /* bit of a hack */
153 + cfg->pipe.unlearn_spam_args =
154 + p_strsplit(cfg->mem_pool, tmp, "\x01");
155 + cfg->pipe.unlearn_spam_args_num = 1;
156 + debug(&cfg->dbgcfg,
157 + "pipe backend unlearn spam argument = %s\n", tmp);
162 + tmp = getenv("PIPE_PROGRAM_UNLEARN_NOTSPAM_ARGS", getenv_data);
164 + cfg->pipe.unlearn_ham_args = p_strsplit(cfg->mem_pool, tmp, ";");
165 + cfg->pipe.unlearn_ham_args_num = str_array_length(
166 + (const char *const *)cfg->pipe.unlearn_ham_args);
167 + for (i = 0; i < cfg->pipe.unlearn_ham_args_num; i++)
168 + debug(&cfg->dbgcfg, "pipe backend unlearn not-spam arg[%d] = %s\n",
169 + i, cfg->pipe.unlearn_ham_args[i]);
171 + tmp = getenv("PIPE_PROGRAM_UNLEARN_NOTSPAM_ARG", getenv_data);
173 + tmp = getenv("MAIL_UNLEARN_NOTSPAM", getenv_data);
175 + /* bit of a hack */
176 + cfg->pipe.unlearn_ham_args =
177 + p_strsplit(cfg->mem_pool, tmp, "\x01");
178 + cfg->pipe.unlearn_ham_args_num = 1;
179 + debug(&cfg->dbgcfg,
180 + "pipe backend unlearn not-spam argument = %s\n", tmp);
185 tmp = getenv("PIPE_PROGRAM", getenv_data);