Log some infos, sign using dkim separator

master
andryyy 2016-12-15 10:04:56 +01:00
parent 1aa5280fc2
commit 5afda018ce
1 changed files with 23 additions and 15 deletions

View File

@ -1,17 +1,25 @@
sign_condition =<<EOD sign_condition =<<EOD
return function(task) return function(task)
local from = task:get_from('smtp') local from = task:get_from('smtp')
local rspamd_logger = require "rspamd_logger"
if not task:get_user() then
rspamd_logger.infox(task, "Skip DKIM signing for unauthorized user")
return false
end
if from and from[1]['addr'] then if from and from[1]['addr'] then
lastAtSymbol = from[1]['addr']:find("[^%@]+$") lastAtSymbol = from[1]['addr']:find("[^%@]+$")
local domain = from[1]['addr']:sub(lastAtSymbol, #from[1]['addr']) local domain = from[1]['addr']:sub(lastAtSymbol, #from[1]['addr'])
local keyfile = io.open("/etc/rspamd/dkim/keys/" .. domain .. ".default") local keyfile = io.open("/data/dkim/keys/" .. domain .. ".dkim")
if keyfile then if keyfile then
rspamd_logger.infox(task, "DKIM signing mail for authorized user of domain %s", domain)
keyfile:close() keyfile:close()
return { return {
key = "/etc/rspamd/dkim/keys/" .. domain .. ".default", key = "/data/dkim/keys/" .. domain .. ".dkim",
domain = domain, domain = domain,
selector = "default" selector = "dkim"
} }
else
rspamd_logger.infox(task, "Authorized user, but no key file for domain %s - skipped DKIM signing", domain)
end end
end end
return false return false