From 0e654a69f908ae3abe19663dc192f1dbc45d8ed0 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 11 Jun 2018 11:32:43 +0100 Subject: [Feature] Improve error reporting for DKIM key access issues --- src/plugins/lua/arc.lua | 10 ++++++++-- src/plugins/lua/dkim_signing.lua | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/lua/arc.lua b/src/plugins/lua/arc.lua index b240b3b3c..83b02c32e 100644 --- a/src/plugins/lua/arc.lua +++ b/src/plugins/lua/arc.lua @@ -510,10 +510,16 @@ local function arc_signing_cb(task) else if (p.key and p.selector) then p.key = lua_util.template(p.key, {domain = p.domain, selector = p.selector}) - if not rspamd_util.file_exists(p.key) then - rspamd_logger.debugm(N, task, 'file %s does not exists', p.key) + local exists,err = rspamd_util.file_exists(p.key) + if not exists then + if err and err == 'No such file or directory' then + rspamd_logger.debugm(N, task, 'cannot read key from %s: %s', p.key, err) + else + rspamd_logger.warnx(N, task, 'cannot read key from %s: %s', p.key, err) + end return false end + local dret, hdr = dkim_sign(task, p) if dret then return arc_sign_seal(task, p, hdr) diff --git a/src/plugins/lua/dkim_signing.lua b/src/plugins/lua/dkim_signing.lua index 9b8f0a047..5e057cf9e 100644 --- a/src/plugins/lua/dkim_signing.lua +++ b/src/plugins/lua/dkim_signing.lua @@ -117,10 +117,16 @@ local function dkim_signing_cb(task) else if (p.key and p.selector) then p.key = lutil.template(p.key, {domain = p.domain, selector = p.selector}) - if not rspamd_util.file_exists(p.key) then - rspamd_logger.debugm(N, task, 'file %s does not exists', p.key) + local exists,err = rspamd_util.file_exists(p.key) + if not exists then + if err and err == 'No such file or directory' then + rspamd_logger.debugm(N, task, 'cannot read key from %s: %s', p.key, err) + else + rspamd_logger.warnx(N, task, 'cannot read key from %s: %s', p.key, err) + end return false end + local sret, _ = sign_func(task, p) return sret else -- cgit v1.2.3