]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Compat: Allow to use old style sign_condition
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 31 May 2019 15:40:52 +0000 (16:40 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 31 May 2019 15:40:52 +0000 (16:40 +0100)
lualib/lua_cfg_transform.lua
lualib/lua_dkim_tools.lua

index ae05eed592b74e6982645a51defd6fe34cf33f61..971a341b4642a15f16fe034bec865c5cd679b014 100644 (file)
@@ -301,8 +301,29 @@ return function(cfg)
   end
 
   -- Deal with dkim settings
-  if not cfg.dkim then cfg.dkim = {} end
+  if not cfg.dkim then
+    cfg.dkim = {}
+  else
+    if cfg.dkim.sign_condition then
+      -- We have an obsoleted sign condition, so we need to either add dkim_signing and move it
+      -- there or just move sign condition there...
+      if not cfg.dkim_signing then
+        logger.warnx('obsoleted DKIM signing method used, converting it to "dkim_signing" module')
+        cfg.dkim_signing = {
+          sign_condition = cfg.dkim.sign_condition
+        }
+      else
+        if not cfg.dkim_signing.sign_condition then
+          logger.warnx('obsoleted DKIM signing method used, move it to "dkim_signing" module')
+          cfg.dkim_signing.sign_condition = cfg.dkim.sign_condition
+        else
+          logger.warnx('obsoleted DKIM signing method used, ignore it as "dkim_signing" also defines condition!')
+        end
+      end
+    end
+  end
 
+  -- Again: legacy stuff :(
   if not cfg.dkim.sign_headers then
     local sec = cfg.dkim_signing
     if sec and sec[1] then sec = cfg.dkim_signing[1] end
index fbb071245f4b48a3029dc41b853d826e724bb42a..4ca1a662f97e3b97d25fc243aa16aea4e7776825 100644 (file)
@@ -142,7 +142,11 @@ local function prepare_dkim_signing(N, task, settings)
       return false,{}
     end
 
-    return true,ret
+    if ret[1] then
+      return true,ret
+    else
+      return true,{ret}
+    end
   end
 
   local auser = task:get_user()
@@ -666,7 +670,8 @@ exports.validate_signing_settings = function(settings)
       settings.selector_map or
       settings.use_http_headers or
       (settings.signing_table and settings.key_table) or
-      (settings.use_vault and settings.vault_url and settings.vault_token)
+      (settings.use_vault and settings.vault_url and settings.vault_token) or
+      settings.sign_condition
 end
 
 exports.process_signing_settings = function(N, settings, opts)