]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Add execution of lua global functions script
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 28 May 2016 11:33:34 +0000 (12:33 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 28 May 2016 11:33:34 +0000 (12:33 +0100)
src/lua/CMakeLists.txt
src/lua/global_functions.lua [new file with mode: 0644]
src/lua/lua_common.c

index 544fbac3ace7e79a38446f2f3ff7b602a6ce7c97..fefd074d5fdaeed5892c20c4b391f55f1f783346 100644 (file)
@@ -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 (file)
index 0000000..e69de29
index 4563d9f84d7f3619ec865bff836977355d05d896..ad77b0602f35438dc81656195ff2910b381afca8 100644 (file)
@@ -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;
 }