gchar *spam_header;
void *sessions_cache;
gboolean discard_on_reject;
+ gboolean quarantine_on_reject;
};
static struct rspamd_milter_context *milter_ctx = NULL;
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 */
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;
}
}
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);
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);
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 *
RSPAMD_MILTER_TEMPFAIL = 't',
RSPAMD_MILTER_REPLYCODE = 'y',
RSPAMD_MILTER_OPTNEG = 'O',
- RSPAMD_MILTER_PROGRESS = 'p'
+ RSPAMD_MILTER_PROGRESS = 'p',
+ RSPAMD_MILTER_QUARANTINE = 'q',
};
struct rspamd_email_address;
* @param spam_header spam header name (must NOT be NULL)
*/
void rspamd_milter_init_library (const gchar *spam_header,
- void *sessions_cache, gboolean discard_on_reject);
+ void *sessions_cache, gboolean discard_on_reject,
+ gboolean quarantine_on_reject);
/**
* Returns pool for a session
enum rspamd_milter_io_state state;
int fd;
gboolean discard_on_reject;
+ gboolean quarantine_on_reject;
gboolean no_action;
};
#define RSPAMD_MILTER_FLAG_ADDRCPT (1L<<2) /* filter may add recipients */
#define RSPAMD_MILTER_FLAG_DELRCPT (1L<<3) /* filter may delete recipients */
#define RSPAMD_MILTER_FLAG_CHGHDRS (1L<<4) /* filter may change/delete headers */
+#define RSPAMD_MILTER_FLAG_QUARANTINE (1L<<5) /* filter may request quarantine */
#define RSPAMD_MILTER_ACTIONS_MASK \
(RSPAMD_MILTER_FLAG_ADDHDRS | RSPAMD_MILTER_FLAG_ADDRCPT | \
- RSPAMD_MILTER_FLAG_DELRCPT | RSPAMD_MILTER_FLAG_CHGHDRS)
+ RSPAMD_MILTER_FLAG_DELRCPT | RSPAMD_MILTER_FLAG_CHGHDRS | \
+ RSPAMD_MILTER_FLAG_QUARANTINE)
enum rspamd_milter_connect_proto {
RSPAMD_MILTER_CONN_UNKNOWN = 'U',
gboolean milter;
/* Discard messages instead of rejecting them */
gboolean discard_on_reject;
+ /* Quarantine messages instead of rejecting them */
+ gboolean quarantine_on_reject;
/* Milter spam header */
gchar *spam_header;
/* Sessions cache */
G_STRUCT_OFFSET (struct rspamd_proxy_ctx, discard_on_reject),
0,
"Tell MTA to discard rejected messages silently");
+ rspamd_rcl_register_worker_option (cfg,
+ type,
+ "quarantine_on_reject",
+ rspamd_rcl_parse_struct_boolean,
+ ctx,
+ G_STRUCT_OFFSET (struct rspamd_proxy_ctx, quarantine_on_reject),
+ 0,
+ "Tell MTA to quarantine rejected messages");
rspamd_rcl_register_worker_option (cfg,
type,
"spam_header",
}
rspamd_milter_init_library (ctx->spam_header, ctx->sessions_cache,
- ctx->discard_on_reject);
+ ctx->discard_on_reject, ctx->quarantine_on_reject);
rspamd_lua_run_postloads (ctx->cfg->lua_state, ctx->cfg, ctx->ev_base,
worker);