From: Vsevolod Stakhov Date: Thu, 28 Feb 2019 15:27:45 +0000 (+0000) Subject: [Minor] Fix rspamd_update initialisation X-Git-Tag: 1.9.0~72 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a7d4b165ac8cf311907acf95b3d87c1c2cab12d2;p=rspamd.git [Minor] Fix rspamd_update initialisation Issue: #2769 Closes: #2769 --- diff --git a/src/plugins/lua/rspamd_update.lua b/src/plugins/lua/rspamd_update.lua index 51cb5db02..d53d02112 100644 --- a/src/plugins/lua/rspamd_update.lua +++ b/src/plugins/lua/rspamd_update.lua @@ -124,21 +124,25 @@ end -- Configuration part local section = rspamd_config:get_all_opt("rspamd_update") -if section then +if section and section.rules then local trusted_key - fun.each(function(k, elt) - if k == 'key' then - trusted_key = elt + if section.key then + trusted_key = section.key + end + + if type(section.rules) ~= 'table' then + section.rules = {section.rules} + end + + fun.each(function(elt) + local map = rspamd_config:add_map(elt, "rspamd updates map", nil, "callback") + if not map then + rspamd_logger.errx(rspamd_config, 'cannot load updates from %1', elt) else - local map = rspamd_config:add_map(elt, "rspamd updates map", nil, "callback") - if not map then - rspamd_logger.errx(rspamd_config, 'cannot load updates from %1', elt) - else - map:set_callback(gen_callback(map)) - maps['elt'] = map - end + map:set_callback(gen_callback(map)) + maps['elt'] = map end - end, section) + end, section.rules) fun.each(function(k, map) -- Check sanity for maps