aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2008-12-10 22:17:24 +0100
committerJohannes Berg <johannes@sipsolutions.net>2008-12-10 22:17:24 +0100
commit3da16a1c2e0ed17fc0ca9968ca8b978ce28d51c8 (patch)
tree1b0bd9d759faf1abf239a821be8c697d75775f50
parent03a1d105eaa49ab0717f048ab9e09d9ede1d287f (diff)
downloaddovecot-antispam-3da16a1c2e0ed17fc0ca9968ca8b978ce28d51c8.tar.gz
dovecot-antispam-3da16a1c2e0ed17fc0ca9968ca8b978ce28d51c8.tar.xz
dovecot-antispam-3da16a1c2e0ed17fc0ca9968ca8b978ce28d51c8.zip
add signature missing thing
-rw-r--r--antispam.77
-rw-r--r--signature-log.c7
-rw-r--r--signature.c44
-rw-r--r--signature.h4
4 files changed, 48 insertions, 14 deletions
diff --git a/antispam.7 b/antispam.7
index d07c1d0..f47571a 100644
--- a/antispam.7
+++ b/antispam.7
@@ -108,6 +108,13 @@ plugin {
# mail signature (used with any backend requiring a signature)
antispam_signature = X-DSPAM-Signature
+ # action to take on mails without signature
+ # (used with any backend requiring a signature)
+ # (we recommend only setting this to 'move' after verifying that the
+ # whole setup is working)
+ # antispam_signature_missing = move # move silently without training
+ antispam_signature_missing = error
+
# semicolon-separated list of Trash folders (default unset i.e. none)
# antispam_trash =
# antispam_trash = trash;Trash;Deleted Items
diff --git a/signature-log.c b/signature-log.c
index ab8cd6d..5b7b306 100644
--- a/signature-log.c
+++ b/signature-log.c
@@ -99,7 +99,12 @@ int backend_handle_mail(struct mailbox_transaction_context *t,
return -1;
}
- signature = signature_extract(t, mail);
+ ret = signature_extract(t, mail, &signature);
+ if (ret)
+ return ret;
+
+ if (!signature)
+ return 0;
switch (wanted) {
case CLASS_SPAM:
diff --git a/signature.c b/signature.c
index 7f9d83b..7ad29d6 100644
--- a/signature.c
+++ b/signature.c
@@ -5,6 +5,7 @@
#include "mail-storage-private.h"
const char *signature_hdr = "X-DSPAM-Signature";
+static int signature_nosig_ignore = 0;
void signature_init(void)
{
@@ -12,6 +13,16 @@ void signature_init(void)
if (tmp)
signature_hdr = tmp;
debug("signature header line is \"%s\"\n", signature_hdr);
+
+ tmp = get_setting("SIGNATURE_MISSING");
+ if (!tmp)
+ tmp = "error";
+ if (strcmp(tmp, "move") == 0) {
+ signature_nosig_ignore = 1;
+ debug("will silently move mails with missing signature\n");
+ } else if (strcmp(tmp, "error") != 0) {
+ debug("invalid signature_missing setting '%s', ignoring\n", tmp);
+ }
}
int signature_extract_to_list(struct mailbox_transaction_context *t,
@@ -23,10 +34,14 @@ int signature_extract_to_list(struct mailbox_transaction_context *t,
signatures = get_mail_headers(mail, signature_hdr);
if (!signatures || !signatures[0]) {
- mail_storage_set_error(t->box->storage,
- ME(NOTPOSSIBLE)
- "antispam signature not found");
- return -1;
+ if (!signature_nosig_ignore) {
+ mail_storage_set_error(t->box->storage,
+ ME(NOTPOSSIBLE)
+ "antispam signature not found");
+ return -1;
+ } else {
+ return 0;
+ }
}
while (signatures[1])
@@ -42,23 +57,30 @@ int signature_extract_to_list(struct mailbox_transaction_context *t,
return 0;
}
-const char *signature_extract(struct mailbox_transaction_context *t,
- struct mail *mail)
+int signature_extract(struct mailbox_transaction_context *t,
+ struct mail *mail, const char **signature)
{
const char *const *signatures;
signatures = get_mail_headers(mail, signature_hdr);
if (!signatures || !signatures[0]) {
- mail_storage_set_error(t->box->storage,
- ME(NOTPOSSIBLE)
- "antispam signature not found");
- return NULL;
+ if (!signature_nosig_ignore) {
+ mail_storage_set_error(t->box->storage,
+ ME(NOTPOSSIBLE)
+ "antispam signature not found");
+ return -1;
+ } else {
+ *signature = NULL;
+ return 0;
+ }
}
while (signatures[1])
signatures++;
- return signatures[0];
+ *signature = signatures[0];
+
+ return 0;
}
void signature_list_free(struct siglist **list)
diff --git a/signature.h b/signature.h
index e25d1b5..1384924 100644
--- a/signature.h
+++ b/signature.h
@@ -16,8 +16,8 @@ void signature_init(void);
int signature_extract_to_list(struct mailbox_transaction_context *t,
struct mail *mail, struct siglist **list,
enum classification wanted);
-const char *signature_extract(struct mailbox_transaction_context *t,
- struct mail *mail);
+int signature_extract(struct mailbox_transaction_context *t,
+ struct mail *mail, const char **signature);
void signature_list_free(struct siglist **list);
extern const char *signature_hdr;