diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-02-18 15:42:43 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-02-18 15:42:43 +0000 |
commit | 8920c4d8faf24ab5eff34f389d01da7635514fb0 (patch) | |
tree | 9890a600debe14de4cf59ce531a8d6dd5690f76b /src/libserver/cfg_rcl.c | |
parent | 96ae0fe1867bc3c9ba5ea752bd93bd1b3632fa79 (diff) | |
download | rspamd-8920c4d8faf24ab5eff34f389d01da7635514fb0.tar.gz rspamd-8920c4d8faf24ab5eff34f389d01da7635514fb0.zip |
[Fix] Rework groups scores definitions
Diffstat (limited to 'src/libserver/cfg_rcl.c')
-rw-r--r-- | src/libserver/cfg_rcl.c | 61 |
1 files changed, 47 insertions, 14 deletions
diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c index 21a89c06e..59656392d 100644 --- a/src/libserver/cfg_rcl.c +++ b/src/libserver/cfg_rcl.c @@ -326,7 +326,7 @@ rspamd_rcl_group_handler (rspamd_mempool_t *pool, const ucl_object_t *obj, { struct rspamd_config *cfg = ud; struct rspamd_symbols_group *gr; - const ucl_object_t *val; + const ucl_object_t *val, *elt; struct rspamd_rcl_section *subsection; struct rspamd_rcl_symbol_data sd; @@ -343,6 +343,51 @@ rspamd_rcl_group_handler (rspamd_mempool_t *pool, const ucl_object_t *obj, return FALSE; } + if ((elt = ucl_object_lookup (obj, "one_shot")) != NULL) { + if (ucl_object_type (elt) != UCL_BOOLEAN) { + g_set_error (err, + CFG_RCL_ERROR, + EINVAL, + "one_shot attribute is not boolean for symbol: '%s'", + key); + + return FALSE; + } + if (ucl_object_toboolean (elt)) { + gr->flags |= RSPAMD_SYMBOL_GROUP_ONE_SHOT; + } + } + + if ((elt = ucl_object_lookup (obj, "disabled")) != NULL) { + if (ucl_object_type (elt) != UCL_BOOLEAN) { + g_set_error (err, + CFG_RCL_ERROR, + EINVAL, + "disabled attribute is not boolean for symbol: '%s'", + key); + + return FALSE; + } + if (ucl_object_toboolean (elt)) { + gr->flags |= RSPAMD_SYMBOL_GROUP_DISABLED; + } + } + + if ((elt = ucl_object_lookup (obj, "enabled")) != NULL) { + if (ucl_object_type (elt) != UCL_BOOLEAN) { + g_set_error (err, + CFG_RCL_ERROR, + EINVAL, + "enabled attribute is not boolean for symbol: '%s'", + key); + + return FALSE; + } + if (!ucl_object_toboolean (elt)) { + gr->flags |= RSPAMD_SYMBOL_GROUP_DISABLED; + } + } + sd.gr = gr; sd.cfg = cfg; @@ -1316,7 +1361,7 @@ rspamd_rcl_composite_handler (rspamd_mempool_t *pool, rspamd_config_add_symbol (cfg, composite_name, score, description, group, 0, - ucl_object_get_priority (obj) + 1, + ucl_object_get_priority (obj), /* No +1 as it is default... */ 1); elt = ucl_object_lookup (obj, "groups"); @@ -2194,18 +2239,6 @@ rspamd_rcl_config_init (struct rspamd_config *cfg, GHashTable *skip_sections) /* Group part */ rspamd_rcl_add_default_handler (sub, - "disabled", - rspamd_rcl_parse_struct_boolean, - G_STRUCT_OFFSET (struct rspamd_symbols_group, disabled), - 0, - "Disable symbols group"); - rspamd_rcl_add_default_handler (sub, - "enabled", - rspamd_rcl_parse_struct_boolean, - G_STRUCT_OFFSET (struct rspamd_symbols_group, disabled), - RSPAMD_CL_FLAG_BOOLEAN_INVERSE, - "Enable or disable symbols group"); - rspamd_rcl_add_default_handler (sub, "max_score", rspamd_rcl_parse_struct_double, G_STRUCT_OFFSET (struct rspamd_symbols_group, max_score), |