From 15e9311ce1bfafdcfc520f7543053cddca4541f9 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Fri, 24 Nov 2017 19:08:25 +0000 Subject: [PATCH] [Minor] Use quarantine message --- src/libserver/milter.c | 18 ++++++++++++++++-- src/libserver/milter_internal.h | 1 + 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/libserver/milter.c b/src/libserver/milter.c index 7874a9dbc..c201e2ee9 100644 --- a/src/libserver/milter.c +++ b/src/libserver/milter.c @@ -1139,7 +1139,9 @@ rspamd_milter_send_action (struct rspamd_milter_session *session, va_list ap; guchar cmd, *pos; rspamd_fstring_t *reply = NULL; + gsize len; GString *name, *value; + const char *reason; struct rspamd_milter_outbuf *obuf; struct rspamd_milter_private *priv = session->priv; @@ -1156,6 +1158,17 @@ rspamd_milter_send_action (struct rspamd_milter_session *session, /* No additional arguments */ SET_COMMAND (cmd, 0, reply, pos); break; + case RSPAMD_MILTER_QUARANTINE: + reason = va_arg (ap, const char *); + + if (reason == NULL) { + reason = ""; + } + + len = strlen (reason); + SET_COMMAND (cmd, len + 1, reply, pos); + memcpy (pos, reason, len + 1); + break; case RSPAMD_MILTER_ADDHEADER: name = va_arg (ap, GString *); value = va_arg (ap, GString *); @@ -1721,8 +1734,9 @@ rspamd_milter_send_task_results (struct rspamd_milter_session *session, rspamd_milter_send_action (session, RSPAMD_MILTER_DISCARD); } else if (priv->quarantine_on_reject) { - /* TODO: need to add quarantine message */ - rspamd_milter_send_action (session, RSPAMD_MILTER_QUARANTINE); + /* TODO: be more flexible about SMTP messages */ + rspamd_milter_send_action (session, RSPAMD_MILTER_QUARANTINE, + RSPAMD_MILTER_QUARANTINE_MESSAGE); } else { rcode = rspamd_fstring_new_init (RSPAMD_MILTER_RCODE_REJECT, diff --git a/src/libserver/milter_internal.h b/src/libserver/milter_internal.h index 6473ed147..f44da9c93 100644 --- a/src/libserver/milter_internal.h +++ b/src/libserver/milter_internal.h @@ -153,6 +153,7 @@ enum rspamd_milter_connect_proto { #define RSPAMD_MILTER_XCODE_REJECT "5.7.1" #define RSPAMD_MILTER_XCODE_TEMPFAIL "4.7.1" #define RSPAMD_MILTER_REJECT_MESSAGE "Spam message rejected" +#define RSPAMD_MILTER_QUARANTINE_MESSAGE "Spam message quarantined" #define RSPAMD_MILTER_TEMPFAIL_MESSAGE "Try again later" #define RSPAMD_MILTER_SPAM_HEADER "X-Spam" #define RSPAMD_MILTER_DKIM_HEADER "DKIM-Signature" -- 2.39.5