aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-08-25 19:55:35 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-08-25 19:56:03 +0100
commitd0f96a765d87dd6fcd24c3448e311aac257b67ff (patch)
tree1654983f5681fcc7dc5bbf3270d0cf4eb94808aa /src/libserver
parentc13a5cbb44578df5a5387633ce058bfb417425ff (diff)
downloadrspamd-d0f96a765d87dd6fcd24c3448e311aac257b67ff.tar.gz
rspamd-d0f96a765d87dd6fcd24c3448e311aac257b67ff.zip
[Feature] Add some sanity checks for actions and controller
Diffstat (limited to 'src/libserver')
-rw-r--r--src/libserver/cfg_utils.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c
index 7e410559f..721419c4b 100644
--- a/src/libserver/cfg_utils.c
+++ b/src/libserver/cfg_utils.c
@@ -768,6 +768,51 @@ rspamd_config_post_load (struct rspamd_config *cfg,
/* Validate cache */
if (opts & RSPAMD_CONFIG_INIT_VALIDATE) {
+ /* Check for actions sanity */
+ int i, prev_act = 0;
+ struct rspamd_metric *metric = cfg->default_metric;
+ gdouble prev_score = NAN;
+ gboolean seen_controller = FALSE;
+ GList *cur;
+ struct rspamd_worker_conf *wcf;
+
+ for (i = METRIC_ACTION_REJECT; i < METRIC_ACTION_MAX; i ++) {
+ if (!isnan (prev_score) && !isnan (metric->actions[i].score)) {
+ if (prev_score <= isnan (metric->actions[i].score)) {
+ msg_warn_config ("incorrect metrics scores: action %s"
+ " has lower score: %.2f than action %s: %.2f",
+ rspamd_action_to_str (prev_act), prev_score,
+ rspamd_action_to_str (i), metric->actions[i].score);
+ ret = FALSE;
+ }
+ }
+
+ if (!isnan (metric->actions[i].score)) {
+ prev_score = metric->actions[i].score;
+ prev_act = i;
+ }
+ }
+
+ cur = cfg->workers;
+ while (cur) {
+ wcf = cur->data;
+
+ if (wcf->type == g_quark_from_static_string ("controller")) {
+ seen_controller = TRUE;
+ break;
+ }
+
+ cur = g_list_next (cur);
+ }
+
+ if (!seen_controller) {
+ msg_warn_config ("controller worker is unconfigured: learning,"
+ " periodic scripts, maps watching and many other"
+ " Rspamd features will be broken");
+
+ ret = FALSE;
+ }
+
return rspamd_symbols_cache_validate (cfg->cache, cfg, FALSE) && ret;
}