Browse Source

Remove expressions pollutions from parts of rspamd.

tags/0.9.0
Vsevolod Stakhov 9 years ago
parent
commit
943734997a
6 changed files with 1 additions and 110 deletions
  1. 1
    1
      src/libmime/CMakeLists.txt
  2. 0
    1
      src/libserver/cfg_rcl.c
  3. 0
    1
      src/lua/lua_cfg_file.c
  4. 0
    1
      src/lua/lua_common.c
  5. 0
    105
      src/lua/lua_config.c
  6. 0
    1
      src/lua/lua_regexp.c

+ 1
- 1
src/libmime/CMakeLists.txt View 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

+ 0
- 1
src/libserver/cfg_rcl.c View 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 {

+ 0
- 1
src/lua/lua_cfg_file.c View 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>

+ 0
- 1
src/lua/lua_common.c View File

@@ -23,7 +23,6 @@
*/

#include "lua_common.h"
#include "expressions.h"

/* Lua module init function */
#define MODULE_INIT_FUNC "module_init"

+ 0
- 105
src/lua/lua_config.c View 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)

*/
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)
{

+ 0
- 1
src/lua/lua_regexp.c View File

@@ -22,7 +22,6 @@
*/

#include "lua_common.h"
#include "expressions.h"
#include "regexp.h"

/***

Loading…
Cancel
Save