mirror of
https://github.com/rspamd/rspamd.git
synced 2024-09-13 23:56:50 +02:00
[Fix] Fix plugins intialisation in configwizard
This commit is contained in:
parent
250b41e528
commit
3ae5051edd
@ -625,6 +625,11 @@ return {
|
||||
os.exit(1)
|
||||
end
|
||||
|
||||
if not rspamd_config:init_modules() then
|
||||
rspamd_logger.errx('cannot init modules when parsing %s', opts['config'])
|
||||
os.exit(1)
|
||||
end
|
||||
|
||||
if #args > 0 then
|
||||
interactive_start = false
|
||||
|
||||
|
@ -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}
|
||||
@ -3387,6 +3395,22 @@ lua_config_parse_rcl (lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -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");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user