From a109540436f05ea4e67c50b4a2517023bd6b144b Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sat, 28 May 2016 12:33:34 +0100 Subject: [PATCH] [Feature] Add execution of lua global functions script --- src/lua/CMakeLists.txt | 2 +- src/lua/global_functions.lua | 0 src/lua/lua_common.c | 6 ++++++ 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 src/lua/global_functions.lua diff --git a/src/lua/CMakeLists.txt b/src/lua/CMakeLists.txt index 544fbac3a..fefd074d5 100644 --- a/src/lua/CMakeLists.txt +++ b/src/lua/CMakeLists.txt @@ -30,7 +30,7 @@ SET(LUASRC ${CMAKE_CURRENT_SOURCE_DIR}/lua_common.c ${CMAKE_CURRENT_SOURCE_DIR}/lua_map.c) SET(RSPAMD_LUA ${LUASRC} PARENT_SCOPE) -SET(RSPAMDMLUASRC "") +SET(RSPAMDMLUASRC "${CMAKE_CURRENT_SOURCE_DIR}/global_functions.lua") ADD_CUSTOM_TARGET(rspamd_lua_preprocess ${PERL_EXECUTABLE} "${CMAKE_SOURCE_DIR}/lua_preprocess.pl" diff --git a/src/lua/global_functions.lua b/src/lua/global_functions.lua new file mode 100644 index 000000000..e69de29bb diff --git a/src/lua/lua_common.c b/src/lua/lua_common.c index 4563d9f84..ad77b0602 100644 --- a/src/lua/lua_common.c +++ b/src/lua/lua_common.c @@ -14,6 +14,7 @@ * limitations under the License. */ #include "lua_common.h" +#include "lua/global_functions.lua.h" /* Lua module init function */ #define MODULE_INIT_FUNC "module_init" @@ -244,6 +245,11 @@ rspamd_lua_init () rspamd_lua_add_preload (L, "ucl", luaopen_ucl); + if (luaL_dostring (L, rspamadm_script_global_functions) != 0) { + msg_err ("cannot execute lua global script: %s", + lua_tostring (L, -1)); + } + return L; } -- 2.39.5