From: Vsevolod Stakhov Date: Tue, 8 Sep 2020 12:25:55 +0000 (+0100) Subject: [Fix] Arc: Allow to reuse authentication results when doing multi-stage signing X-Git-Tag: 2.6~71 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bd689b9b23679860d4e3c9e419f4c46bcb2e04e2;p=thirdparty%2Frspamd.git [Fix] Arc: Allow to reuse authentication results when doing multi-stage signing --- diff --git a/src/plugins/lua/arc.lua b/src/plugins/lua/arc.lua index 3f21bd3f49..ce6f1e02e6 100644 --- a/src/plugins/lua/arc.lua +++ b/src/plugins/lua/arc.lua @@ -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