commit af4fca4: [Minor] Configwizard: Fix usage when the config is wrong
Vsevolod Stakhov
vsevolod at highsecure.ru
Tue Aug 24 14:28:04 UTC 2021
Author: Vsevolod Stakhov
Date: 2021-08-24 15:25:02 +0100
URL: https://github.com/rspamd/rspamd/commit/af4fca4b2a5543bc3838897fa603af2e0cdc210c (HEAD -> master)
[Minor] Configwizard: Fix usage when the config is wrong
---
lualib/rspamadm/configwizard.lua | 3 ++-
src/lua/lua_config.c | 19 ++++++++++++-------
2 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/lualib/rspamadm/configwizard.lua b/lualib/rspamadm/configwizard.lua
index bd7cd37c0..7c2d67cb5 100644
--- a/lualib/rspamadm/configwizard.lua
+++ b/lualib/rspamadm/configwizard.lua
@@ -696,7 +696,6 @@ return {
local args = opts['checks'] or {}
local _r,err = rspamd_config:load_ucl(opts['config'])
- local cfg = rspamd_config:get_ucl()
if not _r then
rspamd_logger.errx('cannot parse %s: %s', opts['config'], err)
@@ -709,6 +708,8 @@ return {
os.exit(1)
end
+ local cfg = rspamd_config:get_ucl()
+
if not rspamd_config:init_modules() then
rspamd_logger.errx('cannot init modules when parsing %s', opts['config'])
os.exit(1)
diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c
index b0e2df672..c6660852a 100644
--- a/src/lua/lua_config.c
+++ b/src/lua/lua_config.c
@@ -1092,13 +1092,18 @@ lua_config_get_ucl (lua_State * L)
lua_rawgeti (L, LUA_REGISTRYINDEX, cached->ref);
}
else {
- ucl_object_push_lua (L, cfg->rcl_obj, true);
- lua_pushvalue (L, -1);
- cached = rspamd_mempool_alloc (cfg->cfg_pool, sizeof (*cached));
- cached->L = L;
- cached->ref = luaL_ref (L, LUA_REGISTRYINDEX);
- rspamd_mempool_set_variable (cfg->cfg_pool, "ucl_cached",
- cached, lua_config_ucl_dtor);
+ if (cfg->rcl_obj) {
+ ucl_object_push_lua(L, cfg->rcl_obj, true);
+ lua_pushvalue(L, -1);
+ cached = rspamd_mempool_alloc (cfg->cfg_pool, sizeof(*cached));
+ cached->L = L;
+ cached->ref = luaL_ref(L, LUA_REGISTRYINDEX);
+ rspamd_mempool_set_variable(cfg->cfg_pool, "ucl_cached",
+ cached, lua_config_ucl_dtor);
+ }
+ else {
+ lua_pushnil (L);
+ }
}
}
else {
More information about the Commits
mailing list