]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Set lua path for lua configuration.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 17 Feb 2015 12:55:51 +0000 (12:55 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 17 Feb 2015 12:55:51 +0000 (12:55 +0000)
src/libserver/cfg_rcl.c
src/lua/lua_common.c
src/lua/lua_common.h

index 4ea7c17edbc176ca10c68fea6f0920be11f7a924..6c309d4dd5e9c461fef6e55ed3f071a1167b42ee 100644 (file)
@@ -664,6 +664,8 @@ rspamd_rcl_set_lua_globals (struct rspamd_config *cfg, lua_State *L)
 
        /* Clear stack from globals */
        lua_pop (L, 4);
+
+       rspamd_lua_set_path (L, cfg);
 }
 
 static gboolean
index cb5f0771263c640c20b77b433b0b266aeb2c417e..ffba71754c5da5b93cf91f81d5640e631c0da4f9 100644 (file)
@@ -281,7 +281,7 @@ lua_add_actions_global (lua_State *L)
        lua_setglobal (L, "rspamd_actions");
 }
 
-static void
+void
 rspamd_lua_set_path (lua_State *L, struct rspamd_config *cfg)
 {
        const gchar *old_path, *additional_path = NULL;
@@ -292,6 +292,11 @@ rspamd_lua_set_path (lua_State *L, struct rspamd_config *cfg)
        lua_getfield (L, -1, "path");
        old_path = luaL_checkstring (L, -1);
 
+       if (strstr (old_path, RSPAMD_PLUGINSDIR) != NULL) {
+               /* Path has been already set, do not touch it */
+               return;
+       }
+
        opts = ucl_object_find_key (cfg->rcl_obj, "options");
        if (opts != NULL) {
                opts = ucl_object_find_key (opts, "lua_path");
index 521a25580303ab99ca43567ed9a0af2c3dfaf70a..7c532df4e87faf9a1f3d574378825a5ebde80a29 100644 (file)
@@ -218,6 +218,9 @@ gboolean rspamd_lua_check_condition (struct rspamd_config *cfg,
        const gchar *condition);
 void rspamd_lua_dumpstack (lua_State *L);
 
+/* Set lua path according to the configuration */
+void rspamd_lua_set_path (lua_State *L, struct rspamd_config *cfg);
+
 struct memory_pool_s * rspamd_lua_check_mempool (lua_State * L);