From: Vsevolod Stakhov Date: Tue, 15 May 2018 13:37:24 +0000 (+0100) Subject: [Feature] Allow to disable lua squeezing logic X-Git-Tag: 1.7.5~19 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=1674846653fd33d9478bfcf9ff391ac6c6164c74;p=rspamd.git [Feature] Allow to disable lua squeezing logic --- diff --git a/src/libserver/cfg_file.h b/src/libserver/cfg_file.h index 5a846a1f5..520c847f3 100644 --- a/src/libserver/cfg_file.h +++ b/src/libserver/cfg_file.h @@ -311,7 +311,8 @@ struct rspamd_config { gboolean ignore_received; /**< Ignore data from the first received header */ gboolean enable_sessions_cache; /**< Enable session cache for debug */ gboolean enable_experimental; /**< Enable experimental plugins */ - gboolean disable_pcre_jit; /**< Disable pcre JIT */ + gboolean disable_pcre_jit; /**< Disable pcre JIT */ + gboolean disable_lua_squeeze; /**< Disable lua rules squeezing */ gsize max_diff; /**< maximum diff size for text parts */ gsize max_cores_size; /**< maximum size occupied by rspamd core files */ diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c index d4aa5314b..e47be0afe 100644 --- a/src/libserver/cfg_rcl.c +++ b/src/libserver/cfg_rcl.c @@ -2059,11 +2059,17 @@ rspamd_rcl_config_init (struct rspamd_config *cfg) 0, "Enable experimental plugins"); rspamd_rcl_add_default_handler (sub, - "enable_experimental", + "disable_pcre_jit", rspamd_rcl_parse_struct_boolean, G_STRUCT_OFFSET (struct rspamd_config, disable_pcre_jit), 0, "Disable PCRE JIT"); + rspamd_rcl_add_default_handler (sub, + "disable_lua_squeeze", + rspamd_rcl_parse_struct_boolean, + G_STRUCT_OFFSET (struct rspamd_config, disable_lua_squeeze), + 0, + "Disable Lua rules squeezing"); rspamd_rcl_add_default_handler (sub, "all_filters", rspamd_rcl_parse_struct_boolean, diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c index 6e502d6e7..2802ab6a4 100644 --- a/src/lua/lua_config.c +++ b/src/lua/lua_config.c @@ -1595,6 +1595,10 @@ lua_config_register_symbol (lua_State * L) return luaL_error (L, "invalid arguments"); } + if (!no_squeeze) { + no_squeeze = cfg->disable_lua_squeeze; + } + if (nshots == 0) { nshots = cfg->default_max_shots; } @@ -1894,18 +1898,20 @@ lua_config_register_dependency (lua_State * L) struct rspamd_config *cfg = lua_check_config (L, 1); const gchar *parent = NULL, *child = NULL; gint child_id; - gboolean skip_squeeze = FALSE; + gboolean skip_squeeze; if (cfg == NULL) { lua_error (L); return 0; } + skip_squeeze = cfg->disable_lua_squeeze; + if (lua_type (L, 2) == LUA_TNUMBER) { child_id = luaL_checknumber (L, 2); parent = luaL_checkstring (L, 3); - if (lua_isboolean (L, 4)) { + if (!skip_squeeze && lua_isboolean (L, 4)) { skip_squeeze = lua_toboolean (L, 4); } @@ -1925,7 +1931,7 @@ lua_config_register_dependency (lua_State * L) child = luaL_checkstring (L,2); parent = luaL_checkstring (L, 3); - if (lua_isboolean (L, 4)) { + if (!skip_squeeze && lua_isboolean (L, 4)) { skip_squeeze = lua_toboolean (L, 4); } @@ -2246,6 +2252,8 @@ lua_config_newindex (lua_State *L) name = luaL_checkstring (L, 2); if (cfg != NULL && name != NULL && lua_gettop (L) == 3) { + no_squeeze = cfg->disable_lua_squeeze; + if (lua_type (L, 3) == LUA_TFUNCTION) { /* Normal symbol from just a function */ lua_pushvalue (L, 3); @@ -2266,6 +2274,7 @@ lua_config_newindex (lua_State *L) const char *type_str, *group = NULL, *description = NULL; guint flags = 0; + no_squeeze = cfg->disable_lua_squeeze; /* * Table can have the following attributes: * "callback" - should be a callback function @@ -2332,13 +2341,15 @@ lua_config_newindex (lua_State *L) } lua_pop (L, 1); - lua_pushstring (L, "no_squeeze"); - lua_gettable (L, -2); + if (!no_squeeze) { + lua_pushstring (L, "no_squeeze"); + lua_gettable (L, -2); - if (lua_toboolean (L, -1)) { - no_squeeze = TRUE; + if (lua_toboolean (L, -1)) { + no_squeeze = TRUE; + } + lua_pop (L, 1); } - lua_pop (L, 1); id = rspamd_register_symbol_fromlua (L, cfg,