]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Allow to disable lua squeezing logic
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 15 May 2018 13:37:24 +0000 (14:37 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 15 May 2018 13:37:24 +0000 (14:37 +0100)
src/libserver/cfg_file.h
src/libserver/cfg_rcl.c
src/lua/lua_config.c

index 5a846a1f52fb879ea96f575802373bba977e866c..520c847f336d714ee38929238fb4055b0b03e871 100644 (file)
@@ -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                 */
index d4aa5314b988e5e68eaa6b8178c0df9e4ddc3169..e47be0afec8849dfae39fa83f63ddf859d62b6dd 100644 (file)
@@ -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,
index 6e502d6e713db570452e3867cb3b7dc66a06a8fc..2802ab6a4d326c48fd70103e6576f360a53c2859 100644 (file)
@@ -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,