}
else {
- if (!mod->module_config_func (cfg)) {
+ if (!mod->module_config_func (cfg, strict)) {
msg_err_config ("config of %s failed", mod->name);
ret = FALSE;
/* Initialization */
gint chartable_module_init (struct rspamd_config *cfg, struct module_ctx **ctx);
-gint chartable_module_config (struct rspamd_config *cfg);
+gint chartable_module_config (struct rspamd_config *cfg, bool validate);
gint chartable_module_reconfig (struct rspamd_config *cfg);
module_t chartable_module = {
gint
-chartable_module_config (struct rspamd_config *cfg)
+chartable_module_config (struct rspamd_config *cfg, bool validate)
{
const ucl_object_t *value;
gint res = TRUE;
gint
chartable_module_reconfig (struct rspamd_config *cfg)
{
- return chartable_module_config (cfg);
+ return chartable_module_config (cfg, false);
}
static gint latin_confusable[] = {
/* Initialization */
gint dkim_module_init (struct rspamd_config *cfg, struct module_ctx **ctx);
-gint dkim_module_config (struct rspamd_config *cfg);
+gint dkim_module_config (struct rspamd_config *cfg, bool validate);
gint dkim_module_reconfig (struct rspamd_config *cfg);
module_t dkim_module = {
}
gint
-dkim_module_config (struct rspamd_config *cfg)
+dkim_module_config (struct rspamd_config *cfg, bool validate)
{
const ucl_object_t *value;
gint res = TRUE, cb_id = -1;
NULL, RSPAMD_MAP_DEFAULT)) {
msg_warn_config ("cannot load dkim domains list from %s",
ucl_object_tostring (value));
+
+ if (validate) {
+ return FALSE;
+ }
}
else {
got_trusted = TRUE;
}
if (dkim_module_ctx->trusted_only && !got_trusted) {
- msg_err_config (
- "trusted_only option is set and no trusted domains are defined; disabling dkim module completely as it is useless in this case");
+ msg_err_config ("trusted_only option is set and no trusted domains are defined");
+ if (validate) {
+ return FALSE;
+ }
}
else {
if (!rspamd_config_is_module_enabled (cfg, "dkim")) {
gint
dkim_module_reconfig (struct rspamd_config *cfg)
{
- return dkim_module_config (cfg);
+ return dkim_module_config (cfg, false);
}
/*
/* Initialization */
gint fuzzy_check_module_init (struct rspamd_config *cfg,
struct module_ctx **ctx);
-gint fuzzy_check_module_config (struct rspamd_config *cfg);
+gint fuzzy_check_module_config (struct rspamd_config *cfg, bool valdate);
gint fuzzy_check_module_reconfig (struct rspamd_config *cfg);
static gint fuzzy_attach_controller (struct module_ctx *ctx,
GHashTable *commands);
}
gint
-fuzzy_check_module_config (struct rspamd_config *cfg)
+fuzzy_check_module_config (struct rspamd_config *cfg, bool validate)
{
const ucl_object_t *value, *cur, *elt;
ucl_object_iter_t it;
"table and not %s",
lua_typename (L, lua_type (L, -1)));
fuzzy_module_ctx->enabled = FALSE;
- } else {
+ }
+ else {
lua_pushstring (L, "process_rule");
lua_gettable (L, -2);
fuzzy_module_ctx->process_rule_ref);
}
- return fuzzy_check_module_config (cfg);
+ return fuzzy_check_module_config (cfg, false);
}
/* Finalize IO */
/* Initialization */
gint regexp_module_init (struct rspamd_config *cfg, struct module_ctx **ctx);
-gint regexp_module_config (struct rspamd_config *cfg);
+gint regexp_module_config (struct rspamd_config *cfg, bool validate);
gint regexp_module_reconfig (struct rspamd_config *cfg);
module_t regexp_module = {
}
gint
-regexp_module_config (struct rspamd_config *cfg)
+regexp_module_config (struct rspamd_config *cfg, bool validate)
{
struct regexp_ctx *regexp_module_ctx = regexp_get_context (cfg);
struct regexp_module_item *cur_item = NULL;
if (!read_regexp_expression (cfg->cfg_pool,
cur_item, ucl_object_key (value),
ucl_obj_tostring (value), &ud)) {
- res = FALSE;
+ if (validate) {
+ return FALSE;
+ }
}
else {
rspamd_symcache_add_symbol (cfg->cache,
if (!read_regexp_expression (cfg->cfg_pool,
cur_item, ucl_object_key (value),
ucl_obj_tostring (elt), &ud)) {
- res = FALSE;
+ if (validate) {
+ return FALSE;
+ }
}
else {
valid_expression = TRUE;
"mime_only attribute is not boolean for symbol: '%s'",
cur_item->symbol);
- res = FALSE;
+ if (validate) {
+ return FALSE;
+ }
}
else {
if (ucl_object_toboolean (elt)) {
"score attribute is not numeric for symbol: '%s'",
cur_item->symbol);
- res = FALSE;
+ if (validate) {
+ return FALSE;
+ }
}
else {
score = ucl_object_todouble (elt);
"one_shot attribute is not boolean for symbol: '%s'",
cur_item->symbol);
- res = FALSE;
+ if (validate) {
+ return FALSE;
+ }
}
else {
if (ucl_object_toboolean (elt)) {
"any_shot attribute is not boolean for symbol: '%s'",
cur_item->symbol);
- res = FALSE;
+ if (validate) {
+ return FALSE;
+ }
}
else {
if (ucl_object_toboolean (elt)) {
"nshots attribute is not numeric for symbol: '%s'",
cur_item->symbol);
- res = FALSE;
+ if (validate) {
+ return FALSE;
+ }
}
else {
nshots = ucl_object_toint (elt);
"one_param attribute is not boolean for symbol: '%s'",
cur_item->symbol);
- res = FALSE;
+ if (validate) {
+ return FALSE;
+ }
}
else {
if (ucl_object_toboolean (elt)) {
"priority attribute is not numeric for symbol: '%s'",
cur_item->symbol);
- res = FALSE;
+ if (validate) {
+ return FALSE;
+ }
}
else {
priority = ucl_object_toint (elt);
}
}
- msg_info_config ("init internal regexp module, %d regexp rules and %d "
- "lua rules are loaded", nre, nlua);
+ if (res) {
+ msg_info_config ("init internal regexp module, %d regexp rules and %d "
+ "lua rules are loaded", nre, nlua);
+ }
+ else {
+ msg_err_config ("fatal regexp module error");
+ }
return res;
}
gint
regexp_module_reconfig (struct rspamd_config *cfg)
{
- return regexp_module_config (cfg);
+ return regexp_module_config (cfg, false);
}
static gboolean
rspamd_lua_post_load_config (cfg);
if (init_modules) {
- rspamd_init_filters (cfg, reload, false);
+ if (!rspamd_init_filters (cfg, reload, false)) {
+ return FALSE;
+ }
}
/* Do post-load actions */
- rspamd_config_post_load (cfg, opts);
+ if (!rspamd_config_post_load (cfg, opts)) {
+ return FALSE;
+ }
}
return TRUE;
int (*module_init_func) (struct rspamd_config *cfg, struct module_ctx **ctx);
- int (*module_config_func) (struct rspamd_config *cfg);
+ int (*module_config_func) (struct rspamd_config *cfg, bool validate);
int (*module_reconfig_func) (struct rspamd_config *cfg);