From: Vsevolod Stakhov Date: Sat, 26 Jan 2019 17:11:55 +0000 (+0000) Subject: [Minor] Core: Use quarantine/dicard as semi-standard actions X-Git-Tag: 1.9.0~248 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=f97078913a7a45adc1f1640d31e032ff7f232e48;p=rspamd.git [Minor] Core: Use quarantine/dicard as semi-standard actions --- diff --git a/src/libserver/cfg_file.h b/src/libserver/cfg_file.h index 8ecb84d26..c7475c327 100644 --- a/src/libserver/cfg_file.h +++ b/src/libserver/cfg_file.h @@ -270,8 +270,8 @@ enum rspamd_action_type { METRIC_ACTION_NOACTION, METRIC_ACTION_MAX, METRIC_ACTION_CUSTOM = 999, - METRIC_ACTION_MILTER_DISCARD, - METRIC_ACTION_MILTER_QUARANTINE + METRIC_ACTION_DISCARD, + METRIC_ACTION_QUARANTINE }; enum rspamd_action_flags { diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c index 0d3f1e75a..d288c8e06 100644 --- a/src/libserver/cfg_utils.c +++ b/src/libserver/cfg_utils.c @@ -1937,11 +1937,11 @@ rspamd_config_action_from_ucl (struct rspamd_config *cfg, if (strcmp (milter_action, "discard") == 0) { flags |= RSPAMD_ACTION_MILTER; - act->action_type = METRIC_ACTION_MILTER_DISCARD; + act->action_type = METRIC_ACTION_DISCARD; } else if (strcmp (milter_action, "quarantine") == 0) { flags |= RSPAMD_ACTION_MILTER; - act->action_type = METRIC_ACTION_MILTER_QUARANTINE; + act->action_type = METRIC_ACTION_QUARANTINE; } else { msg_warn_config ("unknown milter action: %s", milter_action); @@ -2239,6 +2239,12 @@ rspamd_action_from_str (const gchar *data, gint *result) case 0x167C0DF4BAA9BCECULL: /* accept */ *result = METRIC_ACTION_NOACTION; break; + case 0x4E9666ECCD3FC314ULL: /* quarantine */ + *result = METRIC_ACTION_QUARANTINE; + break; + case 0x93B346242F7F69B3ULL: /* discard */ + *result = METRIC_ACTION_DISCARD; + break; default: return FALSE; } @@ -2266,9 +2272,9 @@ rspamd_action_to_str (enum rspamd_action_type action) return "invalid max action"; case METRIC_ACTION_CUSTOM: return "custom"; - case METRIC_ACTION_MILTER_DISCARD: + case METRIC_ACTION_DISCARD: return "discard"; - case METRIC_ACTION_MILTER_QUARANTINE: + case METRIC_ACTION_QUARANTINE: return "quarantine"; } @@ -2295,9 +2301,9 @@ rspamd_action_to_str_alt (enum rspamd_action_type action) return "invalid max action"; case METRIC_ACTION_CUSTOM: return "custom"; - case METRIC_ACTION_MILTER_DISCARD: + case METRIC_ACTION_DISCARD: return "discard"; - case METRIC_ACTION_MILTER_QUARANTINE: + case METRIC_ACTION_QUARANTINE: return "quarantine"; } diff --git a/src/libserver/milter.c b/src/libserver/milter.c index b871c2347..03aef8298 100644 --- a/src/libserver/milter.c +++ b/src/libserver/milter.c @@ -1947,7 +1947,7 @@ rspamd_milter_send_task_results (struct rspamd_milter_session *session, rspamd_milter_send_action (session, RSPAMD_MILTER_ACCEPT); break; - case METRIC_ACTION_MILTER_QUARANTINE: + case METRIC_ACTION_QUARANTINE: /* TODO: be more flexible about SMTP messages */ rspamd_milter_send_action (session, RSPAMD_MILTER_QUARANTINE, RSPAMD_MILTER_QUARANTINE_MESSAGE); @@ -1955,7 +1955,7 @@ rspamd_milter_send_task_results (struct rspamd_milter_session *session, /* Quarantine also requires accept action, all hail Sendmail */ rspamd_milter_send_action (session, RSPAMD_MILTER_ACCEPT); break; - case METRIC_ACTION_MILTER_DISCARD: + case METRIC_ACTION_DISCARD: rspamd_milter_send_action (session, RSPAMD_MILTER_DISCARD); break; case METRIC_ACTION_GREYLIST: diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c index d8c790e8f..574c5fa9f 100644 --- a/src/libserver/protocol.c +++ b/src/libserver/protocol.c @@ -970,11 +970,11 @@ rspamd_metric_result_ucl (struct rspamd_task *task, } if (action->flags & RSPAMD_ACTION_MILTER) { /* Treat milter action specially */ - if (action->action_type == METRIC_ACTION_MILTER_DISCARD) { + if (action->action_type == METRIC_ACTION_DISCARD) { ucl_object_insert_key (obj, ucl_object_fromstring ("discard"), "reject", 0, false); } - else if (action->action_type == METRIC_ACTION_MILTER_QUARANTINE) { + else if (action->action_type == METRIC_ACTION_QUARANTINE) { ucl_object_insert_key (obj, ucl_object_fromstring ("quarantine"), "reject", 0, false); }