commit 13a1368: [Fix] Support definition of ungrouped symbol in conf file, use group info from lua or other conf file
ssturges
ststurge at cisco.com
Fri Jan 28 19:49:04 UTC 2022
Author: ssturges
Date: 2022-01-25 13:37:10 -0500
URL: https://github.com/rspamd/rspamd/commit/13a13685b067c15cf25d867e3b8663ef8835b9f9
[Fix] Support definition of ungrouped symbol in conf file, use group info from lua or other conf file
---
src/libserver/cfg_utils.c | 3 ++-
src/lua/lua_config.c | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 37 insertions(+), 1 deletion(-)
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);
More information about the Commits
mailing list