diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-06-14 19:29:14 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-06-14 19:29:14 +0100 |
commit | 47c14afb4e24547f029862beae65de3526851d7f (patch) | |
tree | 4c22713655880bbafb8d8ad28956cde18f5185b9 | |
parent | a7a0800daba34acc86308d4ba75b8fd8c5fce57c (diff) | |
download | rspamd-47c14afb4e24547f029862beae65de3526851d7f.tar.gz rspamd-47c14afb4e24547f029862beae65de3526851d7f.zip |
[Project] Fix some more issues
-rw-r--r-- | lualib/lua_settings.lua | 8 | ||||
-rw-r--r-- | src/libserver/rspamd_symcache.c | 24 | ||||
-rw-r--r-- | src/lua/lua_config.c | 2 |
3 files changed, 22 insertions, 12 deletions
diff --git a/lualib/lua_settings.lua b/lualib/lua_settings.lua index 5cd2fb8fa..f66db6a06 100644 --- a/lualib/lua_settings.lua +++ b/lualib/lua_settings.lua @@ -22,7 +22,7 @@ limitations under the License. local exports = {} local known_ids = {} -local on_load_added = false +local post_init_added = false local function register_settings_cb() for _,set in pairs(known_ids) do @@ -116,9 +116,9 @@ local function register_settings_id(str, settings) } end - if not on_load_added then - rspamd_config:add_on_load(register_settings_cb) - on_load_added = true + if not post_init_added then + rspamd_config:add_post_init(register_settings_cb) + post_init_added = true end return numeric_id diff --git a/src/libserver/rspamd_symcache.c b/src/libserver/rspamd_symcache.c index 25707b447..d6377eff2 100644 --- a/src/libserver/rspamd_symcache.c +++ b/src/libserver/rspamd_symcache.c @@ -1431,6 +1431,17 @@ rspamd_symcache_is_item_allowed (struct rspamd_task *task, if (!item->enabled || (RSPAMD_TASK_IS_EMPTY (task) && !(item->type & SYMBOL_TYPE_EMPTY)) || (item->type & SYMBOL_TYPE_MIME_ONLY && !RSPAMD_TASK_IS_MIME(task))) { + + if (!item->enabled) { + msg_debug_cache_task ("skipping check of %s as it is permanently disabled", + item->symbol); + } + else { + msg_debug_cache_task ("skipping check of %s as it cannot be " + "executed for this task type", + item->symbol); + } + return FALSE; } @@ -1449,7 +1460,7 @@ rspamd_symcache_is_item_allowed (struct rspamd_task *task, } if (!(item->type & SYMBOL_TYPE_EXPLICIT_DISABLE)) { - if (item->allowed_ids.st[0] != 0 && + if (item->allowed_ids.st[0] == 0 || !rspamd_symcache_check_id_list (&item->allowed_ids, id)) { msg_debug_cache_task ("deny execution of %s as it is not listed " @@ -1515,7 +1526,6 @@ rspamd_symcache_check_symbol (struct rspamd_task *task, SET_START_BIT (checkpoint, dyn_item); if (!rspamd_symcache_is_item_allowed (task, item)) { - msg_debug_cache_task ("disable execution of symbol %s", item->symbol); check = FALSE; } else if (item->specific.normal.condition_cb != -1) { @@ -1535,6 +1545,11 @@ rspamd_symcache_check_symbol (struct rspamd_task *task, check = lua_toboolean (L, -1); lua_pop (L, 1); } + + if (!check) { + msg_debug_cache_task ("skipping check of %s as its start condition is false", + item->symbol); + } } if (check) { @@ -1570,8 +1585,6 @@ rspamd_symcache_check_symbol (struct rspamd_task *task, return FALSE; } else { - msg_debug_cache_task ("skipping check of %s as its start condition is false", - item->symbol); SET_FINISH_BIT (checkpoint, dyn_item); } @@ -3179,11 +3192,8 @@ rspamd_symcache_add_id_to_list (rspamd_mempool_t *pool, /* Static part */ while (ls->st[cnt] != 0) { cnt ++; - - g_assert (cnt < G_N_ELEMENTS (ls->st)); } - if (cnt < G_N_ELEMENTS (ls->st)) { ls->st[cnt] = id; } diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c index 832e10614..537a44bb6 100644 --- a/src/lua/lua_config.c +++ b/src/lua/lua_config.c @@ -3327,7 +3327,7 @@ lua_config_get_group_symbols (lua_State *L) while (g_hash_table_iter_next (&it, &k, &v)) { lua_pushstring (L, k); - lua_rawseti (L, -1, i); + lua_rawseti (L, -2, i); i ++; } } |