aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2014-02-03 15:01:38 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2014-02-03 15:01:38 +0000
commitb03fccff7b4cfd4454a908c8e322e436d80a2293 (patch)
tree5284e4d90fcb404e5e5135ab974689640205d20a /src
parent1a5edd59f8c6a2c17b966737469dbf06e8b37804 (diff)
downloadrspamd-b03fccff7b4cfd4454a908c8e322e436d80a2293.tar.gz
rspamd-b03fccff7b4cfd4454a908c8e322e436d80a2293.zip
Fix classifiers config for repeated sections.
Diffstat (limited to 'src')
-rw-r--r--src/cfg_rcl.c36
1 files changed, 31 insertions, 5 deletions
diff --git a/src/cfg_rcl.c b/src/cfg_rcl.c
index 4eb270c3e..be60c335c 100644
--- a/src/cfg_rcl.c
+++ b/src/cfg_rcl.c
@@ -795,12 +795,36 @@ rspamd_rcl_classifier_handler (struct config_file *cfg, ucl_object_t *obj,
{
ucl_object_t *val, *cur;
ucl_object_iter_t it = NULL;
- const gchar *key;
- struct classifier_config *ccf;
+ const gchar *key, *type;
+ struct classifier_config *ccf, *found = NULL;
gboolean res = TRUE;
struct rspamd_rcl_section *stat_section;
+ GList *cur_cl;
+
+ val = ucl_object_find_key (obj, "type");
+ if (val == NULL || !ucl_object_tostring_safe (val, &type)) {
+ g_set_error (err, CFG_RCL_ERROR, EINVAL, "classifier should have type defined");
+ return FALSE;
+ }
+
+ cur_cl = cfg->classifiers;
+ while (cur_cl != NULL) {
+ ccf = cur_cl->data;
+ if (g_ascii_strcasecmp (ccf->classifier->name, type) == 0) {
+ found = ccf;
+ break;
+ }
+ cur_cl = g_list_next (cur_cl);
+ }
+
+ if (found == NULL) {
+ ccf = check_classifier_conf (cfg, NULL);
+ ccf->classifier = get_classifier (type);
+ }
+ else {
+ ccf = found;
+ }
- ccf = check_classifier_conf (cfg, NULL);
HASH_FIND_STR (section->subsections, "statfile", stat_section);
while ((val = ucl_iterate_object (obj, &it, true)) != NULL && res) {
@@ -815,7 +839,7 @@ rspamd_rcl_classifier_handler (struct config_file *cfg, ucl_object_t *obj,
}
}
else if (g_ascii_strcasecmp (key, "type") == 0 && val->type == UCL_STRING) {
- ccf->classifier = get_classifier (ucl_object_tostring (val));
+ continue;
}
else if (g_ascii_strcasecmp (key, "tokenizer") == 0 && val->type == UCL_STRING) {
ccf->tokenizer = get_tokenizer (ucl_object_tostring (val));
@@ -827,7 +851,9 @@ rspamd_rcl_classifier_handler (struct config_file *cfg, ucl_object_t *obj,
}
}
- cfg->classifiers = g_list_prepend (cfg->classifiers, ccf);
+ if (found == NULL) {
+ cfg->classifiers = g_list_prepend (cfg->classifiers, ccf);
+ }
return res;