diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/libserver/cfg_utils.c | 3 | ||||
-rw-r--r-- | src/lua/lua_config.c | 35 |
2 files changed, 37 insertions, 1 deletions
diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c index 44cdbc84f..4deae950e 100644 --- a/src/libserver/cfg_utils.c +++ b/src/libserver/cfg_utils.c @@ -1630,8 +1630,9 @@ rspamd_config_add_symbol (struct rspamd_config *cfg, sym_group = rspamd_config_new_group (cfg, group); } - if (!sym_def->gr) { + if ((!sym_def->gr) || (sym_def->flags & RSPAMD_SYMBOL_FLAG_UNGROUPPED)) { sym_def->gr = sym_group; + sym_def->flags &= ~RSPAMD_SYMBOL_FLAG_UNGROUPPED; } g_hash_table_insert (sym_group->symbols, sym_def->name, sym_def); diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c index 8b0a4a46c..d66af2d0c 100644 --- a/src/lua/lua_config.c +++ b/src/lua/lua_config.c @@ -2873,6 +2873,41 @@ lua_config_newindex (lua_State *L) lua_pop (L, 1); } } + else + { + /* Fill in missing fields from lua defintion if they are not set */ + if (sym->description == NULL) { + lua_pushstring (L, "description"); + lua_gettable (L, -2); + + if (lua_type (L, -1) == LUA_TSTRING) { + description = lua_tostring (L, -1); + } + lua_pop (L, 1); + + if (description) { + sym->description = rspamd_mempool_strdup (cfg->cfg_pool, description); + } + } + + /* If ungrouped and there is a group defined in lua, change the primary group + * Otherwise, add to the list of groups for this symbol. */ + lua_pushstring (L, "group"); + lua_gettable (L, -2); + if (lua_type (L, -1) == LUA_TSTRING) { + group = lua_tostring (L, -1); + } + lua_pop (L, 1); + if (group) { + if (sym->flags & RSPAMD_SYMBOL_FLAG_UNGROUPPED) + { + /* Unset the "ungrouped" group */ + sym->gr = NULL; + } + /* Add the group */ + rspamd_config_add_symbol_group (cfg, name, group); + } + } /* Remove table from stack */ lua_pop (L, 1); |