diff options
Diffstat (limited to 'src/libserver/cfg_rcl.c')
-rw-r--r-- | src/libserver/cfg_rcl.c | 35 |
1 files changed, 8 insertions, 27 deletions
diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c index 9df9e4aa1..d5e30d8a7 100644 --- a/src/libserver/cfg_rcl.c +++ b/src/libserver/cfg_rcl.c @@ -753,7 +753,6 @@ rspamd_rcl_lua_handler (rspamd_mempool_t *pool, const ucl_object_t *obj, ucl_object_tostring (obj)); gchar *cur_dir, *lua_dir, *lua_file, *tmp1, *tmp2; lua_State *L = cfg->lua_state; - GString *tb; gint err_idx; tmp1 = g_strdup (lua_src); @@ -788,15 +787,13 @@ rspamd_rcl_lua_handler (rspamd_mempool_t *pool, const ucl_object_t *obj, /* Now do it */ if (lua_pcall (L, 0, 0, err_idx) != 0) { - tb = lua_touserdata (L, -1); g_set_error (err, CFG_RCL_ERROR, EINVAL, "cannot init lua file %s: %s", lua_src, - tb->str); - g_string_free (tb, TRUE); - lua_pop (L, 2); + lua_tostring (L, -1)); + lua_settop (L, 0); if (chdir (cur_dir) == -1) { msg_err_config ("cannot chdir to %s: %s", cur_dir, @@ -1241,7 +1238,6 @@ rspamd_rcl_classifier_handler (rspamd_mempool_t *pool, const gchar *lua_script; gsize slen; gint err_idx, ref_idx; - GString *tb = NULL; lua_script = ucl_object_tolstring (cur, &slen); L = cfg->lua_state; @@ -1263,13 +1259,11 @@ rspamd_rcl_classifier_handler (rspamd_mempool_t *pool, /* Now do it */ if (lua_pcall (L, 0, 1, err_idx) != 0) { - tb = lua_touserdata (L, -1); g_set_error (err, CFG_RCL_ERROR, EINVAL, "cannot init lua condition script: %s", - tb->str); - g_string_free (tb, TRUE); + lua_tostring (L, -1)); lua_settop (L, 0); return FALSE; @@ -3484,7 +3478,6 @@ rspamd_rcl_maybe_apply_lua_transform (struct rspamd_config *cfg) { lua_State *L = cfg->lua_state; gint err_idx, ret; - GString *tb; gchar str[PATH_MAX]; static const char *transform_script = "lua_cfg_transform"; @@ -3518,13 +3511,8 @@ rspamd_rcl_maybe_apply_lua_transform (struct rspamd_config *cfg) ucl_object_push_lua (L, cfg->rcl_obj, true); if ((ret = lua_pcall (L, 1, 2, err_idx)) != 0) { - tb = lua_touserdata (L, -1); - msg_err ("call to rspamadm lua script failed (%d): %v", ret, tb); - - if (tb) { - g_string_free (tb, TRUE); - } - + msg_err ("call to rspamadm lua script failed (%d): %v", ret, + lua_tostring (L, -1)); lua_settop (L, 0); return; @@ -3588,11 +3576,8 @@ rspamd_rcl_jinja_handler (struct ucl_parser *parser, lua_pushboolean (L, false); if (lua_pcall (L, 3, 1, err_idx) != 0) { - GString *tb; - - tb = lua_touserdata (L, -1); - msg_err_config ("cannot call lua jinja_template script: %s", tb->str); - g_string_free (tb, TRUE); + msg_err_config ("cannot call lua jinja_template script: %s", + lua_tostring (L, -1)); lua_settop (L, err_idx - 1); return false; @@ -3856,12 +3841,8 @@ rspamd_config_read (struct rspamd_config *cfg, rspamd_lua_setclass (L, "rspamd{config}", -1); if (lua_pcall (L, 1, 0, err_idx) != 0) { - GString *tb; - - tb = lua_touserdata (L, -1); msg_err_config ("cannot call lua init_debug_logging script: %s", - tb->str); - g_string_free (tb, TRUE); + lua_tostring (L, -1)); lua_settop (L, err_idx - 1); return FALSE; |