]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Store plugins state
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 3 Dec 2017 13:36:32 +0000 (13:36 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 3 Dec 2017 16:55:30 +0000 (16:55 +0000)
33 files changed:
.luacheckrc
lualib/rspamadm/configwizard.lua
src/plugins/lua/antivirus.lua
src/plugins/lua/arc.lua
src/plugins/lua/asn.lua
src/plugins/lua/bayes_expiry.lua
src/plugins/lua/clickhouse.lua
src/plugins/lua/dcc.lua
src/plugins/lua/dkim_signing.lua
src/plugins/lua/dynamic_conf.lua
src/plugins/lua/emails.lua
src/plugins/lua/fann_redis.lua
src/plugins/lua/greylist.lua
src/plugins/lua/hfilter.lua
src/plugins/lua/history_redis.lua
src/plugins/lua/ip_score.lua
src/plugins/lua/metadata_exporter.lua
src/plugins/lua/metric_exporter.lua
src/plugins/lua/mid.lua
src/plugins/lua/mime_types.lua
src/plugins/lua/multimap.lua
src/plugins/lua/mx_check.lua
src/plugins/lua/ratelimit.lua
src/plugins/lua/rbl.lua
src/plugins/lua/replies.lua
src/plugins/lua/reputation.lua
src/plugins/lua/rspamd_update.lua
src/plugins/lua/spamassassin.lua
src/plugins/lua/trie.lua
src/plugins/lua/url_redirector.lua
src/plugins/lua/url_reputation.lua
src/plugins/lua/url_tags.lua
src/plugins/lua/whitelist.lua

index 6c76da58fff269305586d230c020edadcd22f0ee..57a9c558264b37f210b165b947087e500c02650f 100644 (file)
@@ -24,7 +24,9 @@ globals = {
   'rspamd_str_split',
   'rspamd_version',
   'rspamd_map_add',
-  'rspamd_maps'
+  'rspamd_maps',
+  'rspamd_plugins_state',
+  'rspamadm',
 }
 
 ignore = {
index 31cdfdcac7c42208f0d95ce12ab1be9d93248468..5757e50f35c002c683e58b6a20e3d77706406503 100644 (file)
@@ -20,12 +20,6 @@ local rspamd_util = require "rspamd_util"
 local rspamd_logger = require "rspamd_logger"
 local lua_util = require "lua_util"
 
-local function is_implicit(t)
-  local mt = getmetatable(t)
-
-  return mt and mt.class and mt.class == 'ucl.type.impl_array'
-end
-
 local function printf(fmt, ...)
   print(string.format(fmt, ...))
 end
index baa876d4e3b1bc07076ec4bef1a567935d799c89..6120cb41f340feede4efa9f1ee2c3bc90b323c3c 100644 (file)
@@ -19,6 +19,7 @@ local rspamd_util = require "rspamd_util"
 local rspamd_regexp = require "rspamd_regexp"
 local tcp = require "rspamd_tcp"
 local upstream_list = require "rspamd_upstream_list"
+local lua_util = require "lua_util"
 local redis_params
 
 local N = "antivirus"
@@ -802,6 +803,7 @@ end
 local opts = rspamd_config:get_all_opt('antivirus')
 if opts and type(opts) == 'table' then
   redis_params = rspamd_parse_redis_server('antivirus')
+  local has_valid = false
   for k, m in pairs(opts) do
     if type(m) == 'table' and m['type'] and m['servers'] then
       local cb = add_antivirus_rule(k, m)
@@ -813,6 +815,7 @@ if opts and type(opts) == 'table' then
           name = m['symbol'],
           callback = cb,
         })
+        has_valid = true
         if type(m['patterns']) == 'table' then
           if m['patterns'][1] then
             for _, p in ipairs(m['patterns']) do
@@ -856,4 +859,9 @@ if opts and type(opts) == 'table' then
       end
     end
   end
+
+  if not has_valid then
+    lua_util.disable_module(N, 'config')
+  end
 end
+
index fc101b0f75cf550c49351863f749443cabd912de..46e361f2da961a34d95c15404d0f9980c1c26dfc 100644 (file)
@@ -555,6 +555,7 @@ end
 if not (settings.use_redis or settings.path or
     settings.domain or settings.path_map or settings.selector_map) then
   rspamd_logger.infox(rspamd_config, 'mandatory parameters missing, disable arc signing')
+  lua_util.disable_module(N, "fail")
   return
 end
 
@@ -562,7 +563,8 @@ if settings.use_redis then
   redis_params = rspamd_parse_redis_server('arc')
 
   if not redis_params then
-    rspamd_logger.errx(rspamd_config, 'no servers are specified, but module is configured to load keys from redis, disable dkim signing')
+    rspamd_logger.errx(rspamd_config, 'no servers are specified, but module is configured to load keys from redis, disable arc signing')
+    lua_util.disable_module(N, "config")
     return
   end
 end
index 0d103fc1022a88133efd694115ce6fc6f548dacb..a125b99c19a71371cdc7d1875d0caa13b6fa222b 100644 (file)
@@ -17,6 +17,8 @@ limitations under the License.
 
 local rspamd_logger = require "rspamd_logger"
 local rspamd_regexp = require "rspamd_regexp"
+local lua_util = require "lua_util"
+local N = "asn"
 
 if confighelp then
   return
@@ -114,4 +116,6 @@ if configure_asn_module() then
       type = 'virtual'
     })
   end
+else
+  lua_util.disable_module(N, 'config')
 end
index 674727e42e4c4ced78d9594c660231e558dc0967..d922f3f55839003872cb8d7eb3a03651e7273cea 100644 (file)
@@ -91,7 +91,10 @@ local function configure_bayes_expiry()
   return true
 end
 
-if not configure_bayes_expiry() then return end
+if not configure_bayes_expiry() then
+  lutil.disable_module(N, 'config')
+  return
+end
 
 local function get_redis_params(ev_base, symbol)
   local redis_params
index cfa06672888d8960ee3bfe2c37250b4f6b9fe0ed..84a479b46d7d4d1a3d14ca41ab748b51ca428485 100644 (file)
@@ -18,6 +18,7 @@ local rspamd_logger = require 'rspamd_logger'
 local rspamd_http = require "rspamd_http"
 local rspamd_lua_utils = require "lua_util"
 local upstream_list = require "rspamd_upstream_list"
+local N = "clickhouse"
 
 if confighelp then
   return
@@ -653,6 +654,7 @@ if opts then
 
     if not settings['server'] and not settings['servers'] then
       rspamd_logger.infox(rspamd_config, 'no servers are specified, disabling module')
+      rspamd_lua_utils.disable_module(N, "config")
     else
       settings['from_map'] = rspamd_map_add('clickhouse', 'from_tables',
         'regexp', 'clickhouse specific domains')
@@ -666,6 +668,7 @@ if opts then
       if not settings.upstream then
         rspamd_logger.errx('cannot parse clickhouse address: %s',
             settings['server'] or settings['servers'])
+        rspamd_lua_utils.disable_module(N, "config")
         return
       end
 
index 503dcce7cd6c05c05d52b62bcbc0a7f0562f25aa..131c83d369d5494e4a04b0903a58d89feee3ca33 100644 (file)
@@ -23,6 +23,7 @@ local opts = rspamd_config:get_all_opt(N)
 local logger = require "rspamd_logger"
 local tcp = require "rspamd_tcp"
 local fun = require "fun"
+local lua_util = require "lua_util"
 
 if confighelp then
   rspamd_config:add_example(nil, 'dcc',
@@ -139,5 +140,6 @@ if opts and opts['host'] then
     name = symbol_bulk
   })
 else
+  lua_util.disable_module(N, "config")
   logger.infox('DCC module not configured');
 end
index 341cddc94e637156ff0df1af3cc305bbe889c242..75720df9dad11ab0beff199f81813b97e875029c 100644 (file)
@@ -142,6 +142,7 @@ for k,v in pairs(opts) do
 end
 if not (settings.use_redis or settings.path or settings.domain or settings.path_map or settings.selector_map) then
   rspamd_logger.infox(rspamd_config, 'mandatory parameters missing, disable dkim signing')
+  lutil.disable_module(N, "config")
   return
 end
 if settings.use_redis then
@@ -149,6 +150,7 @@ if settings.use_redis then
 
   if not redis_params then
     rspamd_logger.errx(rspamd_config, 'no servers are specified, but module is configured to load keys from redis, disable dkim signing')
+    lutil.disable_module(N, "redis")
     return
   end
 end
index 9c017d6c9d5bfac1ab63f18dfd8e4b6fd13aa335..0ddad354ca653b8f4231a5f0377f3a5a9ffec4f6 100644 (file)
@@ -18,6 +18,8 @@ local rspamd_logger = require "rspamd_logger"
 local redis_params
 local ucl = require "ucl"
 local fun = require "fun"
+local lua_util = require "lua_util"
+local N = "dynamic_conf"
 
 if confighelp then
   return
@@ -359,4 +361,5 @@ if redis_params then
     add_symbol = add_dynamic_symbol,
     add_action = add_dynamic_action,
   }
+  lua_util.disable_module(N, "redis")
 end
index aeb2bc7cdfe8f179d16cc174227e4387ab9de471..65e6b433e15c8236781e45d47d8d3fe00377d757 100644 (file)
@@ -201,4 +201,6 @@ if #rules > 0 then
       callback = cb,
     })
   end
+else
+  rspamd_lua_utils.disable_module(N, "conf")
 end
index 3a435c321182e306699a21f9dde7cdc29406b0e9..2b9b06f28dbbdff2e0161e9413486d0ea01b4f04 100644 (file)
@@ -25,11 +25,13 @@ local rspamd_logger = require "rspamd_logger"
 local rspamd_fann = require "rspamd_fann"
 local rspamd_util = require "rspamd_util"
 local rspamd_redis = require "lua_redis"
+local lua_util = require "lua_util"
 local fun = require "fun"
 local meta_functions = require "meta_functions"
 local use_torch = false
 local torch
 local nn
+local N = "fann_redis"
 
 if rspamd_config:has_torch() then
   use_torch = true
@@ -1078,12 +1080,14 @@ redis_params = rspamd_parse_redis_server('fann_redis')
 -- Initialization part
 if not (opts and type(opts) == 'table') or not redis_params then
   rspamd_logger.infox(rspamd_config, 'Module is unconfigured')
+  lua_util.disable_module(N, "redis")
   return
 end
 
 if not rspamd_fann.is_enabled() then
   rspamd_logger.errx(rspamd_config, 'fann is not compiled in rspamd, this ' ..
     'module is eventually disabled')
+  lua_util.disable_module(N, "fail")
   return
 else
   local rules = opts['rules']
index 11ab2a2ded8054738350455cd3fb935d6b0ead14..9e42f4482a4772f49185600ed6dcd53f0f8047db 100644 (file)
@@ -63,6 +63,7 @@ local rspamd_util = require "rspamd_util"
 local fun = require "fun"
 local hash = require "rspamd_cryptobox_hash"
 local rspamd_lua_utils = require "lua_util"
+local N = "greylist"
 
 local function data_key(task)
   local cached = task:get_mempool():get_variable("grey_bodyhash")
@@ -426,6 +427,7 @@ if opts then
   redis_params = rspamd_parse_redis_server('greylist')
   if not redis_params then
     rspamd_logger.infox(rspamd_config, 'no servers are specified, disabling module')
+    rspamd_lua_utils.disable_module(N, "redis")
   else
     rspamd_config:register_symbol({
       name = 'GREYLIST_SAVE',
index 6f3322ecf9cdc67d1acc933321efcdb36a4b1cd7..0b82357198c26e7a15bee4114bafc45079a2d06f 100644 (file)
@@ -25,6 +25,7 @@ end
 
 local rspamd_logger = require "rspamd_logger"
 local rspamd_regexp = require "rspamd_regexp"
+local lua_util = require "lua_util"
 local rspamc_local_helo = "rspamc.local"
 local checks_hellohost = [[
 /[0-9][.-]?nat/i 5
@@ -623,4 +624,6 @@ end
 --dumper(symbols_enabled)
 if #symbols_enabled > 0 then
   rspamd_config:register_symbols(hfilter, 1.0, "HFILTER", symbols_enabled);
+else
+  lua_util.disable_module(N, "config")
 end
index 13d6aafe59667f79bddf23b4a92706910404d217..a876b46e75241e12a20cc6d5150921cc9917ca7f 100644 (file)
@@ -28,9 +28,11 @@ local settings = {
 
 local rspamd_logger = require "rspamd_logger"
 local rspamd_util = require "rspamd_util"
+local lua_util = require "lua_util"
 local fun = require "fun"
 local ucl = require("ucl")
 local E = {}
+local N = "history_redis"
 local hostname = rspamd_util.get_hostname()
 
 local function process_addr(addr)
@@ -216,6 +218,7 @@ if opts then
   redis_params = rspamd_parse_redis_server('history_redis')
   if not redis_params then
     rspamd_logger.infox(rspamd_config, 'no servers are specified, disabling module')
+    lua_util.disable_module(N, "redis")
   else
     rspamd_config:register_symbol({
       name = 'HISTORY_SAVE',
index e2bd58da51afa31ee51f5b410fe3be925dc82e55..bd64ba48ff42d2c913b77249d44a6c3c8098c3e0 100644 (file)
@@ -30,6 +30,7 @@ local asn_cc_whitelist = nil
 local check_authed = false
 local check_local = false
 local M = "ip_score"
+local N = M
 
 local options = {
   actions = { -- how each action is treated in scoring
@@ -388,4 +389,6 @@ if redis_params then
     name = options['symbol'],
     callback = ip_score_check,
   })
+else
+  rspamd_lua_utils.disable_module(N, "redis")
 end
index 90ec8a4fd67293e7ca60958fcdd836aecfa3b0ae..7d2d531484c1ba6b4fcaa86023847282813ae9c6 100644 (file)
@@ -688,6 +688,7 @@ end
 
 if not next(settings.rules) then
   rspamd_logger.errx(rspamd_config, 'No rules enabled')
+  lutil.disable_module(N, "config")
 end
 for k, r in pairs(settings.rules) do
   rspamd_config:register_symbol({
index d104c4b9b0be063689a3de0d42e5a09ed290443c..efb50d586fea23f58955b43164dfe56f5613baa9 100644 (file)
@@ -24,6 +24,7 @@ local logger = require "rspamd_logger"
 local mempool = require "rspamd_mempool"
 local util = require "rspamd_util"
 local tcp = require "rspamd_tcp"
+local lua_util = require "lua_util"
 
 local pool = mempool.create()
 local settings = {
@@ -166,7 +167,10 @@ local function configure_metric_exporter()
   return backends[be]['configure']()
 end
 
-if not configure_metric_exporter() then return end
+if not configure_metric_exporter() then
+  lua_util.disable_module(N, "config")
+  return
+end
 
 rspamd_config:add_on_load(function (_, ev_base, worker)
   -- Exit unless we're the first 'controller' worker
index 19c85dac0a0c7137200f2c4016bf45a16cace8af..e1dd9ed5d1fbcbbf5059f1caa326346ad58f65a4 100644 (file)
@@ -25,6 +25,8 @@ end
 
 local rspamd_logger = require "rspamd_logger"
 local rspamd_regexp = require "rspamd_regexp"
+local lua_util = require "lua_util"
+local N = "mid"
 
 local settings = {
   url = '',
@@ -97,5 +99,6 @@ if opts then
     rspamd_config:register_dependency(id, settings['symbol_dkim_allow'])
   else
     rspamd_logger.infox(rspamd_config, 'source is not specified, disabling module')
+    lua_util.disable_module(N, "config")
   end
 end
index 4fa43f09fd751a66faf5ac447db7d461cee72194..a93b5889c9f8d040a9f533d1208dcfa250a79877 100644 (file)
@@ -20,6 +20,8 @@ end
 
 -- This plugin implements mime types checks for mail messages
 local logger = require "rspamd_logger"
+local lua_util = require "lua_util"
+local N = "mime_types"
 local settings = {
   file = '',
   symbol_unknown = 'MIME_UNKNOWN',
@@ -313,5 +315,7 @@ if opts then
       name = settings['symbol_bad_extension'],
       parent = id
     })
+  else
+    lua_util.disable_module(N, "config")
   end
 end
index 407a943bc4482939783187449e622aaa4a2a7092..584978453aa34b05fb279cb15023739b0a77c014 100644 (file)
@@ -27,6 +27,7 @@ local util = require "rspamd_util"
 local regexp = require "rspamd_regexp"
 local rspamd_expression = require "rspamd_expression"
 local rspamd_ip = require "rspamd_ip"
+local lua_util = require "lua_util"
 local redis_params
 local fun = require "fun"
 local N = 'multimap'
@@ -1104,4 +1105,8 @@ if opts and type(opts) == 'table' then
     })
   end,
   fun.filter(function(r) return r['prefilter'] end, rules))
+
+  if #rules == 0 then
+    lua_util.disable_module(N, "config")
+  end
 end
index 3e43b4a9a39fce1ebd227f77b7e7e314a78f6371..b30f1293b2ef2985c98d842d34e0d65bae4125d2 100644 (file)
@@ -22,6 +22,8 @@ end
 local rspamd_logger = require "rspamd_logger"
 local rspamd_tcp = require "rspamd_tcp"
 local rspamd_util = require "rspamd_util"
+local lua_util = require "lua_util"
+local N = "mx_check"
 local fun = require "fun"
 
 local settings = {
@@ -268,6 +270,7 @@ if opts then
   redis_params = rspamd_parse_redis_server('mx_check')
   if not redis_params then
     rspamd_logger.errx(rspamd_config, 'no redis servers are specified, disabling module')
+    lua_util.disable_module(N, "redis")
     return
   end
   for k,v in pairs(opts) do
index 33c38c4db80ed9ed00514cd0496c7ad7e79a1212..f77e2ae767962b333ba6100d72c65e37dee4b630 100644 (file)
@@ -729,6 +729,7 @@ if opts then
   redis_params = rspamd_parse_redis_server('ratelimit')
   if not redis_params then
     rspamd_logger.infox(rspamd_config, 'no servers are specified, disabling module')
+    lua_util.disable_module(N, "redis")
   else
     local s = {
       type = 'prefilter,nostat',
index 55f2bffea216630f96a38e353f0b265b8a9acd12..59d1de2d54d911abf8251515dd257329cb64b453 100644 (file)
@@ -33,6 +33,7 @@ local hash = require 'rspamd_cryptobox_hash'
 local rspamd_logger = require 'rspamd_logger'
 local rspamd_util = require 'rspamd_util'
 local fun = require 'fun'
+local lua_util = require 'lua_util'
 local default_monitored = '1.0.0.127'
 
 local symbols = {
@@ -417,6 +418,7 @@ end
 local opts = rspamd_config:get_all_opt(N)
 if not (opts and type(opts) == 'table') then
   rspamd_logger.infox(rspamd_config, 'Module is unconfigured')
+  lua_util.disable_module(N, "config")
   return
 end
 
@@ -564,6 +566,11 @@ for key,rbl in pairs(opts['rbls']) do
     end
   end)()
 end
+
+if #opts.rbls == 0 then
+  lua_util.disable_module(N, "config")
+end
+
 for _, w in pairs(white_symbols) do
   for _, b in pairs(black_symbols) do
     local csymbol = 'RBL_COMPOSITE_' .. w .. '_' .. b
index 99d13db7b73c7530581f983bf8e7922771cce2b5..5c17efa59e3ea1871a1b13030f1d1b3f74806f0a 100644 (file)
@@ -34,6 +34,8 @@ local settings = {
 
 local rspamd_logger = require 'rspamd_logger'
 local hash = require 'rspamd_cryptobox_hash'
+local lua_util = require 'lua_util'
+local N = "replies"
 
 local function make_key(goop)
   local h = hash.create()
@@ -125,6 +127,7 @@ if opts then
   redis_params = rspamd_parse_redis_server('replies')
   if not redis_params then
     rspamd_logger.infox(rspamd_config, 'no servers are specified, disabling module')
+    lua_util.disable_module(N, "redis")
   else
     rspamd_config:register_symbol({
       name = 'REPLIES_SET',
index 8ff53f09beb65a18c6ce992cf477319b0bd3b8eb..e7349e445aed265e47ed19e8070a2c99cb375884 100644 (file)
@@ -945,4 +945,6 @@ if opts['rules'] then
       parse_rule(k, v)
     end
   end
+else
+  lua_util.disable_module(N, "config")
 end
index fa768a0e76cfa7f5d2d890033f2726015b71a506..4eadc027a361c8e55feac14689f57403509f7164 100644 (file)
@@ -25,6 +25,8 @@ local fun = require "fun"
 local rspamd_logger = require "rspamd_logger"
 local rspamd_config = rspamd_config
 local hash = require "rspamd_cryptobox_hash"
+local lua_util = require "lua_util"
+local N = "rspamd_update"
 local rspamd_version = rspamd_version
 local maps = {}
 
@@ -149,4 +151,5 @@ if section then
   end, maps)
 else
   rspamd_logger.infox(rspamd_config, 'Module is unconfigured')
+  lua_util.disable_module(N, "config")
 end
index ab97accb767c23667b7fa2a512a1223b39ecb35d..649abc51f12b8cabfd0c31e67c9a12da73280f79 100644 (file)
@@ -29,6 +29,7 @@ local rspamd_regexp = require "rspamd_regexp"
 local rspamd_expression = require "rspamd_expression"
 local rspamd_trie = require "rspamd_trie"
 local util = require "rspamd_util"
+local lua_util = require "lua_util"
 local fun = require "fun"
 
 -- Known plugins
@@ -1647,4 +1648,6 @@ end
 
 if has_rules then
   post_process()
+else
+  lua_util.disable_module(N, "config")
 end
index 2794e80c890a5612cd0011d1c68eab61bf8effdd..796cd789ac6ef69a6a7ec854948b27a46e4c16e7 100644 (file)
@@ -24,6 +24,7 @@ local N = 'trie'
 local rspamd_logger = require "rspamd_logger"
 local rspamd_trie = require "rspamd_trie"
 local fun = require "fun"
+local lua_util = require "lua_util"
 
 local mime_trie
 local raw_trie
@@ -176,4 +177,5 @@ if opts then
   end
 else
   rspamd_logger.infox(rspamd_config, "Module is unconfigured")
+  lua_util.disable_module(N, "config")
 end
index aefaf2d754f6698d24512f45c9097c450b9e89e4..d0984bd1529c51f2861c1f577ae638f5753f642d 100644 (file)
@@ -49,6 +49,7 @@ local settings = {
 local rspamd_logger = require "rspamd_logger"
 local rspamd_http = require "rspamd_http"
 local hash = require "rspamd_cryptobox_hash"
+local lua_util = require "lua_util"
 
 local function cache_url(task, orig_url, url, key, param)
   local function redis_trim_cb(err, data)
@@ -271,11 +272,13 @@ if opts then
   redis_params = rspamd_parse_redis_server('url_redirector')
   if not redis_params then
     rspamd_logger.infox(rspamd_config, 'no servers are specified, disabling module')
+    lua_util.disable_module(N, "redis")
   else
     if rspamd_plugins.surbl then
       rspamd_plugins.surbl.register_redirect(url_redirector_handler)
     else
       rspamd_logger.infox(rspamd_config, 'surbl module is not enabled, disabling module')
+      lua_util.disable_module(N, "fail")
     end
   end
 end
index 5c5dee14ec53e9d62ca35a7b70af658854a64dd6..9dbb40320ee6c12a44af1ddc76f8bfb85666e68e 100644 (file)
@@ -63,6 +63,7 @@ local scale = {
 
 local rspamd_logger = require "rspamd_logger"
 local rspamd_util = require "rspamd_util"
+local lua_util = require "lua_util"
 
 -- This function is used for taskless redis requests (to load scripts)
 local function redis_make_request(ev_base, cfg, key, is_write, callback, command, args)
@@ -407,6 +408,7 @@ if not opts then return end
 redis_params = rspamd_parse_redis_server(N)
 if not redis_params then
   rspamd_logger.warnx(rspamd_config, 'no servers are specified, disabling module')
+  lua_util.disable_module(N, "redis")
   return
 end
 for k, v in pairs(opts) do
@@ -427,6 +429,7 @@ for k, v in pairs(opts) do
 end
 if settings.threshold < 1 then
   rspamd_logger.errx(rspamd_config, 'threshold should be >= 1, disabling module')
+  lua_util.disable_module(N, "config")
   return
 end
 
index 9aa64e1f4ab8de715b3aea36d3df8ecbdb25b6be..1281cc2fc0c3be0d9b2b69c8af6409cffc0af0ac 100644 (file)
@@ -35,6 +35,7 @@ local settings = {
 
 local rspamd_logger = require "rspamd_logger"
 local rspamd_util = require "rspamd_util"
+local lua_util = require "lua_util"
 local ucl = require "ucl"
 
 -- This function is used for taskless redis requests (to load scripts)
@@ -350,6 +351,7 @@ local opts = rspamd_config:get_all_opt(N)
 if not opts then return end
 redis_params = rspamd_parse_redis_server(N)
 if not redis_params then
+  lua_util.disable_module(N, "redis")
   rspamd_logger.warnx(rspamd_config, 'no servers are specified, disabling module')
   return
 end
index c7d5a498f1a213901fda7dc743915d4e2635c595..8155547662bb70198c0f6229985792ad4014971f 100644 (file)
@@ -21,6 +21,9 @@ end
 local rspamd_logger = require "rspamd_logger"
 local rspamd_util = require "rspamd_util"
 local fun = require "fun"
+local lua_util = require "lua_util"
+
+local N = "whitelist"
 
 local options = {
   dmarc_allow_symbol = 'DMARC_POLICY_ALLOW',
@@ -287,6 +290,8 @@ local configure_whitelist_module = function()
         end
       end
     end, options['rules'])
+  else
+    lua_util.disable_module(N, "config")
   end
 end