]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Fix rspamd_update initialisation
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 28 Feb 2019 15:27:45 +0000 (15:27 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 28 Feb 2019 15:27:45 +0000 (15:27 +0000)
Issue: #2769
Closes: #2769
src/plugins/lua/rspamd_update.lua

index 51cb5db022a0c2400dfd3d0d12eed84dd121f041..d53d0211237f92ad528886badcc1533ee76b72bd 100644 (file)
@@ -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