exports.disable_module = disable_module
+--[[[
+-- @function lua_util.push_config_error(module, err)
+-- Pushes a configuration error to the state
+-- @param {string} module name of module
+-- @param {string} err error string
+--]]
+local function push_config_error(module, err)
+ if not rspamd_plugins_state.config_errors then
+ rspamd_plugins_state.config_errors = {}
+ end
+
+ if not rspamd_plugins_state.config_errors[module] then
+ rspamd_plugins_state.config_errors[module] = {}
+ end
+
+ table.insert(rspamd_plugins_state.config_errors[module], err)
+end
+
+exports.push_config_error = push_config_error
+
--[[[
-- @function lua_util.disable_module(modname)
-- Checks experimental plugins state and disable if needed
if not cb then
rspamd_logger.errx(rspamd_config, 'cannot add rule: "' .. k .. '"')
+ lua_util.push_config_error(N, 'cannot add AV rule: "' .. k .. '"')
else
rspamd_logger.infox(rspamd_config, 'added antivirus engine %s -> %s', k, m.symbol)
local t = {
if not res then
rspamd_logger.warnx(rspamd_config, 'plugin is misconfigured: %s', err)
- lua_util.disable_module(N, "config")
+ local err_msg = string.format("schema error: %s", res)
+ lua_util.push_config_error(N, err_msg)
+ lua_util.disable_module(N, "failed", err_msg)
return
end
for k, v in pairs(opts['rules']) do
if not ((v or E).selector) then
rspamd_logger.errx(rspamd_config, "no selector defined for rule %s", k)
+ lua_util.push_config_error(N, "no selector defined for rule: " .. k)
else
- parse_rule(k, v)
+ if not parse_rule(k, v) then
+ lua_util.push_config_error(N, "reputation rule is misconfigured: " .. k)
+ end
end
end
else