aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-11-04 13:17:43 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-11-04 13:17:43 +0000
commit041d2e56ebeb880a423eb7f8434cdab4f7efaf68 (patch)
treebfe5553c7b21bbe00aeec9c93ff9f52cde4f9af8 /src
parent3383065b190c63dfaa3ef837572b1b43f80ae841 (diff)
downloadrspamd-041d2e56ebeb880a423eb7f8434cdab4f7efaf68.tar.gz
rspamd-041d2e56ebeb880a423eb7f8434cdab4f7efaf68.zip
[Rework] Simplify lua path initialization
Diffstat (limited to 'src')
-rw-r--r--src/libserver/cfg_file.h3
-rw-r--r--src/libserver/cfg_rcl.c1
-rw-r--r--src/libserver/cfg_utils.c4
-rw-r--r--src/lua/lua_common.c4
-rw-r--r--src/lua/lua_common.h3
-rw-r--r--src/lua/lua_util.c2
-rw-r--r--src/rspamadm/configdump.c3
-rw-r--r--src/rspamadm/confighelp.c4
-rw-r--r--src/rspamadm/configtest.c2
-rw-r--r--src/rspamadm/control.c3
-rw-r--r--src/rspamd.c14
11 files changed, 19 insertions, 24 deletions
diff --git a/src/libserver/cfg_file.h b/src/libserver/cfg_file.h
index 39f57662a..d91a4f06e 100644
--- a/src/libserver/cfg_file.h
+++ b/src/libserver/cfg_file.h
@@ -589,8 +589,7 @@ void rspamd_ucl_add_conf_variables (struct ucl_parser *parser, GHashTable *vars)
* @param reconfig
* @return
*/
-gboolean rspamd_init_filters (struct rspamd_config *cfg, bool reconfig,
- GHashTable *vars);
+gboolean rspamd_init_filters (struct rspamd_config *cfg, bool reconfig);
/**
* Add new symbol to the metric
diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c
index d32fa1919..f53b5ca17 100644
--- a/src/libserver/cfg_rcl.c
+++ b/src/libserver/cfg_rcl.c
@@ -3624,6 +3624,7 @@ rspamd_config_read (struct rspamd_config *cfg, const gchar *filename,
MIN (sizeof (cfg->cfg_pool->tag.uid), strlen (cfg->checksum)));
top = rspamd_rcl_config_init (cfg);
+ rspamd_lua_set_path (cfg->lua_state, cfg->rcl_obj, vars);
rspamd_rcl_set_lua_globals (cfg, cfg->lua_state, vars);
rspamd_mempool_add_destructor (cfg->cfg_pool, rspamd_rcl_section_free, top);
err = NULL;
diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c
index 079ed71c6..691482773 100644
--- a/src/libserver/cfg_utils.c
+++ b/src/libserver/cfg_utils.c
@@ -1375,7 +1375,7 @@ rspamd_check_worker (struct rspamd_config *cfg, worker_t *wrk)
}
gboolean
-rspamd_init_filters (struct rspamd_config *cfg, bool reconfig, GHashTable *vars)
+rspamd_init_filters (struct rspamd_config *cfg, bool reconfig)
{
GList *cur;
module_t *mod, **pmod;
@@ -1427,7 +1427,7 @@ rspamd_init_filters (struct rspamd_config *cfg, bool reconfig, GHashTable *vars)
cur = g_list_next (cur);
}
- return rspamd_init_lua_filters (cfg, 0, vars);
+ return rspamd_init_lua_filters (cfg, 0);
}
static void
diff --git a/src/lua/lua_common.c b/src/lua/lua_common.c
index dcdfef823..7b2b073e9 100644
--- a/src/lua/lua_common.c
+++ b/src/lua/lua_common.c
@@ -442,8 +442,7 @@ rspamd_free_lua_locked (struct lua_locked_state *st)
}
gboolean
-rspamd_init_lua_filters (struct rspamd_config *cfg, gboolean force_load,
- GHashTable *vars)
+rspamd_init_lua_filters (struct rspamd_config *cfg, gboolean force_load)
{
struct rspamd_config **pcfg;
GList *cur;
@@ -452,7 +451,6 @@ rspamd_init_lua_filters (struct rspamd_config *cfg, gboolean force_load,
GString *tb;
gint err_idx;
- rspamd_lua_set_path (L, cfg->rcl_obj, vars);
cur = g_list_first (cfg->script_modules);
while (cur) {
diff --git a/src/lua/lua_common.h b/src/lua/lua_common.h
index f67401fc2..9dbd8782b 100644
--- a/src/lua/lua_common.h
+++ b/src/lua/lua_common.h
@@ -163,8 +163,7 @@ lua_State *rspamd_lua_init (void);
* Load and initialize lua plugins
*/
gboolean
-rspamd_init_lua_filters (struct rspamd_config *cfg, gboolean force_load,
- GHashTable *vars);
+rspamd_init_lua_filters (struct rspamd_config *cfg, gboolean force_load);
/**
* Initialize new locked lua_State structure
diff --git a/src/lua/lua_util.c b/src/lua/lua_util.c
index 24273c8c4..8af61d6d5 100644
--- a/src/lua/lua_util.c
+++ b/src/lua/lua_util.c
@@ -658,7 +658,7 @@ lua_util_process_message (lua_State *L)
if (cfg != NULL && message != NULL) {
base = event_init ();
- rspamd_init_filters (cfg, FALSE, NULL);
+ rspamd_init_filters (cfg, FALSE);
task = rspamd_task_new (NULL, cfg, NULL);
task->ev_base = base;
task->msg.begin = rspamd_mempool_alloc (task->task_pool, mlen);
diff --git a/src/rspamadm/configdump.c b/src/rspamadm/configdump.c
index 720d6bf51..6f320dea1 100644
--- a/src/rspamadm/configdump.c
+++ b/src/rspamadm/configdump.c
@@ -284,9 +284,10 @@ rspamadm_configdump (gint argc, gchar **argv)
}
else {
/* Do post-load actions */
+ rspamd_lua_set_path (cfg->lua_state, cfg->rcl_obj, ucl_vars);
rspamd_lua_post_load_config (cfg);
- if (!rspamd_init_filters (rspamd_main->cfg, FALSE, ucl_vars)) {
+ if (!rspamd_init_filters (rspamd_main->cfg, FALSE)) {
ret = FALSE;
}
diff --git a/src/rspamadm/confighelp.c b/src/rspamadm/confighelp.c
index f3da9422d..5f8e1cfcc 100644
--- a/src/rspamadm/confighelp.c
+++ b/src/rspamadm/confighelp.c
@@ -20,7 +20,6 @@
#include "cfg_rcl.h"
#include "rspamd.h"
#include "lua/lua_common.h"
-#include "confighelp.lua.h"
static gboolean json = FALSE;
static gboolean compact = FALSE;
@@ -251,7 +250,8 @@ rspamadm_confighelp (gint argc, gchar **argv)
}
/* Init lua modules */
- rspamd_init_lua_filters (cfg, TRUE, ucl_vars);
+ rspamd_lua_set_path (cfg->lua_state, cfg->rcl_obj, ucl_vars);
+ rspamd_init_lua_filters (cfg, TRUE);
if (argc > 1) {
for (i = 1; i < argc; i ++) {
diff --git a/src/rspamadm/configtest.c b/src/rspamadm/configtest.c
index 3a15b976b..59f466de2 100644
--- a/src/rspamadm/configtest.c
+++ b/src/rspamadm/configtest.c
@@ -146,7 +146,7 @@ rspamadm_configtest (gint argc, gchar **argv)
/* Do post-load actions */
rspamd_lua_post_load_config (cfg);
- if (!rspamd_init_filters (rspamd_main->cfg, FALSE, ucl_vars)) {
+ if (!rspamd_init_filters (rspamd_main->cfg, FALSE)) {
ret = FALSE;
}
diff --git a/src/rspamadm/control.c b/src/rspamadm/control.c
index 98bcd81f4..62a7e26ae 100644
--- a/src/rspamadm/control.c
+++ b/src/rspamadm/control.c
@@ -24,7 +24,6 @@
#include <event.h>
#include "libutil/util.h"
#include "lua/lua_common.h"
-#include "fuzzy_stat.lua.h"
static gchar *control_path = RSPAMD_DBDIR "/rspamd.sock";
static gboolean json = FALSE;
@@ -135,7 +134,7 @@ rspamd_control_finish_handler (struct rspamd_http_connection *conn,
cbdata->argc,
cbdata->argv,
obj,
- rspamadm_script_fuzzy_stat);
+ "fuzzy_stat");
rspamd_fstring_free (out);
ucl_object_unref (obj);
diff --git a/src/rspamd.c b/src/rspamd.c
index d301f7449..6d20fe50c 100644
--- a/src/rspamd.c
+++ b/src/rspamd.c
@@ -68,8 +68,7 @@ static gboolean load_rspamd_config (struct rspamd_main *rspamd_main,
struct rspamd_config *cfg,
gboolean init_modules,
enum rspamd_post_load_options opts,
- gboolean reload,
- GHashTable *vars);
+ gboolean reload);
/* Control socket */
static gint control_fd;
@@ -289,7 +288,7 @@ reread_config (struct rspamd_main *rspamd_main)
if (!load_rspamd_config (rspamd_main, tmp_cfg, TRUE,
RSPAMD_CONFIG_INIT_VALIDATE|RSPAMD_CONFIG_INIT_SYMCACHE,
- TRUE, ucl_vars)) {
+ TRUE)) {
rspamd_main->cfg = old_cfg;
rspamd_log_close_priv (rspamd_main->logger,
rspamd_main->workers_uid,
@@ -871,8 +870,7 @@ static gboolean
load_rspamd_config (struct rspamd_main *rspamd_main,
struct rspamd_config *cfg, gboolean init_modules,
enum rspamd_post_load_options opts,
- gboolean reload,
- GHashTable *vars)
+ gboolean reload)
{
cfg->compiled_modules = modules;
cfg->compiled_workers = workers;
@@ -901,7 +899,7 @@ load_rspamd_config (struct rspamd_main *rspamd_main,
rspamd_lua_post_load_config (cfg);
if (init_modules) {
- rspamd_init_filters (cfg, reload, vars);
+ rspamd_init_filters (cfg, reload);
}
/* Do post-load actions */
@@ -1278,7 +1276,7 @@ main (gint argc, gchar **argv, gchar **env)
if (config_test || dump_cache) {
if (!load_rspamd_config (rspamd_main, rspamd_main->cfg, FALSE, 0,
- FALSE, ucl_vars)) {
+ FALSE)) {
exit (EXIT_FAILURE);
}
@@ -1301,7 +1299,7 @@ main (gint argc, gchar **argv, gchar **env)
/* Load config */
if (!load_rspamd_config (rspamd_main, rspamd_main->cfg, TRUE,
- RSPAMD_CONFIG_LOAD_ALL, FALSE, ucl_vars)) {
+ RSPAMD_CONFIG_LOAD_ALL, FALSE)) {
exit (EXIT_FAILURE);
}