From 509a804acdb0d7eaa5eb2e2cca199a068fb58efc Mon Sep 17 00:00:00 2001 From: andryyy Date: Thu, 16 Mar 2017 13:42:56 +0100 Subject: [PATCH 1/3] Deprecated lua function replaced, better tag handling when spam --- data/conf/rspamd/lua/rspamd.local.lua | 85 ++++++++++++++------------- 1 file changed, 45 insertions(+), 40 deletions(-) diff --git a/data/conf/rspamd/lua/rspamd.local.lua b/data/conf/rspamd/lua/rspamd.local.lua index 236734f2..60516991 100644 --- a/data/conf/rspamd/lua/rspamd.local.lua +++ b/data/conf/rspamd/lua/rspamd.local.lua @@ -23,51 +23,56 @@ auth_domain_map = rspamd_config:add_map({ description = 'Map of domains we are authoritative for' }) -rspamd_config:register_post_filter(function(task) - local util = require("rspamd_util") - local rspamd_logger = require "rspamd_logger" +rspamd_config:register_symbol({ + name = 'TAG_MOO', + type = 'postfilter', + callback = function(task) + local util = require("rspamd_util") + local rspamd_logger = require "rspamd_logger" - local tagged_rcpt = task:get_symbol("TAGGED_RCPT") - local user = task:get_recipients(0)[1]['user'] - local domain = task:get_recipients(0)[1]['domain'] - local rcpt = user .. '@' .. domain - local authdomain = auth_domain_map:get_key(domain) + local tagged_rcpt = task:get_symbol("TAGGED_RCPT") + local user = task:get_recipients(0)[1]['user'] + local domain = task:get_recipients(0)[1]['domain'] + local rcpt = user .. '@' .. domain + local authdomain = auth_domain_map:get_key(domain) - if tagged_rcpt then - local tag = tagged_rcpt[1].options[1] - rspamd_logger.infox("found tag: %s", tag) - local action = task:get_metric_action('default') - rspamd_logger.infox("metric action now: %s", action) + if tagged_rcpt then + local tag = tagged_rcpt[1].options[1] + rspamd_logger.infox("found tag: %s", tag) + local action = task:get_metric_action('default') + rspamd_logger.infox("metric action now: %s", action) - if action ~= 'no action' and action ~= 'greylist' then - rspamd_logger.infox("skipping tag handler for action: %s", action) + if action ~= 'no action' and action ~= 'greylist' then + rspamd_logger.infox("skipping tag handler for action: %s", action) + task:set_metric_action('default', action) + end + + if authdomain then + rspamd_logger.infox("found mailcow domain %s", domain) + rspamd_logger.infox("querying tag settings for user %s", rcpt) + + if modify_subject_map:get_key(rcpt) then + rspamd_logger.infox("user wants subject modified for tagged mail") + local sbj = task:get_header('Subject') + new_sbj = '=?UTF-8?B?' .. tostring(util.encode_base64('[' .. tag .. '] ' .. sbj)) .. '?=' + task:set_rmilter_reply({ + remove_headers = {['Subject'] = 1}, + add_headers = {['Subject'] = new_sbj} + }) + else + rspamd_logger.infox("Add X-Moo-Tag header") + task:set_rmilter_reply({ + add_headers = {['X-Moo-Tag'] = 'YES'} + }) + end + else + rspamd_logger.infox("skip delimiter handling for unknown domain") + end return false end - - if authdomain then - rspamd_logger.infox("found mailcow domain %s", domain) - rspamd_logger.infox("querying tag settings for user %s", rcpt) - - if modify_subject_map:get_key(rcpt) then - rspamd_logger.infox("user wants subject modified for tagged mail") - local sbj = task:get_header('Subject') - new_sbj = '=?UTF-8?B?' .. tostring(util.encode_base64('[' .. tag .. '] ' .. sbj)) .. '?=' - task:set_rmilter_reply({ - remove_headers = {['Subject'] = 1}, - add_headers = {['Subject'] = new_sbj} - }) - else - rspamd_logger.infox("Add X-Moo-Tag header") - task:set_rmilter_reply({ - add_headers = {['X-Moo-Tag'] = 'YES'} - }) - end - else - rspamd_logger.infox("skip delimiter handling for unknown domain") - end - return false - end -end) + end, + priority = 10 +}) rspamd_config.MRAPTOR = { callback = function(task) From edf047cf6687e87f0eebad865f3054089bb33583 Mon Sep 17 00:00:00 2001 From: andryyy Date: Thu, 16 Mar 2017 13:43:04 +0100 Subject: [PATCH 2/3] Fix domain alias edit error --- data/web/inc/functions.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/web/inc/functions.inc.php b/data/web/inc/functions.inc.php index 87bed9b9..9c2bdbc1 100644 --- a/data/web/inc/functions.inc.php +++ b/data/web/inc/functions.inc.php @@ -3320,7 +3320,7 @@ function mailbox_edit_alias_domain($postarray) { $stmt = $pdo->prepare("UPDATE `alias_domain` SET `alias_domain` = :alias_domain, `active` = :active, - `modified` = :modified, + `modified` = :modified WHERE `alias_domain` = :alias_domain_now"); $stmt->execute(array( ':alias_domain' => $alias_domain, From 2fcbce4f2ebfe32a93fde344506f8119edf88264 Mon Sep 17 00:00:00 2001 From: andryyy Date: Fri, 17 Mar 2017 19:23:25 +0100 Subject: [PATCH 3/3] Fix: return true --- data/conf/rspamd/lua/rspamd.local.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/data/conf/rspamd/lua/rspamd.local.lua b/data/conf/rspamd/lua/rspamd.local.lua index 60516991..7d6aaa20 100644 --- a/data/conf/rspamd/lua/rspamd.local.lua +++ b/data/conf/rspamd/lua/rspamd.local.lua @@ -45,6 +45,7 @@ rspamd_config:register_symbol({ if action ~= 'no action' and action ~= 'greylist' then rspamd_logger.infox("skipping tag handler for action: %s", action) task:set_metric_action('default', action) + return true end if authdomain then