diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-11-23 20:02:32 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-11-23 20:02:32 +0000 |
commit | 929a9746c963fba0b3c59f35a06f9100d0fac13a (patch) | |
tree | 4cf28274fd84578a8f3dda21972b289102990af5 /src/libserver/milter.c | |
parent | feb910e287c215d5a1b6a03856ad2a1cbd36a394 (diff) | |
download | rspamd-929a9746c963fba0b3c59f35a06f9100d0fac13a.tar.gz rspamd-929a9746c963fba0b3c59f35a06f9100d0fac13a.zip |
[Feature] Allow to quarantine rejected messages using milter interface
Diffstat (limited to 'src/libserver/milter.c')
-rw-r--r-- | src/libserver/milter.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/libserver/milter.c b/src/libserver/milter.c index f2ced4f0f..7874a9dbc 100644 --- a/src/libserver/milter.c +++ b/src/libserver/milter.c @@ -50,6 +50,7 @@ struct rspamd_milter_context { gchar *spam_header; void *sessions_cache; gboolean discard_on_reject; + gboolean quarantine_on_reject; }; static struct rspamd_milter_context *milter_ctx = NULL; @@ -1072,6 +1073,7 @@ rspamd_milter_handle_socket (gint fd, const struct timeval *tv, priv->state = RSPAMD_MILTER_READ_MORE; priv->pool = rspamd_mempool_new (rspamd_mempool_suggest_size (), "milter"); priv->discard_on_reject = milter_ctx->discard_on_reject; + priv->quarantine_on_reject = milter_ctx->quarantine_on_reject; if (pool) { /* Copy tag */ @@ -1567,8 +1569,13 @@ rspamd_milter_process_milter_block (struct rspamd_milter_session *session, priv->discard_on_reject = TRUE; msg_info_milter ("discard message instead of rejection"); } + else if (strcmp (ucl_object_tostring (elt), "quarantine") == 0) { + priv->quarantine_on_reject = TRUE; + msg_info_milter ("quarantine message instead of rejection"); + } else { priv->discard_on_reject = FALSE; + priv->quarantine_on_reject = FALSE; } } @@ -1713,6 +1720,10 @@ rspamd_milter_send_task_results (struct rspamd_milter_session *session, if (priv->discard_on_reject) { 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); + } else { rcode = rspamd_fstring_new_init (RSPAMD_MILTER_RCODE_REJECT, sizeof (RSPAMD_MILTER_RCODE_REJECT) - 1); @@ -1789,7 +1800,7 @@ cleanup: void rspamd_milter_init_library (const gchar *spam_header, void *sessions_cache, - gboolean discard_on_reject) + gboolean discard_on_reject, gboolean quarantine_on_reject) { if (milter_ctx) { g_free (milter_ctx->spam_header); @@ -1807,6 +1818,7 @@ rspamd_milter_init_library (const gchar *spam_header, void *sessions_cache, milter_ctx->sessions_cache = sessions_cache; milter_ctx->discard_on_reject = discard_on_reject; + milter_ctx->quarantine_on_reject = quarantine_on_reject; } rspamd_mempool_t * |