From bd689b9b23679860d4e3c9e419f4c46bcb2e04e2 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 8 Sep 2020 13:25:55 +0100 Subject: [PATCH] [Fix] Arc: Allow to reuse authentication results when doing multi-stage signing --- src/plugins/lua/arc.lua | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/src/plugins/lua/arc.lua b/src/plugins/lua/arc.lua index 3f21bd3f4..ce6f1e02e 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 -- 2.39.5