aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-01-14 17:25:56 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-01-14 17:25:56 +0000
commit9546576a9e449ac0d57246679af8b00d940af55b (patch)
tree5822f2d6c6c604ba48ebac04173be245f8815c2c /src/libserver
parentaa07f4bc9eff2a252743e20faa334f2aa7d589d5 (diff)
downloadrspamd-9546576a9e449ac0d57246679af8b00d940af55b.tar.gz
rspamd-9546576a9e449ac0d57246679af8b00d940af55b.zip
[Minor] Fix some issues
Diffstat (limited to 'src/libserver')
-rw-r--r--src/libserver/cfg_utils.c28
-rw-r--r--src/libserver/dns.c1
2 files changed, 23 insertions, 6 deletions
diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c
index 26bf4e4b0..d4b4e9075 100644
--- a/src/libserver/cfg_utils.c
+++ b/src/libserver/cfg_utils.c
@@ -153,7 +153,8 @@ rspamd_config_new (enum rspamd_config_init_flags flags)
action->flags |= RSPAMD_ACTION_HAM;
}
- HASH_ADD_STR (cfg->actions, name, action);
+ HASH_ADD_KEYPTR (hh, cfg->actions,
+ action->name, strlen (action->name), action);
}
/* Disable timeout */
@@ -1952,8 +1953,6 @@ rspamd_config_action_from_ucl (struct rspamd_config *cfg,
act->action_type = METRIC_ACTION_CUSTOM;
}
- rspamd_actions_sort (cfg);
-
return TRUE;
}
@@ -1963,6 +1962,7 @@ rspamd_config_set_action_score (struct rspamd_config *cfg,
const ucl_object_t *obj)
{
struct rspamd_action *act;
+ enum rspamd_action_type std_act;
const ucl_object_t *elt;
guint priority = ucl_object_get_priority (obj), obj_type;
@@ -1979,6 +1979,17 @@ rspamd_config_set_action_score (struct rspamd_config *cfg,
}
}
+ /* Here are dragons:
+ * We have `canonical` name for actions, such as `soft reject` and
+ * configuration names for actions (used to be more convenient), such
+ * as `soft_reject`. Unfortunately, we must have heuristic for this
+ * variance of names.
+ */
+
+ if (rspamd_action_from_str (action_name, (gint *)&std_act)) {
+ action_name = rspamd_action_to_str (std_act);
+ }
+
HASH_FIND_STR (cfg->actions, action_name, act);
if (act) {
@@ -1992,7 +2003,12 @@ rspamd_config_set_action_score (struct rspamd_config *cfg,
act->priority,
priority,
act->threshold);
- return rspamd_config_action_from_ucl (cfg, act, obj, priority);
+ if (rspamd_config_action_from_ucl (cfg, act, obj, priority)) {
+ rspamd_actions_sort (cfg);
+ }
+ else {
+ return FALSE;
+ }
}
else {
msg_info_config ("action %s has been already registered with "
@@ -2008,7 +2024,9 @@ rspamd_config_set_action_score (struct rspamd_config *cfg,
act->name = rspamd_mempool_strdup (cfg->cfg_pool, action_name);
if (rspamd_config_action_from_ucl (cfg, act, obj, priority)) {
- HASH_ADD_STR (cfg->actions, name, act);
+ HASH_ADD_KEYPTR (hh, cfg->actions,
+ act->name, strlen (act->name), act);
+ rspamd_actions_sort (cfg);
}
else {
return FALSE;
diff --git a/src/libserver/dns.c b/src/libserver/dns.c
index 17b84884a..7ad266c2f 100644
--- a/src/libserver/dns.c
+++ b/src/libserver/dns.c
@@ -20,7 +20,6 @@
#include "dns.h"
#include "rspamd.h"
#include "utlist.h"
-#include "uthash.h"
#include "rdns_event.h"
#include "unix-std.h"