]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Remove expressions pollutions from parts of rspamd.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 19 Mar 2015 16:19:09 +0000 (16:19 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 19 Mar 2015 16:19:09 +0000 (16:19 +0000)
src/libmime/CMakeLists.txt
src/libserver/cfg_rcl.c
src/lua/lua_cfg_file.c
src/lua/lua_common.c
src/lua/lua_config.c
src/lua/lua_regexp.c

index 36de02c82015ca9e7ae3e0394bf66907d6580efb..bb678d2f94c4b35ee03c35b7b21072cc01dc2a50 100644 (file)
@@ -1,6 +1,6 @@
 # Librspamd mime
 SET(LIBRSPAMDMIMESRC
-                               ${CMAKE_CURRENT_SOURCE_DIR}/expressions.c
+                               ${CMAKE_CURRENT_SOURCE_DIR}/mime_expressions.c
                                ${CMAKE_CURRENT_SOURCE_DIR}/filter.c
                                ${CMAKE_CURRENT_SOURCE_DIR}/images.c
                                ${CMAKE_CURRENT_SOURCE_DIR}/message.c
index 21dff7dd1726b90f0325ba18738671fa4ba1431e..5071b390f03df04f3c75cddcb417b15ce7b527d3 100644 (file)
@@ -27,7 +27,6 @@
 #include "utlist.h"
 #include "cfg_file.h"
 #include "lua/lua_common.h"
-#include "expressions.h"
 
 
 struct rspamd_rcl_default_handler_data {
index c29b4b2b14b50bac390435aec0d0f442411de6f8..9ad33313259735e7dd1160da0fa1ea7595a11dda 100644 (file)
@@ -23,7 +23,6 @@
  */
 
 #include "lua_common.h"
-#include "expressions.h"
 #include "symbols_cache.h"
 #ifdef HAVE_SYS_UTSNAME_H
 #include <sys/utsname.h>
index 63d34e4e6b32f09838fc23be246dea8bc7177601..d970325d14f72b5de2b32affe94bce8b649dcd7a 100644 (file)
@@ -23,7 +23,6 @@
  */
 
 #include "lua_common.h"
-#include "expressions.h"
 
 /* Lua module init function */
 #define MODULE_INIT_FUNC "module_init"
index 5116fff93d7664fb784fb708b45c4f41df47b56e..178b3f098fe2cec597d9add0cc20268084a9d062 100644 (file)
@@ -24,7 +24,6 @@
 
 
 #include "lua_common.h"
-#include "expressions.h"
 #include "map.h"
 #include "message.h"
 #include "radix.h"
@@ -69,27 +68,6 @@ LUA_FUNCTION_DEF (config, get_all_opt);
  * @return {mempool} [memory pool](mempool.md) object
  */
 LUA_FUNCTION_DEF (config, get_mempool);
-/***
- * @method rspamd_config:register_function(name, callback)
- * Registers new rspamd function that could be used in symbols expressions
- * @param {string} name name of function
- * @param {function} callback callback to be called
- * @example
-
-local function lua_header_exists(task, hname)
-       if task:get_raw_header(hname) then
-               return true
-       end
-
-       return false
-end
-
-rspamd_config:register_function('lua_header_exists', lua_header_exists)
-
--- Further in configuration it would be possible to define symbols like:
--- HAS_CONTENT_TYPE = 'lua_header_exists(Content-Type)'
- */
-LUA_FUNCTION_DEF (config, register_function);
 /***
  * @method rspamd_config:add_radix_map(mapline[, description])
  * Creates new dynamic map of IP/mask addresses.
@@ -314,7 +292,6 @@ static const struct luaL_reg configlib_m[] = {
        LUA_INTERFACE_DEF (config, get_module_opt),
        LUA_INTERFACE_DEF (config, get_mempool),
        LUA_INTERFACE_DEF (config, get_all_opt),
-       LUA_INTERFACE_DEF (config, register_function),
        LUA_INTERFACE_DEF (config, add_radix_map),
        LUA_INTERFACE_DEF (config, radix_from_config),
        LUA_INTERFACE_DEF (config, add_hash_map),
@@ -532,90 +509,6 @@ lua_destroy_cfg_symbol (gpointer ud)
        }
 }
 
-static gboolean
-lua_config_function_callback (struct rspamd_task *task,
-       GList *args,
-       void *user_data)
-{
-       struct lua_callback_data *cd = user_data;
-       struct rspamd_task **ptask;
-       gint i = 1;
-       struct expression_argument *arg;
-       GList *cur;
-       gboolean res = FALSE;
-
-       if (cd->cb_is_ref) {
-               lua_rawgeti (cd->L, LUA_REGISTRYINDEX, cd->callback.ref);
-       }
-       else {
-               lua_getglobal (cd->L, cd->callback.name);
-       }
-       ptask = lua_newuserdata (cd->L, sizeof (struct rspamd_task *));
-       rspamd_lua_setclass (cd->L, "rspamd{task}", -1);
-       *ptask = task;
-       /* Now push all arguments */
-       cur = args;
-       while (cur) {
-               arg = get_function_arg (cur->data, task, TRUE);
-               lua_pushstring (cd->L, (const gchar *)arg->data);
-               cur = g_list_next (cur);
-               i++;
-       }
-
-       if (lua_pcall (cd->L, i, 1, 0) != 0) {
-               msg_info ("error processing symbol %s: call to %s failed: %s",
-                       cd->symbol,
-                       cd->cb_is_ref ? "local function" :
-                       cd->callback.name,
-                       lua_tostring (cd->L, -1));
-       }
-       else {
-               if (lua_isboolean (cd->L, 1)) {
-                       res = lua_toboolean (cd->L, 1);
-               }
-               lua_pop (cd->L, 1);
-       }
-
-       return res;
-}
-
-static gint
-lua_config_register_function (lua_State *L)
-{
-       struct rspamd_config *cfg = lua_check_config (L);
-       gchar *name;
-       struct lua_callback_data *cd;
-
-       if (cfg) {
-               name = rspamd_mempool_strdup (cfg->cfg_pool, luaL_checkstring (L, 2));
-               cd =
-                       rspamd_mempool_alloc (cfg->cfg_pool,
-                               sizeof (struct lua_callback_data));
-
-               if (lua_type (L, 3) == LUA_TSTRING) {
-                       cd->callback.name = rspamd_mempool_strdup (cfg->cfg_pool,
-                                       luaL_checkstring (L, 3));
-                       cd->cb_is_ref = FALSE;
-               }
-               else {
-                       lua_pushvalue (L, 3);
-                       /* Get a reference */
-                       cd->callback.ref = luaL_ref (L, LUA_REGISTRYINDEX);
-                       cd->cb_is_ref = TRUE;
-               }
-               if (name) {
-                       cd->L = L;
-                       cd->symbol = name;
-                       register_expression_function (name, lua_config_function_callback,
-                               cd);
-               }
-               rspamd_mempool_add_destructor (cfg->cfg_pool,
-                       (rspamd_mempool_destruct_t)lua_destroy_cfg_symbol,
-                       cd);
-       }
-       return 1;
-}
-
 static gint
 lua_config_register_module_option (lua_State *L)
 {
index 6fa0de77273c76a87fb8b252cc96e58529e31b16..58073b3bc3b08574f54d4fd49032db1593498e9d 100644 (file)
@@ -22,7 +22,6 @@
  */
 
 #include "lua_common.h"
-#include "expressions.h"
 #include "regexp.h"
 
 /***