From 0389ba3f00b579fb538c021bd0de39f5e4c0b613 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sat, 25 Jun 2022 12:45:28 +0100 Subject: [PATCH] [Minor] Add some sanity stuff for signing to skip signing for passthrough results --- lualib/lua_dkim_tools.lua | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lualib/lua_dkim_tools.lua b/lualib/lua_dkim_tools.lua index 5552ae861..21794a570 100644 --- a/lualib/lua_dkim_tools.lua +++ b/lualib/lua_dkim_tools.lua @@ -156,6 +156,29 @@ local function prepare_dkim_signing(N, task, settings) is_local = true end + local has_pre_result = task:has_pre_result() + if has_pre_result then + local metric_action = task:get_metric_action() + + if metric_action == 'reject' or metric_action == 'drop' then + -- No need to sign what we are already rejecting/dropping + lua_util.debugm(N, task, 'task result is already %s, no need to sign', metric_action) + return false,{} + end + + if metric_action == 'soft reject' then + -- Same here, we are going to delay an email, signing is just a waste of time + lua_util.debugm(N, task, 'task result is %s, skip signing', metric_action) + return false,{} + end + + -- For spam actions, there is no clear distinction + if metric_action ~= 'no action' and type(settings.skip_spam_sign) == 'boolean' and settings.skip_spam_sign then + lua_util.debugm(N, task, 'task result is %s, no need to sign', metric_action) + return false,{} + end + end + if settings.sign_authenticated and auser then lua_util.debugm(N, task, 'user is authenticated') is_authed = true -- 2.39.5