From: Vsevolod Stakhov Date: Tue, 17 Feb 2015 12:55:51 +0000 (+0000) Subject: Set lua path for lua configuration. X-Git-Tag: 0.9.0~681 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=77d65b7266828dccdec909d352f2c1238e970e4b;p=thirdparty%2Frspamd.git Set lua path for lua configuration. --- diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c index 4ea7c17edb..6c309d4dd5 100644 --- a/src/libserver/cfg_rcl.c +++ b/src/libserver/cfg_rcl.c @@ -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 diff --git a/src/lua/lua_common.c b/src/lua/lua_common.c index cb5f077126..ffba71754c 100644 --- a/src/lua/lua_common.c +++ b/src/lua/lua_common.c @@ -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"); diff --git a/src/lua/lua_common.h b/src/lua/lua_common.h index 521a255803..7c532df4e8 100644 --- a/src/lua/lua_common.h +++ b/src/lua/lua_common.h @@ -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);