summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-05-10 12:04:15 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-05-10 12:04:15 +0100
commit37a04a9e42001f376f69d2920315194f3098a0c4 (patch)
tree5c383185523dd5e7f79bd5504d9d9f53925f70e6 /src
parentaaa96909f731c4493cfc707b59fdd4c67f0afcac (diff)
downloadrspamd-37a04a9e42001f376f69d2920315194f3098a0c4.tar.gz
rspamd-37a04a9e42001f376f69d2920315194f3098a0c4.zip
[Fix] Do not check DMARC if SPF or DKIM were not checked
Issue: #1629
Diffstat (limited to 'src')
-rw-r--r--src/plugins/dkim_check.c16
-rw-r--r--src/plugins/lua/dmarc.lua6
-rw-r--r--src/plugins/spf.c15
3 files changed, 36 insertions, 1 deletions
diff --git a/src/plugins/dkim_check.c b/src/plugins/dkim_check.c
index dd61de67f..8dc8ee1ec 100644
--- a/src/plugins/dkim_check.c
+++ b/src/plugins/dkim_check.c
@@ -870,7 +870,21 @@ dkim_symbol_callback (struct rspamd_task *task, void *unused)
GError *err = NULL;
struct rspamd_mime_header *rh;
struct dkim_check_result *res = NULL, *cur;
- guint checked = 0, i;
+ guint checked = 0, i, *dmarc_checks;
+
+ /* Allow dmarc */
+ dmarc_checks = rspamd_mempool_get_variable (task->task_pool, "dmarc_checks");
+
+ if (dmarc_checks) {
+ (*dmarc_checks) ++;
+ }
+ else {
+ dmarc_checks = rspamd_mempool_alloc (task->task_pool,
+ sizeof (*dmarc_checks));
+ *dmarc_checks = 1;
+ rspamd_mempool_set_variable (task->task_pool, "dmarc_checks",
+ dmarc_checks, NULL);
+ }
/* First check if plugin should be enabled */
if ((!dkim_module_ctx->check_authed && task->user != NULL)
diff --git a/src/plugins/lua/dmarc.lua b/src/plugins/lua/dmarc.lua
index e3cc09bf0..f7a95c5af 100644
--- a/src/plugins/lua/dmarc.lua
+++ b/src/plugins/lua/dmarc.lua
@@ -255,6 +255,12 @@ local function dmarc_callback(task)
local dmarc_domain, efromdom, spf_domain
local ip_addr = task:get_ip()
local dkim_results = {}
+ local dmarc_checks = task:get_mempool():get_variable('dmarc_checks', 'int') or 0
+
+ if dmarc_checks ~= 2 then
+ rspamd_logger.infox(task, "skip DMARC checks as either SPF or DKIM were not checked");
+ return
+ end
if ((not check_authed and task:get_user()) or
(not check_local and ip_addr and ip_addr:is_local())) then
diff --git a/src/plugins/spf.c b/src/plugins/spf.c
index 883fabde4..c9bc5d67d 100644
--- a/src/plugins/spf.c
+++ b/src/plugins/spf.c
@@ -549,6 +549,21 @@ spf_symbol_callback (struct rspamd_task *task, void *unused)
const gchar *domain;
struct spf_resolved *l;
struct rspamd_async_watcher *w;
+ gint *dmarc_checks;
+
+ /* Allow dmarc */
+ dmarc_checks = rspamd_mempool_get_variable (task->task_pool, "dmarc_checks");
+
+ if (dmarc_checks) {
+ (*dmarc_checks) ++;
+ }
+ else {
+ dmarc_checks = rspamd_mempool_alloc (task->task_pool,
+ sizeof (*dmarc_checks));
+ *dmarc_checks = 1;
+ rspamd_mempool_set_variable (task->task_pool, "dmarc_checks",
+ dmarc_checks, NULL);
+ }
if (radix_find_compressed_addr (spf_module_ctx->whitelist_ip,
task->from_addr) != RADIX_NO_VALUE) {