aboutsummaryrefslogtreecommitdiffstats
path: root/lualib/lua_auth_results.lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-11-30 17:46:10 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-11-30 19:03:13 +0000
commit6a3a3335cd4cc9637323332ffbc498236d414995 (patch)
tree4dbc73ac67f9766a4d1f63cc429cbbf379691abb /lualib/lua_auth_results.lua
parent1f416765cb8365b52a9161dfcd66cb7af8fd5c34 (diff)
downloadrspamd-6a3a3335cd4cc9637323332ffbc498236d414995.tar.gz
rspamd-6a3a3335cd4cc9637323332ffbc498236d414995.zip
[Feature] Improve SPF results in Authentication-Results
Diffstat (limited to 'lualib/lua_auth_results.lua')
-rw-r--r--lualib/lua_auth_results.lua49
1 files changed, 43 insertions, 6 deletions
diff --git a/lualib/lua_auth_results.lua b/lualib/lua_auth_results.lua
index 07957376d..9b72dc5ab 100644
--- a/lualib/lua_auth_results.lua
+++ b/lualib/lua_auth_results.lua
@@ -78,11 +78,13 @@ local function gen_auth_results(task, settings)
local mta_hostname = task:get_request_header('MTA-Name') or
task:get_request_header('MTA-Tag')
if mta_hostname then
- table.insert(hdr_parts, tostring(mta_hostname))
+ mta_hostname = tostring(mta_hostname)
else
- table.insert(hdr_parts, local_hostname)
+ mta_hostname = local_hostname
end
+ table.insert(hdr_parts, mta_hostname)
+
for auth_type, symbols in pairs(auth_types) do
for key, sym in pairs(symbols) do
if not common.symbols.sym then
@@ -152,16 +154,51 @@ local function gen_auth_results(task, settings)
end
end
elseif auth_type == 'spf' and key ~= 'none' then
- hdr = hdr .. auth_type .. '=' .. key
+ -- Main type
+ local sender
+ local sender_type
local smtp_from = task:get_from('smtp')
- if smtp_from and smtp_from[1] and smtp_from[1]['addr'] ~= '' and smtp_from[1]['addr'] ~= nil then
- hdr = hdr .. ' smtp.mailfrom=' .. smtp_from[1]['addr']
+
+ if smtp_from and
+ smtp_from[1] and
+ smtp_from[1]['addr'] ~= '' and
+ smtp_from[1]['addr'] ~= nil then
+ sender = smtp_from[1]['addr']
+ sender_type = 'smtp.mailfrom='
else
local helo = task:get_helo()
if helo then
- hdr = hdr .. ' smtp.helo=' .. task:get_helo()
+ sender = helo
+ sender_type = 'smtp.helo'
+ end
+ end
+
+ if sender and sender_type then
+ -- Comment line
+ local comment = ''
+ if key == 'pass' then
+ comment = string.format('%s: domain of %s designates %s as permitted sender',
+ mta_hostname, sender, tostring(task:get_from_ip() or 'unknown'))
+ elseif key == 'fail' then
+ comment = string.format('%s: domain of %s does not designate %s as permitted sender',
+ mta_hostname, sender, tostring(task:get_from_ip() or 'unknown'))
+ elseif key == 'neutral' or key == 'softfail' then
+ comment = string.format('%s: %s is neither permitted nor denied by domain of %s',
+ mta_hostname, tostring(task:get_from_ip() or 'unknown'), sender)
+ elseif key == 'permerror' then
+ comment = string.format('%s: domain of %s uses mechanism not recognized by this client',
+ mta_hostname, sender)
+ elseif key == 'temperror' then
+ comment = string.format('%s: error in processing during lookup of %s: DNS error',
+ mta_hostname, sender)
end
+ hdr = string.format('%s=%s (%s) %s=%s', auth_type, key,
+ comment, sender_type, sender)
+ else
+ hdr = string.format('%s=%s', auth_type, key)
end
+
+
table.insert(hdr_parts, hdr)
end
end