commit a7d4b16: [Minor] Fix rspamd_update initialisation

Vsevolod Stakhov vsevolod at highsecure.ru
Thu Feb 28 15:35:03 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-02-28 15:27:45 +0000
URL: https://github.com/rspamd/rspamd/commit/a7d4b165ac8cf311907acf95b3d87c1c2cab12d2 (HEAD -> master)

[Minor] Fix rspamd_update initialisation
Issue: #2769
Closes: #2769

---
 src/plugins/lua/rspamd_update.lua | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

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


More information about the Commits mailing list