aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2008-04-26 20:26:39 +0200
committerJohannes Berg <johannes@sipsolutions.net>2008-04-26 20:26:39 +0200
commitfd7d4c8a31604c9888aed9bc47b1218a7e4495f8 (patch)
tree10a9cee72b973a1e5e3ac63703db4f31f39054cc
parentba068756b782e55251bd58ac67f0a9700f745fbe (diff)
downloaddovecot-antispam-fd7d4c8a31604c9888aed9bc47b1218a7e4495f8.tar.gz
dovecot-antispam-fd7d4c8a31604c9888aed9bc47b1218a7e4495f8.tar.xz
dovecot-antispam-fd7d4c8a31604c9888aed9bc47b1218a7e4495f8.zip
backend preparations for 1.1
-rw-r--r--antispam-plugin.h7
-rw-r--r--crm114-exec.c1
-rw-r--r--dspam-exec.c1
-rw-r--r--mailtrain.c19
-rw-r--r--signature.c12
5 files changed, 40 insertions, 0 deletions
diff --git a/antispam-plugin.h b/antispam-plugin.h
index f614894..dba8ed0 100644
--- a/antispam-plugin.h
+++ b/antispam-plugin.h
@@ -73,5 +73,12 @@ bool keyword_is_spam(const char *keyword);
extern bool need_keyword_hook;
extern bool need_folder_hook;
+
+#ifdef CONFIG_DOVECOT_11
+#define __attr_unused__ ATTR_UNUSED
+#define ME(err) MAIL_ERROR_ ##err,
+#else
+#define ME(err)
+#endif
#endif /* _ANTISPAM_PLUGIN_H */
diff --git a/crm114-exec.c b/crm114-exec.c
index 295c52a..88b14c4 100644
--- a/crm114-exec.c
+++ b/crm114-exec.c
@@ -154,6 +154,7 @@ int backend_commit(struct mailbox_transaction_context *ctx,
if (call_reaver(item->sig, item->wanted)) {
ret = -1;
mail_storage_set_error(ctx->box->storage,
+ ME(NOTPOSSIBLE)
"Failed to call reaver");
break;
}
diff --git a/dspam-exec.c b/dspam-exec.c
index 7396d0e..fffb61b 100644
--- a/dspam-exec.c
+++ b/dspam-exec.c
@@ -180,6 +180,7 @@ int backend_commit(struct mailbox_transaction_context *ctx,
if (call_dspam(item->sig, item->wanted)) {
ret = -1;
mail_storage_set_error(ctx->box->storage,
+ ME(NOTPOSSIBLE)
"Failed to call dspam");
break;
}
diff --git a/mailtrain.c b/mailtrain.c
index 75c0fc8..a0e4a40 100644
--- a/mailtrain.c
+++ b/mailtrain.c
@@ -143,6 +143,7 @@ static int process_tmpdir(struct mailbox_transaction_context *ctx,
if ((rc = run_sendmail(fd, wanted))) {
mail_storage_set_error(ctx->box->storage,
+ ME(TEMP)
"failed to send mail");
debug("run program failed with exit code %d\n", rc);
rc = -1;
@@ -220,19 +221,27 @@ int backend_handle_mail(struct mailbox_transaction_context *t,
if (!ast->tmpdir) {
mail_storage_set_error(t->box->storage,
+ ME(NOTPOSSIBLE)
"Failed to initialise temporary dir");
return -1;
}
if (!hamaddr || !spamaddr) {
mail_storage_set_error(t->box->storage,
+ ME(NOTPOSSIBLE)
"antispam plugin not configured");
return -1;
}
+#ifdef CONFIG_DOVECOT_11
+ if (mail_get_stream(mail, NULL, NULL, &mailstream) < 0)
+ mailstream = NULL;
+#else
mailstream = mail_get_stream(mail, NULL, NULL);
+#endif
if (!mailstream) {
mail_storage_set_error(t->box->storage,
+ ME(EXPUNGED)
"Failed to get mail contents");
return -1;
}
@@ -245,6 +254,7 @@ int backend_handle_mail(struct mailbox_transaction_context *t,
fd = creat(buf, 0600);
if (fd < 0) {
mail_storage_set_error(t->box->storage,
+ ME(NOTPOSSIBLE)
"Failed to create temporary file");
ret = -1;
goto out;
@@ -252,10 +262,15 @@ int backend_handle_mail(struct mailbox_transaction_context *t,
ast->count++;
+#ifdef CONFIG_DOVECOT_11
+ outstream = o_stream_create_fd(fd, 0, TRUE);
+#else
outstream = o_stream_create_file(fd, t->box->pool, 0, TRUE);
+#endif
if (!outstream) {
ret = -1;
mail_storage_set_error(t->box->storage,
+ ME(NOTPOSSIBLE)
"Failed to stream temporary file");
goto out_close;
}
@@ -264,6 +279,7 @@ int backend_handle_mail(struct mailbox_transaction_context *t,
!= sizeof(wanted)) {
ret = -1;
mail_storage_set_error(t->box->storage,
+ ME(NOTPOSSIBLE)
"Failed to write marker to temp file");
goto failed_to_copy;
}
@@ -272,6 +288,7 @@ int backend_handle_mail(struct mailbox_transaction_context *t,
size < 5) {
ret = -1;
mail_storage_set_error(t->box->storage,
+ ME(NOTPOSSIBLE)
"Failed to read mail beginning");
goto failed_to_copy;
}
@@ -283,6 +300,7 @@ int backend_handle_mail(struct mailbox_transaction_context *t,
if (o_stream_send_str(outstream, "From ") < 0) {
ret = -1;
mail_storage_set_error(t->box->storage,
+ ME(NOTPOSSIBLE)
"Failed to write line to temp");
goto failed_to_copy;
}
@@ -291,6 +309,7 @@ int backend_handle_mail(struct mailbox_transaction_context *t,
if (o_stream_send_istream(outstream, mailstream) < 0) {
ret = -1;
mail_storage_set_error(t->box->storage,
+ ME(NOTPOSSIBLE)
"Failed to copy to temporary file");
goto failed_to_copy;
}
diff --git a/signature.c b/signature.c
index 8257586..bf257ea 100644
--- a/signature.c
+++ b/signature.c
@@ -21,9 +21,15 @@ int signature_extract_to_list(struct mailbox_transaction_context *t,
const char *const *signatures;
struct siglist *item;
+#ifdef CONFIG_DOVECOT_11
+ if (mail_get_headers(mail, signature_hdr, &signatures) < 0)
+ signatures = NULL;
+#else
signatures = mail_get_headers(mail, signature_hdr);
+#endif
if (!signatures || !signatures[0]) {
mail_storage_set_error(t->box->storage,
+ ME(NOTPOSSIBLE)
"antispam signature not found");
return -1;
}
@@ -46,9 +52,15 @@ const char *signature_extract(struct mailbox_transaction_context *t,
{
const char *const *signatures;
+#ifdef CONFIG_DOVECOT_11
+ if (mail_get_headers(mail, signature_hdr, &signatures) < 0)
+ signatures = NULL;
+#else
signatures = mail_get_headers(mail, signature_hdr);
+#endif
if (!signatures || !signatures[0]) {
mail_storage_set_error(t->box->storage,
+ ME(NOTPOSSIBLE)
"antispam signature not found");
return NULL;
}