aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-05-31 15:52:18 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-05-31 15:52:18 +0100
commit3ae5051edd25d8b3ef46e50e08c4148a27b3aa8a (patch)
treeb79ca80c9cd52b7c32c6d512c3aaaceee4f18037 /src
parent250b41e5280cc5a653bb15ffad6e800149b2a6ed (diff)
downloadrspamd-3ae5051edd25d8b3ef46e50e08c4148a27b3aa8a.tar.gz
rspamd-3ae5051edd25d8b3ef46e50e08c4148a27b3aa8a.zip
[Fix] Fix plugins intialisation in configwizard
Diffstat (limited to 'src')
-rw-r--r--src/lua/lua_config.c26
-rw-r--r--src/rspamadm/configdump.c1
-rw-r--r--src/rspamadm/rspamadm.c15
3 files changed, 41 insertions, 1 deletions
diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c
index f54411e88..37d122402 100644
--- a/src/lua/lua_config.c
+++ b/src/lua/lua_config.c
@@ -696,13 +696,20 @@ LUA_FUNCTION_DEF (config, experimental_enabled);
LUA_FUNCTION_DEF (config, load_ucl);
/***
- * @method rspamd_config:parce_rcl([skip_sections])
+ * @method rspamd_config:parse_rcl([skip_sections])
* Parses RCL using loaded ucl file
* @param {table|string} sections to skip
* @return true or false + error message
*/
LUA_FUNCTION_DEF (config, parse_rcl);
+/***
+ * @method rspamd_config:init_modules()
+ * Initialize lua and internal modules
+ * @return true or false
+ */
+LUA_FUNCTION_DEF (config, init_modules);
+
static const struct luaL_reg configlib_m[] = {
LUA_INTERFACE_DEF (config, get_module_opt),
LUA_INTERFACE_DEF (config, get_mempool),
@@ -763,6 +770,7 @@ static const struct luaL_reg configlib_m[] = {
LUA_INTERFACE_DEF (config, experimental_enabled),
LUA_INTERFACE_DEF (config, load_ucl),
LUA_INTERFACE_DEF (config, parse_rcl),
+ LUA_INTERFACE_DEF (config, init_modules),
{"__tostring", rspamd_lua_class_tostring},
{"__newindex", lua_config_newindex},
{NULL, NULL}
@@ -3388,6 +3396,22 @@ lua_config_parse_rcl (lua_State *L)
}
static gint
+lua_config_init_modules (lua_State *L)
+{
+ struct rspamd_config *cfg = lua_check_config (L, 1);
+
+ if (cfg != NULL) {
+ rspamd_lua_post_load_config (cfg);
+ lua_pushboolean (L, rspamd_init_filters (cfg, FALSE));
+ }
+ else {
+ return luaL_error (L, "invalid arguments");
+ }
+
+ return 1;
+}
+
+static gint
lua_monitored_alive (lua_State *L)
{
struct rspamd_monitored *m = lua_check_monitored (L, 1);
diff --git a/src/rspamadm/configdump.c b/src/rspamadm/configdump.c
index bd776e586..cd9f6d378 100644
--- a/src/rspamadm/configdump.c
+++ b/src/rspamadm/configdump.c
@@ -278,6 +278,7 @@ rspamadm_configdump (gint argc, gchar **argv, const struct rspamadm_command *cmd
(void) g_quark_from_static_string ((*pworker)->name);
pworker++;
}
+
cfg->cache = rspamd_symbols_cache_new (cfg);
cfg->compiled_modules = modules;
cfg->compiled_workers = workers;
diff --git a/src/rspamadm/rspamadm.c b/src/rspamadm/rspamadm.c
index a804d0059..eff27c1e9 100644
--- a/src/rspamadm/rspamadm.c
+++ b/src/rspamadm/rspamadm.c
@@ -33,6 +33,10 @@ GHashTable *ucl_vars = NULL;
struct rspamd_main *rspamd_main = NULL;
lua_State *L = NULL;
+/* Defined in modules.c */
+extern module_t *modules[];
+extern worker_t *workers[];
+
static void rspamadm_help (gint argc, gchar **argv, const struct rspamadm_command *);
static const char* rspamadm_help_help (gboolean full_help, const struct rspamadm_command *);
@@ -291,6 +295,7 @@ main (gint argc, gchar **argv, gchar **env)
const struct rspamadm_command *cmd;
GPtrArray *all_commands = g_ptr_array_new (); /* Discovered during check */
gint i, nargc, targc;
+ worker_t **pworker;
ucl_vars = g_hash_table_new_full (rspamd_strcase_hash,
rspamd_strcase_equal, g_free, g_free);
@@ -325,6 +330,16 @@ main (gint argc, gchar **argv, gchar **env)
rspamd_config_post_load (cfg,
RSPAMD_CONFIG_INIT_LIBS|RSPAMD_CONFIG_INIT_URL|RSPAMD_CONFIG_INIT_NO_TLD);
+ pworker = &workers[0];
+ while (*pworker) {
+ /* Init string quarks */
+ (void) g_quark_from_static_string ((*pworker)->name);
+ pworker++;
+ }
+
+ cfg->compiled_modules = modules;
+ cfg->compiled_workers = workers;
+
gperf_profiler_init (cfg, "rspamadm");
setproctitle ("rspamdadm");