aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFredrik Lindberg <fli@shapeshifter.se>2008-12-10 22:17:41 +0100
committerJohannes Berg <johannes@sipsolutions.net>2008-12-10 22:17:41 +0100
commit28075fabec0dad462804ffe274b4eb2524c8d405 (patch)
treea771f284d4e9882a95515835d800e121f4804d77
parent3da16a1c2e0ed17fc0ca9968ca8b978ce28d51c8 (diff)
downloaddovecot-antispam-28075fabec0dad462804ffe274b4eb2524c8d405.tar.gz
dovecot-antispam-28075fabec0dad462804ffe274b4eb2524c8d405.tar.xz
dovecot-antispam-28075fabec0dad462804ffe274b4eb2524c8d405.zip
dspam backend: allow configuring ignoring virus emails
The following new options needs to be added to the configuration for anything to happen. antispam_dspam_result_header = X-DSPAM-Result antispam_dspam_result_blacklist = Virus result_blacklist is a semicolon separated list of "blacklisted" classifications and mails with the header X-DSPAM-Result set to any of the strings (case insensitive) are ignored during move. I've tested it and it seems to work as expected.
-rw-r--r--antispam.77
-rw-r--r--dspam-exec.c35
2 files changed, 42 insertions, 0 deletions
diff --git a/antispam.7 b/antispam.7
index f47571a..efec9cd 100644
--- a/antispam.7
+++ b/antispam.7
@@ -146,6 +146,13 @@ plugin {
# antispam_dspam_args = --deliver=;--user;%u # % expansion done by dovecot
# antispam_dspam_args = --mode=teft
+ # Ignore mails where the DSPAM result header contains any of the
+ # strings listed in the blacklist
+ # (default unset i.e. none)
+ # antispam_dspam_result_header = X-DSPAM-Result
+ # semicolon-separated list of blacklisted results, case insensitive
+ # antispam_dspam_result_blacklist = Virus
+
#=====================
# mail sending plugin
#
diff --git a/dspam-exec.c b/dspam-exec.c
index bbb8338..3c52271 100644
--- a/dspam-exec.c
+++ b/dspam-exec.c
@@ -30,6 +30,9 @@
#include "signature.h"
static const char *dspam_binary = "/usr/bin/dspam";
+static const char *dspam_result_header = NULL;
+static char **dspam_result_bl = NULL;
+static int dspam_result_bl_num = 0;
static char **extra_args = NULL;
static int extra_args_num = 0;
@@ -201,6 +204,22 @@ int backend_handle_mail(struct mailbox_transaction_context *t,
struct antispam_transaction_context *ast,
struct mail *mail, enum classification want)
{
+ const char *const *result = NULL;
+ int i;
+
+ /*
+ * Check for whitelisted classifications that should
+ * be ignored when moving a mail. eg. virus.
+ */
+ if (dspam_result_header)
+ result = get_mail_headers(mail, dspam_result_header);
+ if (result && result[0]) {
+ for (i = 0; i < dspam_result_bl_num; i++) {
+ if (strcasecmp(result[0], dspam_result_bl[i]) == 0)
+ return 0;
+ }
+ }
+
return signature_extract_to_list(t, mail, &ast->siglist, want);
}
@@ -214,6 +233,22 @@ void backend_init(pool_t pool)
dspam_binary = tmp;
debug("dspam binary set to %s\n", dspam_binary);
+ tmp = get_setting("DSPAM_RESULT_HEADER");
+ if (tmp) {
+ dspam_result_header = tmp;
+ debug("dspam result set to %s\n", dspam_result_header);
+
+ tmp = get_setting("DSPAM_RESULT_BLACKLIST");
+ if (tmp) {
+ dspam_result_bl = p_strsplit(pool, tmp, ";");
+ dspam_result_bl_num = str_array_length(
+ (const char *const *)dspam_result_bl);
+ for (i = 0; i < dspam_result_bl_num; i++)
+ debug("dspam result blacklist %s\n",
+ dspam_result_bl[i]);
+ }
+ }
+
tmp = get_setting("DSPAM_ARGS");
if (tmp) {
extra_args = p_strsplit(pool, tmp, ";");