]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Arc: Allow to reuse authentication results when doing multi-stage signing
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 8 Sep 2020 12:25:55 +0000 (13:25 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 8 Sep 2020 12:25:55 +0000 (13:25 +0100)
src/plugins/lua/arc.lua

index 3f21bd3f49ff431a2571af2ab0efec0fb8e20197..ce6f1e02e62a2dc65d0a2abd688bd74a2aa12134 100644 (file)
@@ -553,11 +553,38 @@ local function prepare_arc_selector(task, sel)
   if arc_seals then
     sel.arc_idx = #arc_seals + 1
 
-    if task:has_symbol(arc_symbols.allow) then
-      sel.arc_cv = 'pass'
+    local function default_arc_cv()
+      if task:has_symbol(arc_symbols.allow) then
+        sel.arc_cv = 'pass'
+      else
+        sel.arc_cv = 'fail'
+      end
+    end
+
+    if settings.reuse_auth_results then
+      local ar_header = task:get_header('Authentication-Results')
+
+      if ar_header then
+        local arc_match = string.match(ar_header, 'arc=(%w+)')
+
+        if arc_match then
+          if arc_match == 'none' or arc_match == 'pass' then
+            -- none should be converted to `pass`
+            sel.arc_cv = 'pass'
+          else
+            sel.arc_cv = 'fail'
+          end
+        else
+          default_arc_cv()
+        end
+      else
+        -- Cannot reuse, use normal path
+        default_arc_cv()
+      end
     else
-      sel.arc_cv = 'fail'
+      default_arc_cv()
     end
+
   end
 end