From c21623b4827ce9b399df61dbe32308275359b2ae Mon Sep 17 00:00:00 2001 From: andryyy Date: Fri, 3 Mar 2017 04:44:51 +0100 Subject: [PATCH] Important fix for Rspamd score settings, LUA tag handling changes --- data/conf/rspamd/dynmaps/settings.php | 29 +++++++++++++++++---------- data/conf/rspamd/lua/rspamd.local.lua | 3 +++ 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/data/conf/rspamd/dynmaps/settings.php b/data/conf/rspamd/dynmaps/settings.php index a281b981..90697821 100644 --- a/data/conf/rspamd/dynmaps/settings.php +++ b/data/conf/rspamd/dynmaps/settings.php @@ -4,11 +4,11 @@ The match section performs AND operation on different matches: for example, if y then the rule matches only when from AND rcpt match. For similar matches, the OR rule applies: if you have multiple rcpt matches, then any of these will trigger the rule. If a rule is triggered then no more rules are matched. */ -ini_set('error_reporting', '0'); - header('Content-Type: text/plain'); require_once "vars.inc.php"; +ini_set('error_reporting', 0); + $dsn = $database_type . ':host=' . $database_host . ';dbname=' . $database_name; $opt = [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, @@ -38,10 +38,17 @@ while ($row = array_shift($rows)) { WHERE (`object`= :object OR `object`= :object_domain) AND (`option` = 'blacklist_from' OR `option` = 'whitelist_from')"); $stmt->execute(array(':object' => $row['object'], ':object_domain' => substr(strrchr($row['object'], "@"), 1))); - $grouped_lists = $stmt->fetchAll(PDO::FETCH_COLUMN); - $value_sane = preg_replace("/\.\./", ".", (preg_replace("/\*/", ".*", $grouped_lists[0]))); + $grouped_lists = $stmt->fetchAll(PDO::FETCH_ASSOC); + array_filter($grouped_lists); + while ($grouped_list = array_shift($grouped_lists)) { + $value_sane = preg_replace("/\.\./", ".", (preg_replace("/\*/", ".*", $grouped_list['value']))); + if (!empty($value_sane)) { ?> from = "/^((?!).)*$/"; + rcpt = ""; prepare("SELECT `address` FROM `alias` WHERE `goto` = :object_goto AND `address` NOT LIKE '@%' AND `address` != :object_address"); @@ -57,7 +64,7 @@ while ($row = array_shift($rows)) { WHERE `mailbox`.`username` = :object"); $stmt->execute(array(':object' => $row['object'])); $rows_aliases_2 = $stmt->fetchAll(PDO::FETCH_ASSOC); - array_filter($rows_aliases_2); + array_filter($rows_aliases_2); while ($row_aliases_2 = array_shift($rows_aliases_2)) { if (!empty($row_aliases_2['aliases'])) { ?> @@ -106,7 +113,7 @@ while ($row = array_shift($rows)) { WHERE `target_domain` = :object"); $stmt->execute(array(':object' => $row['object'])); $rows_domain_aliases = $stmt->fetchAll(PDO::FETCH_ASSOC); - array_filter($rows_domain_aliases); + array_filter($rows_domain_aliases); while ($row_domain_aliases = array_shift($rows_domain_aliases)) { ?> rcpt = "/.*@/"; @@ -122,7 +129,7 @@ while ($row = array_shift($rows)) { $stmt = $pdo->prepare("SELECT `address` FROM `alias` WHERE `goto` = :object_goto AND `address` NOT LIKE '@%' AND `address` != :object_address"); $stmt->execute(array(':object_goto' => $row['object'], ':object_address' => $row['object'])); $rows_aliases_wl_1 = $stmt->fetchAll(PDO::FETCH_ASSOC); - array_filter($rows_aliases_wl_1); + array_filter($rows_aliases_wl_1); while ($row_aliases_wl_1 = array_shift($rows_aliases_wl_1)) { ?> rcpt = ""; @@ -133,7 +140,7 @@ while ($row = array_shift($rows)) { WHERE `mailbox`.`username` = :object"); $stmt->execute(array(':object' => $row['object'])); $rows_aliases_wl_2 = $stmt->fetchAll(PDO::FETCH_ASSOC); - array_filter($rows_aliases_wl_2); + array_filter($rows_aliases_wl_2); while ($row_aliases_wl_2 = array_shift($rows_aliases_wl_2)) { if (!empty($row_aliases_wl_2['aliases'])) { ?> @@ -178,7 +185,7 @@ while ($row = array_shift($rows)) { WHERE `target_domain` = :object"); $stmt->execute(array(':object' => $row['object'])); $rows_domain_aliases = $stmt->fetchAll(PDO::FETCH_ASSOC); - array_filter($rows_domain_aliases); + array_filter($rows_domain_aliases); while ($row_domain_aliases = array_shift($rows_domain_aliases)) { ?> rcpt = "/.*@/"; @@ -194,7 +201,7 @@ while ($row = array_shift($rows)) { $stmt = $pdo->prepare("SELECT `address` FROM `alias` WHERE `goto` = :object_goto AND `address` NOT LIKE '@%' AND `address` != :object_address"); $stmt->execute(array(':object_goto' => $row['object'], ':object_address' => $row['object'])); $rows_aliases_bl_1 = $stmt->fetchAll(PDO::FETCH_ASSOC); - array_filter($rows_aliases_bl_1); + array_filter($rows_aliases_bl_1); while ($row_aliases_bl_1 = array_shift($rows_aliases_bl_1)) { ?> rcpt = ""; @@ -205,7 +212,7 @@ while ($row = array_shift($rows)) { WHERE `mailbox`.`username` = :object"); $stmt->execute(array(':object' => $row['object'])); $rows_aliases_bl_2 = $stmt->fetchAll(PDO::FETCH_ASSOC); - array_filter($rows_aliases_bl_2); + array_filter($rows_aliases_bl_2); while ($row_aliases_bl_2 = array_shift($rows_aliases_bl_2)) { if (!empty($row_aliases_bl_2['aliases'])) { ?> diff --git a/data/conf/rspamd/lua/rspamd.local.lua b/data/conf/rspamd/lua/rspamd.local.lua index b3f96f64..b6d264ea 100644 --- a/data/conf/rspamd/lua/rspamd.local.lua +++ b/data/conf/rspamd/lua/rspamd.local.lua @@ -26,6 +26,9 @@ local auth_domain_map = rspamd_config:add_map({ rspamd_config.ADD_DELIMITER_TAG = { callback = function(task) tag = nil + local tag_env = nil + local tag_to = nil + local util = require("rspamd_util") local rspamd_logger = require "rspamd_logger"