]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Allow to receive signing keys from mempool vars
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 14 Jul 2017 07:18:16 +0000 (08:18 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 14 Jul 2017 07:18:16 +0000 (08:18 +0100)
lualib/dkim_sign_tools.lua
src/libserver/mempool_vars_internal.h

index 7c49aef1e6ea2e2931058325a07be5644519b2ec..3a34a56824a9114ee4f0c2d910b0442165aca745 100644 (file)
@@ -137,10 +137,23 @@ local function prepare_dkim_signing(N, task, settings)
     p.key = settings.domain[dkim_domain].path
   end
 
-  if not (p.key and p.selector) and not
-  (settings.try_fallback or settings.use_redis or settings.selector_map or settings.path_map) then
-    rspamd_logger.debugm(N, task, 'dkim unconfigured and fallback disabled')
-    return false,{}
+  if not p.key and p.selector then
+    local key_var = "dkim_key"
+    local selector_var = "dkim_selector"
+    if N == "arc" then
+      key_var = "arc_key"
+      selector_var = "arc_selector"
+    end
+
+    p.key = task:get_mempool():get_variable(key_var)
+    p.selector = task:get_mempool():get_variable(selector_var)
+
+    if (not p.key or not p.selector) and (not (settings.try_fallback or
+        settings.use_redis or settings.selector_map
+        or settings.path_map)) then
+      rspamd_logger.debugm(N, task, 'dkim unconfigured and fallback disabled')
+      return false,{}
+    end
   end
 
   if not p.key then
@@ -154,14 +167,14 @@ local function prepare_dkim_signing(N, task, settings)
   end
   p.domain = dkim_domain
 
-  if settings.selector_map then
+  if not p.selector and settings.selector_map then
     local data = settings.selector_map:get_key(dkim_domain)
     if data then
       p.selector = data
     end
   end
 
-  if settings.path_map then
+  if not p.key and settings.path_map then
     local data = settings.path_map:get_key(dkim_domain)
     if data then
       p.key = data
index 229d56d48dfa1d5f606162dbd14cc4e8f22293f0..903f169f9c1e9fa1b1436fb7619f6bc41ca361cb 100644 (file)
 #define RSPAMD_MEMPOOL_DKIM_SIGNATURE "dkim-signature"
 #define RSPAMD_MEMPOOL_DMARC_CHECKS "dmarc_checks"
 #define RSPAMD_MEMPOOL_DKIM_BH_CACHE "dkim_bh_cache"
+#define RSPAMD_MEMPOOL_DKIM_SIGN_KEY "dkim_key"
+#define RSPAMD_MEMPOOL_DKIM_SIGN_SELECTOR "dkim_selector"
+#define RSPAMD_MEMPOOL_ARC_SIGN_KEY "arc_key"
+#define RSPAMD_MEMPOOL_ARC_SIGN_SELECTOR "arc_selector"
 #define RSPAMD_MEMPOOL_STAT_SIGNATURE "stat_signature"
 
 #endif