浏览代码

Add conditional enabling of modules.

tags/1.0.0
Vsevolod Stakhov 8 年前
父节点
当前提交
d9c16b50a4

+ 10
- 1
src/libserver/cfg_rcl.c 查看文件

@@ -795,7 +795,7 @@ rspamd_rcl_add_module_path (struct rspamd_config *cfg,
struct stat st;
struct script_module *cur_mod;
glob_t globbuf;
gchar *pattern;
gchar *pattern, *ext_pos;
size_t len;
guint i;

@@ -823,6 +823,15 @@ rspamd_rcl_add_module_path (struct rspamd_config *cfg,
sizeof (struct script_module));
cur_mod->path = rspamd_mempool_strdup (cfg->cfg_pool,
globbuf.gl_pathv[i]);
cur_mod->name = g_path_get_basename (cur_mod->path);
rspamd_mempool_add_destructor (cfg->cfg_pool, g_free,
cur_mod->name);
ext_pos = strstr (cur_mod->name, ".lua");

if (ext_pos != NULL) {
*ext_pos = '\0';
}

cfg->script_modules = g_list_prepend (cfg->script_modules,
cur_mod);
}

+ 3
- 10
src/libserver/cfg_utils.c 查看文件

@@ -1059,15 +1059,8 @@ rspamd_config_is_module_enabled (struct rspamd_config *cfg,
conf = ucl_object_find_key (cfg->rcl_obj, module_name);

if (conf == NULL) {
if (is_c) {
msg_info ("internal module %s is enabled but has not configured",
module_name);
}
else {
msg_info ("lua module %s is disabled as it has not configured",
module_name);
return FALSE;
}
msg_info ("%s module %s is enabled but has not been configured",
is_c ? "internal" : "lua", module_name);
}
else {
enabled = ucl_object_find_key (conf, "enabled");
@@ -1087,7 +1080,7 @@ rspamd_config_is_module_enabled (struct rspamd_config *cfg,
if (gr) {
if (gr->disabled) {
msg_info ("%s module %s is disabled in the configuration as "
"its group is disabled",
"its group has been disabled",
is_c ? "internal" : "lua", module_name);
return FALSE;
}

+ 5
- 0
src/lua/lua_common.c 查看文件

@@ -294,6 +294,11 @@ rspamd_init_lua_filters (struct rspamd_config *cfg)
while (cur) {
module = cur->data;
if (module->path) {
if (!rspamd_config_is_module_enabled (cfg, module->name)) {
cur = g_list_next (cur);
continue;
}

if (luaL_loadfile (L, module->path) != 0) {
msg_info ("load of %s failed: %s", module->path,
lua_tostring (L, -1));

+ 4
- 0
src/plugins/chartable.c 查看文件

@@ -82,6 +82,10 @@ chartable_module_config (struct rspamd_config *cfg)
const ucl_object_t *value;
gint res = TRUE;

if (!rspamd_config_is_module_enabled (cfg, "chartable")) {
return TRUE;
}

if ((value =
rspamd_config_get_module_opt (cfg, "chartable", "symbol")) != NULL) {
chartable_module_ctx->symbol = ucl_obj_tostring (value);

+ 4
- 0
src/plugins/dkim_check.c 查看文件

@@ -116,6 +116,10 @@ dkim_module_config (struct rspamd_config *cfg)
guint cache_size, cache_expire;
gboolean got_trusted = FALSE;

if (!rspamd_config_is_module_enabled (cfg, "dkim")) {
return TRUE;
}

dkim_module_ctx->whitelist_ip = radix_create_compressed ();

if ((value =

+ 4
- 0
src/plugins/fuzzy_check.c 查看文件

@@ -417,6 +417,10 @@ fuzzy_check_module_config (struct rspamd_config *cfg)
const ucl_object_t *value, *cur;
gint res = TRUE, cb_id;

if (!rspamd_config_is_module_enabled (cfg, "fuzzy_check")) {
return TRUE;
}

if ((value =
rspamd_config_get_module_opt (cfg, "fuzzy_check", "symbol")) != NULL) {
fuzzy_module_ctx->default_symbol = ucl_obj_tostring (value);

+ 4
- 0
src/plugins/regexp.c 查看文件

@@ -114,6 +114,10 @@ regexp_module_config (struct rspamd_config *cfg)
ucl_object_iter_t it = NULL;
gint res = TRUE;

if (!rspamd_config_is_module_enabled (cfg, "regexp")) {
return TRUE;
}

sec = ucl_object_find_key (cfg->rcl_obj, "regexp");
if (sec == NULL) {
msg_err ("regexp module enabled, but no rules are defined");

+ 4
- 0
src/plugins/spf.c 查看文件

@@ -108,6 +108,10 @@ spf_module_config (struct rspamd_config *cfg)
gint res = TRUE, cb_id;
guint cache_size, cache_expire;

if (!rspamd_config_is_module_enabled (cfg, "spf")) {
return TRUE;
}

spf_module_ctx->whitelist_ip = radix_create_compressed ();

if ((value =

+ 4
- 0
src/plugins/surbl.c 查看文件

@@ -346,6 +346,10 @@ surbl_module_config (struct rspamd_config *cfg)
gint cb_id;
gboolean has_subsymbols;

if (!rspamd_config_is_module_enabled (cfg, "surbl")) {
return TRUE;
}

if ((value =
rspamd_config_get_module_opt (cfg, "surbl", "redirector")) != NULL) {
surbl_module_ctx->redirectors = rspamd_upstreams_create ();

正在加载...
取消
保存