commit 2ac0fbe: [Minor] Core: Add milter actions concept
Vsevolod Stakhov
vsevolod at highsecure.ru
Sat Jan 26 17:14:03 UTC 2019
Author: Vsevolod Stakhov
Date: 2019-01-26 13:26:36 +0000
URL: https://github.com/rspamd/rspamd/commit/2ac0fbea2763ff9913c7924495c39869ddad924b
[Minor] Core: Add milter actions concept
---
src/libserver/cfg_file.h | 3 +++
src/libserver/cfg_utils.c | 29 ++++++++++++++++++++++++-----
2 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/src/libserver/cfg_file.h b/src/libserver/cfg_file.h
index 5c245a31b..8ecb84d26 100644
--- a/src/libserver/cfg_file.h
+++ b/src/libserver/cfg_file.h
@@ -270,6 +270,8 @@ enum rspamd_action_type {
METRIC_ACTION_NOACTION,
METRIC_ACTION_MAX,
METRIC_ACTION_CUSTOM = 999,
+ METRIC_ACTION_MILTER_DISCARD,
+ METRIC_ACTION_MILTER_QUARANTINE
};
enum rspamd_action_flags {
@@ -277,6 +279,7 @@ enum rspamd_action_flags {
RSPAMD_ACTION_NO_THRESHOLD = (1u << 0),
RSPAMD_ACTION_THRESHOLD_ONLY = (1u << 1),
RSPAMD_ACTION_HAM = (1u << 2),
+ RSPAMD_ACTION_MILTER = (1u << 3),
};
diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c
index a854f45ca..42e4bbc4a 100644
--- a/src/libserver/cfg_utils.c
+++ b/src/libserver/cfg_utils.c
@@ -1929,6 +1929,24 @@ rspamd_config_action_from_ucl (struct rspamd_config *cfg,
}
}
}
+
+ elt = ucl_object_lookup (obj, "milter");
+
+ if (elt) {
+ const gchar *milter_action = ucl_object_tostring (elt);
+
+ if (strcmp (milter_action, "discard") == 0) {
+ flags |= RSPAMD_ACTION_MILTER;
+ act->action_type = METRIC_ACTION_MILTER_DISCARD;
+ }
+ else if (strcmp (milter_action, "quarantine") == 0) {
+ flags |= RSPAMD_ACTION_MILTER;
+ act->action_type = METRIC_ACTION_MILTER_QUARANTINE;
+ }
+ else {
+ msg_warn_config ("unknown milter action: %s", milter_action);
+ }
+ }
}
else if (obj_type == UCL_FLOAT || obj_type == UCL_INT) {
threshold = ucl_object_todouble (obj);
@@ -1946,11 +1964,12 @@ rspamd_config_action_from_ucl (struct rspamd_config *cfg,
act->threshold = threshold;
act->flags = flags;
- if (rspamd_action_from_str (act->name, &std_act)) {
- act->action_type = std_act;
- }
- else {
- act->action_type = METRIC_ACTION_CUSTOM;
+ if (!(flags & RSPAMD_ACTION_MILTER)) {
+ if (rspamd_action_from_str (act->name, &std_act)) {
+ act->action_type = std_act;
+ } else {
+ act->action_type = METRIC_ACTION_CUSTOM;
+ }
}
return TRUE;
More information about the Commits
mailing list