From: Vsevolod Stakhov Date: Sun, 16 Jul 2017 15:33:28 +0000 (+0100) Subject: [Fix] Fix setting of path and cpath for Lua X-Git-Tag: 1.7.0~842 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=8d080cdc349ee281701ae185d2053314611875da;p=rspamd.git [Fix] Fix setting of path and cpath for Lua --- diff --git a/src/lua/lua_common.c b/src/lua/lua_common.c index 2af506f13..58c728607 100644 --- a/src/lua/lua_common.c +++ b/src/lua/lua_common.c @@ -253,14 +253,25 @@ rspamd_lua_set_path (lua_State *L, struct rspamd_config *cfg, GHashTable *vars) if (additional_path) { rspamd_snprintf (path_buf, sizeof (path_buf), - "%s/lua/?.lua;%s/lua/?.lua;%s/?.lua;%s/?.lua;%s/?.so;%s;%s", + "%s/lua/?.lua;" + "%s/lua/?.lua;" + "%s/?.lua;" + "%s/?.lua;" + "%s/?/init.lua;" + "%s;" + "%s", pluginsdir, RSPAMD_CONFDIR, rulesdir, lualibdir, lualibdir, additional_path, old_path); } else { rspamd_snprintf (path_buf, sizeof (path_buf), - "%s/lua/?.lua;%s/lua/?.lua;%s/?.lua;%s/?.lua;%s/?.so;%s", + "%s/lua/?.lua;" + "%s/lua/?.lua;" + "%s/?.lua;" + "%s/?.lua;" + "%s/?/init.lua;" + "%s", pluginsdir, RSPAMD_CONFDIR, rulesdir, lualibdir, lualibdir, old_path); @@ -269,6 +280,20 @@ rspamd_lua_set_path (lua_State *L, struct rspamd_config *cfg, GHashTable *vars) lua_pop (L, 1); lua_pushstring (L, path_buf); lua_setfield (L, -2, "path"); + + lua_getglobal (L, "package"); + lua_getfield (L, -1, "cpath"); + old_path = luaL_checkstring (L, -1); + + rspamd_snprintf (path_buf, sizeof (path_buf), + "%s/?.so;" + "%s", + lualibdir, + old_path); + lua_pop (L, 1); + lua_pushstring (L, path_buf); + lua_setfield (L, -2, "cpath"); + lua_pop (L, 1); }