]> source.dussan.org Git - rspamd.git/commitdiff
Warn about composites redefinition.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 29 Jan 2014 14:24:36 +0000 (14:24 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 29 Jan 2014 14:24:36 +0000 (14:24 +0000)
src/cfg_rcl.c

index aedee7ea344bac4d2645f63120b1f95dca32a29e..4eb270c3e60a441be64ef226ac324caa54d9c385 100644 (file)
@@ -841,6 +841,7 @@ rspamd_rcl_composite_handler (struct config_file *cfg, ucl_object_t *obj,
        struct expression *expr;
        struct rspamd_composite *composite;
        const gchar *composite_name, *composite_expression;
+       gboolean new = TRUE;
 
        val = ucl_object_find_key (obj, "name");
        if (val == NULL || !ucl_object_tostring_safe (val, &composite_name)) {
@@ -848,6 +849,11 @@ rspamd_rcl_composite_handler (struct config_file *cfg, ucl_object_t *obj,
                return FALSE;
        }
 
+       if (g_hash_table_lookup (cfg->composite_symbols, composite_name) != NULL) {
+               msg_warn ("composite %s is redefined", composite_name);
+               new = FALSE;
+       }
+
        val = ucl_object_find_key (obj, "expression");
        if (val == NULL || !ucl_object_tostring_safe (val, &composite_expression)) {
                g_set_error (err, CFG_RCL_ERROR, EINVAL, "composite must have an expression defined");
@@ -863,7 +869,10 @@ rspamd_rcl_composite_handler (struct config_file *cfg, ucl_object_t *obj,
        composite->expr = expr;
        composite->id = g_hash_table_size (cfg->composite_symbols) + 1;
        g_hash_table_insert (cfg->composite_symbols, (gpointer)composite_name, composite);
-       register_virtual_symbol (&cfg->cache, composite_name, 1);
+
+       if (new) {
+               register_virtual_symbol (&cfg->cache, composite_name, 1);
+       }
 
        return TRUE;
 }