From d9249726a98a417c82aee9ef14353cad6c63da91 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 11 Jan 2017 14:06:18 +0000 Subject: [PATCH] [Fix] Stop hardcoding of lua in C --- {src/lua => rules}/global_functions.lua | 0 rules/rspamd.lua | 1 + src/CMakeLists.txt | 1 - src/lua/CMakeLists.txt | 9 +-------- src/lua/lua_common.c | 6 ------ 5 files changed, 2 insertions(+), 15 deletions(-) rename {src/lua => rules}/global_functions.lua (100%) diff --git a/src/lua/global_functions.lua b/rules/global_functions.lua similarity index 100% rename from src/lua/global_functions.lua rename to rules/global_functions.lua diff --git a/rules/rspamd.lua b/rules/rspamd.lua index a9ead440d..a89f0a002 100644 --- a/rules/rspamd.lua +++ b/rules/rspamd.lua @@ -21,6 +21,7 @@ config['regexp'] = {} local local_conf = rspamd_paths['CONFDIR'] local local_rules = rspamd_paths['RULESDIR'] +dofile(local_rules .. '/global_functions.lua') dofile(local_rules .. '/regexp/headers.lua') dofile(local_rules .. '/regexp/lotto.lua') dofile(local_rules .. '/regexp/fraud.lua') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 36ab66f73..33bc45406 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -170,7 +170,6 @@ TARGET_LINK_LIBRARIES(rspamd-server rspamd-zstd) IF (ENABLE_CLANG_PLUGIN MATCHES "ON") ADD_DEPENDENCIES(rspamd-server rspamd-clang) ENDIF() -ADD_DEPENDENCIES(rspamd-server rspamd_lua_preprocess) ADD_EXECUTABLE(rspamd ${RSPAMDSRC} ${CMAKE_CURRENT_BINARY_DIR}/workers.c) SET_TARGET_PROPERTIES(rspamd PROPERTIES LINKER_LANGUAGE C) diff --git a/src/lua/CMakeLists.txt b/src/lua/CMakeLists.txt index ba1a7c16a..9c561c0e4 100644 --- a/src/lua/CMakeLists.txt +++ b/src/lua/CMakeLists.txt @@ -27,11 +27,4 @@ SET(LUASRC ${CMAKE_CURRENT_SOURCE_DIR}/lua_common.c ${CMAKE_CURRENT_SOURCE_DIR}/lua_cryptobox.c ${CMAKE_CURRENT_SOURCE_DIR}/lua_map.c) -SET(RSPAMD_LUA ${LUASRC} PARENT_SCOPE) -SET(RSPAMDMLUASRC "${CMAKE_CURRENT_SOURCE_DIR}/global_functions.lua") -ADD_CUSTOM_TARGET(rspamd_lua_preprocess - ${PERL_EXECUTABLE} - "${CMAKE_SOURCE_DIR}/lua_preprocess.pl" - "${CMAKE_CURRENT_SOURCE_DIR}" - "${CMAKE_CURRENT_BINARY_DIR}" - SOURCES ${RSPAMDMLUASRC} ${CMAKE_SOURCE_DIR}/lua_preprocess.pl) \ No newline at end of file +SET(RSPAMD_LUA ${LUASRC} PARENT_SCOPE) \ No newline at end of file diff --git a/src/lua/lua_common.c b/src/lua/lua_common.c index 3dc02991b..b9eabe790 100644 --- a/src/lua/lua_common.c +++ b/src/lua/lua_common.c @@ -14,7 +14,6 @@ * limitations under the License. */ #include "lua_common.h" -#include "lua/global_functions.lua.h" #include "lptree.h" #include "utlist.h" #include @@ -302,11 +301,6 @@ rspamd_lua_init () rspamd_lua_new_class (L, "rspamd{worker}", worker_reg); 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)); - } - /* Add plugins global */ lua_newtable (L); lua_setglobal (L, "rspamd_plugins"); -- 2.39.5