]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Fix reading of the multiple sections
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 4 Nov 2017 16:35:01 +0000 (16:35 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 4 Nov 2017 16:35:01 +0000 (16:35 +0000)
src/libserver/cfg_rcl.c

index 3aa277e1abcee0a21d07832478ec688e6e44ab23..363df29b2aa4d1732f7e27281dae78ee58011a4f 100644 (file)
@@ -52,7 +52,6 @@ struct rspamd_rcl_section {
        enum ucl_type type;         /**< type of attribute */
        gboolean required;                  /**< whether this param is required */
        gboolean strict_type;               /**< whether we need strict type */
-       gboolean processed;
        UT_hash_handle hh;                  /** hash handle */
        struct rspamd_rcl_section *subsections; /**< hash table of subsections */
        struct rspamd_rcl_default_handler_data *default_parser; /**< generic parsing fields */
@@ -2217,7 +2216,7 @@ rspamd_rcl_config_init (struct rspamd_config *cfg)
                        "Rewrite subject with this value");
 
        sub = rspamd_rcl_add_section_doc (&new,
-                       "groups", "name",
+                       "group", "name",
                        rspamd_rcl_group_handler,
                        UCL_OBJECT,
                        FALSE,
@@ -2253,16 +2252,6 @@ rspamd_rcl_config_init (struct rspamd_config *cfg)
                        0,
                        "Maximum score that could be reached by this symbols group");
 
-       /* Grouped symbols */
-       rspamd_rcl_add_section_doc (&ssub->subsections,
-                       "symbol", "name",
-                       rspamd_rcl_symbol_handler,
-                       UCL_OBJECT,
-                       TRUE,
-                       TRUE,
-                       ssub->doc_ref,
-                       "Symbols settings");
-
        /**
         * Worker section
         */
@@ -2463,10 +2452,6 @@ rspamd_rcl_process_section (struct rspamd_config *cfg,
        g_assert (obj != NULL);
        g_assert (sec->handler != NULL);
 
-       if (sec->processed) {
-               return TRUE;
-       }
-
        if (sec->key_attr != NULL) {
                it = ucl_object_iterate_new (obj);
 
@@ -2490,14 +2475,12 @@ rspamd_rcl_process_section (struct rspamd_config *cfg,
                while ((cur = ucl_object_iterate_full (it, UCL_ITERATE_EXPLICIT)) != NULL) {
                        if (!sec->handler (pool, cur, ucl_object_key (cur), ptr, sec, err)) {
                                ucl_object_iterate_free (it);
-                               sec->processed = TRUE;
 
                                return FALSE;
                        }
                }
 
                ucl_object_iterate_free (it);
-               sec->processed = TRUE;
 
                return TRUE;
        }
@@ -2513,7 +2496,6 @@ rspamd_rcl_process_section (struct rspamd_config *cfg,
                                                        sec->key_attr,
                                                        sec->name,
                                                        ucl_object_emit (obj, UCL_EMIT_CONFIG));
-                                       sec->processed = TRUE;
 
                                        return FALSE;
                                }
@@ -2528,7 +2510,6 @@ rspamd_rcl_process_section (struct rspamd_config *cfg,
                                g_set_error (err, CFG_RCL_ERROR, EINVAL, "required attribute %s"
                                                " is not a string for section %s",
                                                sec->key_attr, sec->name);
-                               sec->processed = TRUE;
 
                                return FALSE;
                        }
@@ -2538,8 +2519,6 @@ rspamd_rcl_process_section (struct rspamd_config *cfg,
                }
        }
 
-       sec->processed = TRUE;
-
        return sec->handler (pool, obj, key, ptr, sec, err);
 }
 
@@ -3506,7 +3485,7 @@ rspamd_rcl_maybe_apply_lua_transform (struct rspamd_config *cfg)
                return;
        }
 
-       if (lua_toboolean (L, -2)) {
+       if (lua_toboolean (L, -2) && lua_type (L, -1) == LUA_TTABLE) {
                ucl_object_t *old_cfg = cfg->rcl_obj;
 
                msg_info_config ("configuration has been transformed in Lua");