From a09188540958de4c27f13d76af5deed09a413db2 Mon Sep 17 00:00:00 2001 From: Marius Burkard Date: Tue, 13 Nov 2018 13:56:47 +0100 Subject: [PATCH] - ported rspamd support --- .../sql/incremental/upd_dev_collection.sql | 36 ++- install/sql/ispconfig3.sql | 19 +- install/tpl/mailfilter.master | 90 -------- install/tpl/server.ini.master | 2 + .../web/admin/form/server_config.tform.php | 80 ++++++- .../web/admin/lib/lang/de_server_config.lng | 5 +- .../web/admin/lib/lang/en_server_config.lng | 6 +- interface/web/admin/server_config_edit.php | 64 ++++++ .../templates/server_config_mail_edit.htm | 35 +++ .../web/mail/form/spamfilter_policy.tform.php | 36 +++ interface/web/mail/lib/lang/de.lng | 4 +- .../mail/lib/lang/de_spamfilter_policy.lng | 9 +- interface/web/mail/lib/lang/en.lng | 3 +- .../mail/lib/lang/en_spamfilter_policy.lng | 9 +- interface/web/mail/mail_domain_edit.php | 5 +- interface/web/mail/mail_user_edit.php | 4 +- interface/web/mail/spamfilter_policy_edit.php | 72 +++++- interface/web/mail/spamfilter_policy_list.php | 29 ++- .../mail/templates/spamfilter_policy_edit.htm | 5 +- .../mail/templates/spamfilter_policy_list.htm | 12 +- .../templates/spamfilter_taglevel_edit.htm | 29 ++- server/conf/apache_apps.vhost.master | 10 + server/conf/autoresponder.master | 4 +- server/conf/nginx_apps.vhost.master | 25 +++ server/conf/rspamd.local.lua.master | 3 + server/conf/rspamd_antivirus.conf.master | 30 +++ .../conf/rspamd_classifier-bayes.conf.master | 3 + server/conf/rspamd_dkim_signing.conf.master | 2 + server/conf/rspamd_greylist.conf.master | 1 + server/conf/rspamd_metrics.conf.master | 17 ++ .../conf/rspamd_metrics_override.conf.master | 159 +++++++++++++ server/conf/rspamd_mx_check.conf.master | 9 + server/conf/rspamd_users.conf.master | 43 ++++ server/conf/rspamd_users.inc.conf.master | 41 ++++ server/conf/rspamd_wblist.inc.conf.master | 18 ++ .../conf/rspamd_worker-controller.inc.master | 8 + server/conf/sieve_filter.master | 6 +- server/conf/sieve_filter_1.2.master | 6 +- server/mods-available/mail_module.inc.php | 37 +++ .../apps_vhost_plugin.inc.php | 22 +- .../postfix_server_plugin.inc.php | 150 ++++++++++++- .../plugins-available/rspamd_plugin.inc.php | 210 ++++++++++++++++++ 42 files changed, 1205 insertions(+), 153 deletions(-) delete mode 100644 install/tpl/mailfilter.master create mode 100644 server/conf/rspamd.local.lua.master create mode 100644 server/conf/rspamd_antivirus.conf.master create mode 100644 server/conf/rspamd_classifier-bayes.conf.master create mode 100644 server/conf/rspamd_dkim_signing.conf.master create mode 100644 server/conf/rspamd_greylist.conf.master create mode 100644 server/conf/rspamd_metrics.conf.master create mode 100644 server/conf/rspamd_metrics_override.conf.master create mode 100644 server/conf/rspamd_mx_check.conf.master create mode 100644 server/conf/rspamd_users.conf.master create mode 100644 server/conf/rspamd_users.inc.conf.master create mode 100644 server/conf/rspamd_wblist.inc.conf.master create mode 100644 server/conf/rspamd_worker-controller.inc.master create mode 100644 server/plugins-available/rspamd_plugin.inc.php diff --git a/install/sql/incremental/upd_dev_collection.sql b/install/sql/incremental/upd_dev_collection.sql index 29d5700780..351c899360 100644 --- a/install/sql/incremental/upd_dev_collection.sql +++ b/install/sql/incremental/upd_dev_collection.sql @@ -151,4 +151,38 @@ UPDATE `web_domain` as d INNER JOIN `server` as s ON (s.server_id = d.server_id) UPDATE `web_domain` SET `php` = 'php-fpm' WHERE `php` = 'hhvm'; UPDATE `web_domain` SET `php` = 'fast-cgi' WHERE `php` = 'cgi'; -UPDATE `web_domain` SET `php` = 'mod' WHERE `php` = 'suphp'; \ No newline at end of file +UPDATE `web_domain` SET `php` = 'mod' WHERE `php` = 'suphp'; + +-- rspamd +ALTER TABLE `spamfilter_policy` ADD `rspamd_greylisting` ENUM('n','y') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'n' AFTER `policyd_greylist`; +ALTER TABLE `spamfilter_policy` ADD `rspamd_spam_greylisting_level` DECIMAL(5,2) NULL DEFAULT NULL AFTER `rspamd_greylisting`; +ALTER TABLE `spamfilter_policy` ADD `rspamd_spam_tag_level` DECIMAL(5,2) NULL DEFAULT NULL AFTER `rspamd_spam_greylisting_level`; +ALTER TABLE `spamfilter_policy` ADD `rspamd_spam_tag_method` ENUM('add_header','rewrite_subject') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'rewrite_subject' AFTER `rspamd_spam_tag_level`; +ALTER TABLE `spamfilter_policy` ADD `rspamd_spam_kill_level` DECIMAL(5,2) NULL DEFAULT NULL AFTER `rspamd_spam_tag_method`; + +UPDATE `spamfilter_policy` SET `rspamd_greylisting` = 'y' WHERE id = 4; +UPDATE `spamfilter_policy` SET `rspamd_greylisting` = 'y' WHERE id = 5; +UPDATE `spamfilter_policy` SET `rspamd_greylisting` = 'y' WHERE id = 6; + +UPDATE `spamfilter_policy` SET `rspamd_spam_greylisting_level` = '4.00'; +UPDATE `spamfilter_policy` SET `rspamd_spam_greylisting_level` = '6.00' WHERE id = 1; +UPDATE `spamfilter_policy` SET `rspamd_spam_greylisting_level` = '999.00' WHERE id = 2; +UPDATE `spamfilter_policy` SET `rspamd_spam_greylisting_level` = '999.00' WHERE id = 3; +UPDATE `spamfilter_policy` SET `rspamd_spam_greylisting_level` = '2.00' WHERE id = 6; +UPDATE `spamfilter_policy` SET `rspamd_spam_greylisting_level` = '7.00' WHERE id = 7; + +UPDATE `spamfilter_policy` SET `rspamd_spam_tag_level` = '6.00'; +UPDATE `spamfilter_policy` SET `rspamd_spam_tag_level` = '8.00' WHERE id = 1; +UPDATE `spamfilter_policy` SET `rspamd_spam_tag_level` = '999.00' WHERE id = 2; +UPDATE `spamfilter_policy` SET `rspamd_spam_tag_level` = '999.00' WHERE id = 3; +UPDATE `spamfilter_policy` SET `rspamd_spam_tag_level` = '4.00' WHERE id = 6; +UPDATE `spamfilter_policy` SET `rspamd_spam_tag_level` = '10.00' WHERE id = 7; + +UPDATE `spamfilter_policy` SET `rspamd_spam_kill_level` = '10.00'; +UPDATE `spamfilter_policy` SET `rspamd_spam_kill_level` = '12.00' WHERE id = 1; +UPDATE `spamfilter_policy` SET `rspamd_spam_kill_level` = '999.00' WHERE id = 2; +UPDATE `spamfilter_policy` SET `rspamd_spam_kill_level` = '999.00' WHERE id = 3; +UPDATE `spamfilter_policy` SET `rspamd_spam_kill_level` = '8.00' WHERE id = 6; +UPDATE `spamfilter_policy` SET `rspamd_spam_kill_level` = '20.00' WHERE id = 7; +-- end of rspamd + diff --git a/install/sql/ispconfig3.sql b/install/sql/ispconfig3.sql index e5a99a2938..2d86f57ffb 100644 --- a/install/sql/ispconfig3.sql +++ b/install/sql/ispconfig3.sql @@ -1576,6 +1576,11 @@ CREATE TABLE `spamfilter_policy` ( `policyd_quota_out` int(11) NOT NULL DEFAULT '-1', `policyd_quota_out_period` int(11) NOT NULL DEFAULT '24', `policyd_greylist` ENUM( 'Y', 'N' ) NOT NULL DEFAULT 'N', + `rspamd_greylisting` enum('n','y') NOT NULL DEFAULT 'n', + `rspamd_spam_greylisting_level` decimal(5,2) DEFAULT NULL, + `rspamd_spam_tag_level` decimal(5,2) DEFAULT NULL, + `rspamd_spam_tag_method` enum('add_header','rewrite_subject') NOT NULL DEFAULT 'rewrite_subject', + `rspamd_spam_kill_level` decimal(5,2) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; @@ -2423,13 +2428,13 @@ INSERT INTO `software_repo` (`software_repo_id`, `sys_userid`, `sys_groupid`, `s -- Dumping data for table `spamfilter_policy` -- -INSERT INTO `spamfilter_policy` (`id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `policy_name`, `virus_lover`, `spam_lover`, `banned_files_lover`, `bad_header_lover`, `bypass_virus_checks`, `bypass_spam_checks`, `bypass_banned_checks`, `bypass_header_checks`, `spam_modifies_subj`, `virus_quarantine_to`, `spam_quarantine_to`, `banned_quarantine_to`, `bad_header_quarantine_to`, `clean_quarantine_to`, `other_quarantine_to`, `spam_tag_level`, `spam_tag2_level`, `spam_kill_level`, `spam_dsn_cutoff_level`, `spam_quarantine_cutoff_level`, `addr_extension_virus`, `addr_extension_spam`, `addr_extension_banned`, `addr_extension_bad_header`, `warnvirusrecip`, `warnbannedrecip`, `warnbadhrecip`, `newvirus_admin`, `virus_admin`, `banned_admin`, `bad_header_admin`, `spam_admin`, `spam_subject_tag`, `spam_subject_tag2`, `message_size_limit`, `banned_rulenames`) VALUES(1, 1, 0, 'riud', 'riud', 'r', 'Non-paying', 'N', 'N', 'N', 'N', 'Y', 'Y', 'Y', 'N', 'Y', '', '', '', '', '', '', 3, 7, 10, 0, 0, '', '', '', '', 'N', 'N', 'N', '', '', '', '', '', '', '', 0, ''); -INSERT INTO `spamfilter_policy` (`id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `policy_name`, `virus_lover`, `spam_lover`, `banned_files_lover`, `bad_header_lover`, `bypass_virus_checks`, `bypass_spam_checks`, `bypass_banned_checks`, `bypass_header_checks`, `spam_modifies_subj`, `virus_quarantine_to`, `spam_quarantine_to`, `banned_quarantine_to`, `bad_header_quarantine_to`, `clean_quarantine_to`, `other_quarantine_to`, `spam_tag_level`, `spam_tag2_level`, `spam_kill_level`, `spam_dsn_cutoff_level`, `spam_quarantine_cutoff_level`, `addr_extension_virus`, `addr_extension_spam`, `addr_extension_banned`, `addr_extension_bad_header`, `warnvirusrecip`, `warnbannedrecip`, `warnbadhrecip`, `newvirus_admin`, `virus_admin`, `banned_admin`, `bad_header_admin`, `spam_admin`, `spam_subject_tag`, `spam_subject_tag2`, `message_size_limit`, `banned_rulenames`) VALUES(2, 1, 0, 'riud', 'riud', 'r', 'Uncensored', 'Y', 'Y', 'Y', 'Y', 'N', 'N', 'N', 'N', 'N', NULL, NULL, NULL, NULL, NULL, NULL, 3, 999, 999, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); -INSERT INTO `spamfilter_policy` (`id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `policy_name`, `virus_lover`, `spam_lover`, `banned_files_lover`, `bad_header_lover`, `bypass_virus_checks`, `bypass_spam_checks`, `bypass_banned_checks`, `bypass_header_checks`, `spam_modifies_subj`, `virus_quarantine_to`, `spam_quarantine_to`, `banned_quarantine_to`, `bad_header_quarantine_to`, `clean_quarantine_to`, `other_quarantine_to`, `spam_tag_level`, `spam_tag2_level`, `spam_kill_level`, `spam_dsn_cutoff_level`, `spam_quarantine_cutoff_level`, `addr_extension_virus`, `addr_extension_spam`, `addr_extension_banned`, `addr_extension_bad_header`, `warnvirusrecip`, `warnbannedrecip`, `warnbadhrecip`, `newvirus_admin`, `virus_admin`, `banned_admin`, `bad_header_admin`, `spam_admin`, `spam_subject_tag`, `spam_subject_tag2`, `message_size_limit`, `banned_rulenames`) VALUES(3, 1, 0, 'riud', 'riud', 'r', 'Wants all spam', 'N', 'Y', 'N', 'N', 'N', 'N', 'N', 'N', 'Y', NULL, NULL, NULL, NULL, NULL, NULL, 3, 999, 999, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); -INSERT INTO `spamfilter_policy` (`id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `policy_name`, `virus_lover`, `spam_lover`, `banned_files_lover`, `bad_header_lover`, `bypass_virus_checks`, `bypass_spam_checks`, `bypass_banned_checks`, `bypass_header_checks`, `spam_modifies_subj`, `virus_quarantine_to`, `spam_quarantine_to`, `banned_quarantine_to`, `bad_header_quarantine_to`, `clean_quarantine_to`, `other_quarantine_to`, `spam_tag_level`, `spam_tag2_level`, `spam_kill_level`, `spam_dsn_cutoff_level`, `spam_quarantine_cutoff_level`, `addr_extension_virus`, `addr_extension_spam`, `addr_extension_banned`, `addr_extension_bad_header`, `warnvirusrecip`, `warnbannedrecip`, `warnbadhrecip`, `newvirus_admin`, `virus_admin`, `banned_admin`, `bad_header_admin`, `spam_admin`, `spam_subject_tag`, `spam_subject_tag2`, `message_size_limit`, `banned_rulenames`) VALUES(4, 1, 0, 'riud', 'riud', 'r', 'Wants viruses', 'Y', 'N', 'Y', 'Y', 'N', 'N', 'N', 'N', 'Y', NULL, NULL, NULL, NULL, NULL, NULL, 3, 6.9, 6.9, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); -INSERT INTO `spamfilter_policy` (`id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `policy_name`, `virus_lover`, `spam_lover`, `banned_files_lover`, `bad_header_lover`, `bypass_virus_checks`, `bypass_spam_checks`, `bypass_banned_checks`, `bypass_header_checks`, `spam_modifies_subj`, `virus_quarantine_to`, `spam_quarantine_to`, `banned_quarantine_to`, `bad_header_quarantine_to`, `clean_quarantine_to`, `other_quarantine_to`, `spam_tag_level`, `spam_tag2_level`, `spam_kill_level`, `spam_dsn_cutoff_level`, `spam_quarantine_cutoff_level`, `addr_extension_virus`, `addr_extension_spam`, `addr_extension_banned`, `addr_extension_bad_header`, `warnvirusrecip`, `warnbannedrecip`, `warnbadhrecip`, `newvirus_admin`, `virus_admin`, `banned_admin`, `bad_header_admin`, `spam_admin`, `spam_subject_tag`, `spam_subject_tag2`, `message_size_limit`, `banned_rulenames`) VALUES(5, 1, 0, 'riud', 'riud', 'r', 'Normal', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'Y', '', '', '', '', '', '', 1, 4.5, 50, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '', '***SPAM***', NULL, NULL); -INSERT INTO `spamfilter_policy` (`id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `policy_name`, `virus_lover`, `spam_lover`, `banned_files_lover`, `bad_header_lover`, `bypass_virus_checks`, `bypass_spam_checks`, `bypass_banned_checks`, `bypass_header_checks`, `spam_modifies_subj`, `virus_quarantine_to`, `spam_quarantine_to`, `banned_quarantine_to`, `bad_header_quarantine_to`, `clean_quarantine_to`, `other_quarantine_to`, `spam_tag_level`, `spam_tag2_level`, `spam_kill_level`, `spam_dsn_cutoff_level`, `spam_quarantine_cutoff_level`, `addr_extension_virus`, `addr_extension_spam`, `addr_extension_banned`, `addr_extension_bad_header`, `warnvirusrecip`, `warnbannedrecip`, `warnbadhrecip`, `newvirus_admin`, `virus_admin`, `banned_admin`, `bad_header_admin`, `spam_admin`, `spam_subject_tag`, `spam_subject_tag2`, `message_size_limit`, `banned_rulenames`) VALUES(6, 1, 0, 'riud', 'riud', 'r', 'Trigger happy', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'Y', NULL, NULL, NULL, NULL, NULL, NULL, 3, 5, 5, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); -INSERT INTO `spamfilter_policy` (`id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `policy_name`, `virus_lover`, `spam_lover`, `banned_files_lover`, `bad_header_lover`, `bypass_virus_checks`, `bypass_spam_checks`, `bypass_banned_checks`, `bypass_header_checks`, `spam_modifies_subj`, `virus_quarantine_to`, `spam_quarantine_to`, `banned_quarantine_to`, `bad_header_quarantine_to`, `clean_quarantine_to`, `other_quarantine_to`, `spam_tag_level`, `spam_tag2_level`, `spam_kill_level`, `spam_dsn_cutoff_level`, `spam_quarantine_cutoff_level`, `addr_extension_virus`, `addr_extension_spam`, `addr_extension_banned`, `addr_extension_bad_header`, `warnvirusrecip`, `warnbannedrecip`, `warnbadhrecip`, `newvirus_admin`, `virus_admin`, `banned_admin`, `bad_header_admin`, `spam_admin`, `spam_subject_tag`, `spam_subject_tag2`, `message_size_limit`, `banned_rulenames`) VALUES(7, 1, 0, 'riud', 'riud', 'r', 'Permissive', 'N', 'N', 'N', 'Y', 'N', 'N', 'N', 'N', 'Y', NULL, NULL, NULL, NULL, NULL, NULL, 3, 10, 20, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); +INSERT INTO `spamfilter_policy` (`id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `policy_name`, `virus_lover`, `spam_lover`, `banned_files_lover`, `bad_header_lover`, `bypass_virus_checks`, `bypass_spam_checks`, `bypass_banned_checks`, `bypass_header_checks`, `spam_modifies_subj`, `virus_quarantine_to`, `spam_quarantine_to`, `banned_quarantine_to`, `bad_header_quarantine_to`, `clean_quarantine_to`, `other_quarantine_to`, `spam_tag_level`, `spam_tag2_level`, `spam_kill_level`, `spam_dsn_cutoff_level`, `spam_quarantine_cutoff_level`, `addr_extension_virus`, `addr_extension_spam`, `addr_extension_banned`, `addr_extension_bad_header`, `warnvirusrecip`, `warnbannedrecip`, `warnbadhrecip`, `newvirus_admin`, `virus_admin`, `banned_admin`, `bad_header_admin`, `spam_admin`, `spam_subject_tag`, `spam_subject_tag2`, `message_size_limit`, `banned_rulenames`, `rspamd_greylisting`, `rspamd_spam_greylisting_level`, `rspamd_spam_tag_level`, `rspamd_spam_tag_method`, `rspamd_spam_kill_level`) VALUES(1, 1, 0, 'riud', 'riud', 'r', 'Non-paying', 'N', 'N', 'N', 'N', 'Y', 'Y', 'Y', 'N', 'Y', '', '', '', '', '', '', 3, 7, 10, 0, 0, '', '', '', '', 'N', 'N', 'N', '', '', '', '', '', '', '', 0, '', 'n', 6.00, 8.00, 'rewrite_subject', 12.00); +INSERT INTO `spamfilter_policy` (`id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `policy_name`, `virus_lover`, `spam_lover`, `banned_files_lover`, `bad_header_lover`, `bypass_virus_checks`, `bypass_spam_checks`, `bypass_banned_checks`, `bypass_header_checks`, `spam_modifies_subj`, `virus_quarantine_to`, `spam_quarantine_to`, `banned_quarantine_to`, `bad_header_quarantine_to`, `clean_quarantine_to`, `other_quarantine_to`, `spam_tag_level`, `spam_tag2_level`, `spam_kill_level`, `spam_dsn_cutoff_level`, `spam_quarantine_cutoff_level`, `addr_extension_virus`, `addr_extension_spam`, `addr_extension_banned`, `addr_extension_bad_header`, `warnvirusrecip`, `warnbannedrecip`, `warnbadhrecip`, `newvirus_admin`, `virus_admin`, `banned_admin`, `bad_header_admin`, `spam_admin`, `spam_subject_tag`, `spam_subject_tag2`, `message_size_limit`, `banned_rulenames`, `rspamd_greylisting`, `rspamd_spam_greylisting_level`, `rspamd_spam_tag_level`, `rspamd_spam_tag_method`, `rspamd_spam_kill_level`) VALUES(2, 1, 0, 'riud', 'riud', 'r', 'Uncensored', 'Y', 'Y', 'Y', 'Y', 'N', 'N', 'N', 'N', 'N', NULL, NULL, NULL, NULL, NULL, NULL, 3, 999, 999, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'n', 999.00, 999.00, 'rewrite_subject', 999.00); +INSERT INTO `spamfilter_policy` (`id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `policy_name`, `virus_lover`, `spam_lover`, `banned_files_lover`, `bad_header_lover`, `bypass_virus_checks`, `bypass_spam_checks`, `bypass_banned_checks`, `bypass_header_checks`, `spam_modifies_subj`, `virus_quarantine_to`, `spam_quarantine_to`, `banned_quarantine_to`, `bad_header_quarantine_to`, `clean_quarantine_to`, `other_quarantine_to`, `spam_tag_level`, `spam_tag2_level`, `spam_kill_level`, `spam_dsn_cutoff_level`, `spam_quarantine_cutoff_level`, `addr_extension_virus`, `addr_extension_spam`, `addr_extension_banned`, `addr_extension_bad_header`, `warnvirusrecip`, `warnbannedrecip`, `warnbadhrecip`, `newvirus_admin`, `virus_admin`, `banned_admin`, `bad_header_admin`, `spam_admin`, `spam_subject_tag`, `spam_subject_tag2`, `message_size_limit`, `banned_rulenames`, `rspamd_greylisting`, `rspamd_spam_greylisting_level`, `rspamd_spam_tag_level`, `rspamd_spam_tag_method`, `rspamd_spam_kill_level`) VALUES(3, 1, 0, 'riud', 'riud', 'r', 'Wants all spam', 'N', 'Y', 'N', 'N', 'N', 'N', 'N', 'N', 'Y', NULL, NULL, NULL, NULL, NULL, NULL, 3, 999, 999, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'n', 999.00, 999.00, 'rewrite_subject', 999.00); +INSERT INTO `spamfilter_policy` (`id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `policy_name`, `virus_lover`, `spam_lover`, `banned_files_lover`, `bad_header_lover`, `bypass_virus_checks`, `bypass_spam_checks`, `bypass_banned_checks`, `bypass_header_checks`, `spam_modifies_subj`, `virus_quarantine_to`, `spam_quarantine_to`, `banned_quarantine_to`, `bad_header_quarantine_to`, `clean_quarantine_to`, `other_quarantine_to`, `spam_tag_level`, `spam_tag2_level`, `spam_kill_level`, `spam_dsn_cutoff_level`, `spam_quarantine_cutoff_level`, `addr_extension_virus`, `addr_extension_spam`, `addr_extension_banned`, `addr_extension_bad_header`, `warnvirusrecip`, `warnbannedrecip`, `warnbadhrecip`, `newvirus_admin`, `virus_admin`, `banned_admin`, `bad_header_admin`, `spam_admin`, `spam_subject_tag`, `spam_subject_tag2`, `message_size_limit`, `banned_rulenames`, `rspamd_greylisting`, `rspamd_spam_greylisting_level`, `rspamd_spam_tag_level`, `rspamd_spam_tag_method`, `rspamd_spam_kill_level`) VALUES(4, 1, 0, 'riud', 'riud', 'r', 'Wants viruses', 'Y', 'N', 'Y', 'Y', 'N', 'N', 'N', 'N', 'Y', NULL, NULL, NULL, NULL, NULL, NULL, 3, 6.9, 6.9, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'y', 4.00, 6.00, 'rewrite_subject', 10.00); +INSERT INTO `spamfilter_policy` (`id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `policy_name`, `virus_lover`, `spam_lover`, `banned_files_lover`, `bad_header_lover`, `bypass_virus_checks`, `bypass_spam_checks`, `bypass_banned_checks`, `bypass_header_checks`, `spam_modifies_subj`, `virus_quarantine_to`, `spam_quarantine_to`, `banned_quarantine_to`, `bad_header_quarantine_to`, `clean_quarantine_to`, `other_quarantine_to`, `spam_tag_level`, `spam_tag2_level`, `spam_kill_level`, `spam_dsn_cutoff_level`, `spam_quarantine_cutoff_level`, `addr_extension_virus`, `addr_extension_spam`, `addr_extension_banned`, `addr_extension_bad_header`, `warnvirusrecip`, `warnbannedrecip`, `warnbadhrecip`, `newvirus_admin`, `virus_admin`, `banned_admin`, `bad_header_admin`, `spam_admin`, `spam_subject_tag`, `spam_subject_tag2`, `message_size_limit`, `banned_rulenames`, `rspamd_greylisting`, `rspamd_spam_greylisting_level`, `rspamd_spam_tag_level`, `rspamd_spam_tag_method`, `rspamd_spam_kill_level`) VALUES(5, 1, 0, 'riud', 'riud', 'r', 'Normal', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'Y', '', '', '', '', '', '', 1, 4.5, 50, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '', '***SPAM***', NULL, NULL, 'y', 4.00, 6.00, 'rewrite_subject', 10.00); +INSERT INTO `spamfilter_policy` (`id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `policy_name`, `virus_lover`, `spam_lover`, `banned_files_lover`, `bad_header_lover`, `bypass_virus_checks`, `bypass_spam_checks`, `bypass_banned_checks`, `bypass_header_checks`, `spam_modifies_subj`, `virus_quarantine_to`, `spam_quarantine_to`, `banned_quarantine_to`, `bad_header_quarantine_to`, `clean_quarantine_to`, `other_quarantine_to`, `spam_tag_level`, `spam_tag2_level`, `spam_kill_level`, `spam_dsn_cutoff_level`, `spam_quarantine_cutoff_level`, `addr_extension_virus`, `addr_extension_spam`, `addr_extension_banned`, `addr_extension_bad_header`, `warnvirusrecip`, `warnbannedrecip`, `warnbadhrecip`, `newvirus_admin`, `virus_admin`, `banned_admin`, `bad_header_admin`, `spam_admin`, `spam_subject_tag`, `spam_subject_tag2`, `message_size_limit`, `banned_rulenames`, `rspamd_greylisting`, `rspamd_spam_greylisting_level`, `rspamd_spam_tag_level`, `rspamd_spam_tag_method`, `rspamd_spam_kill_level`) VALUES(6, 1, 0, 'riud', 'riud', 'r', 'Trigger happy', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'Y', NULL, NULL, NULL, NULL, NULL, NULL, 3, 5, 5, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'y', 2.00, 4.00, 'rewrite_subject', 8.00); +INSERT INTO `spamfilter_policy` (`id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `policy_name`, `virus_lover`, `spam_lover`, `banned_files_lover`, `bad_header_lover`, `bypass_virus_checks`, `bypass_spam_checks`, `bypass_banned_checks`, `bypass_header_checks`, `spam_modifies_subj`, `virus_quarantine_to`, `spam_quarantine_to`, `banned_quarantine_to`, `bad_header_quarantine_to`, `clean_quarantine_to`, `other_quarantine_to`, `spam_tag_level`, `spam_tag2_level`, `spam_kill_level`, `spam_dsn_cutoff_level`, `spam_quarantine_cutoff_level`, `addr_extension_virus`, `addr_extension_spam`, `addr_extension_banned`, `addr_extension_bad_header`, `warnvirusrecip`, `warnbannedrecip`, `warnbadhrecip`, `newvirus_admin`, `virus_admin`, `banned_admin`, `bad_header_admin`, `spam_admin`, `spam_subject_tag`, `spam_subject_tag2`, `message_size_limit`, `banned_rulenames`, `rspamd_greylisting`, `rspamd_spam_greylisting_level`, `rspamd_spam_tag_level`, `rspamd_spam_tag_method`, `rspamd_spam_kill_level`) VALUES(7, 1, 0, 'riud', 'riud', 'r', 'Permissive', 'N', 'N', 'N', 'Y', 'N', 'N', 'N', 'N', 'Y', NULL, NULL, NULL, NULL, NULL, NULL, 3, 10, 20, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'n', 7.00, 10.00, 'rewrite_subject', 20.00); -- -------------------------------------------------------- diff --git a/install/tpl/mailfilter.master b/install/tpl/mailfilter.master deleted file mode 100644 index ba0e94539b..0000000000 --- a/install/tpl/mailfilter.master +++ /dev/null @@ -1,90 +0,0 @@ -# -# Import variables -# - -LOGNAME=tolower("$LOGNAME") -EXTENSION="$1" -RECIPIENT=tolower("$2") -USER=tolower("$3") -HOST=tolower("$4") -SENDER="$5" -DEFAULT="{dist_postfix_vmail_mailbox_base}/$HOST/$USER/." - -# Workaround for broken tolower function in some current fedora releases - -if(!$USER) -{ - USER=$3 -} -if(!$HOST) -{ - HOST=$4 -} - -if ( "$EXTENSION" ne "" ) -{ - DELIMITER="+" -} - -if (!$SENDER) -{ - SENDER = "<>" -} - -# -# Autocreate maildir, if not existant -# - -#`test -e {dist_postfix_vmail_mailbox_base}/$HOST` -#if ( $RETURNCODE != 0 ) -#{ -# `mkdir {dist_postfix_vmail_mailbox_base}/$HOST` -#} - -#`test -e {dist_postfix_vmail_mailbox_base}/$HOST/$USER` -#if ( $RETURNCODE != 0 ) -#{ -# `maildirmake {dist_postfix_vmail_mailbox_base}/$HOST/$USER` -# `chmod -R 0700 {dist_postfix_vmail_mailbox_base}/$HOST` -#} - -# Check if the user has a autoresponder enabled - -`test -f {dist_postfix_vmail_mailbox_base}/mailfilters/$HOST/$USER/.autoresponder` -if ( $RETURNCODE == 0 ) -{ - include "{dist_postfix_vmail_mailbox_base}/mailfilters/$HOST/$USER/.autoresponder" -} - -# Create a mailsize file -`test -e {dist_postfix_vmail_mailbox_base}/$HOST/$USER` -if ( $RETURNCODE == 0 ) -{ -`echo $SIZE >> {dist_postfix_vmail_mailbox_base}/$HOST/$USER/ispconfig_mailsize` -} - - -# -# Test if the user has his own maildrop include, -# if not available, check if $DEFAULT is set -# (newer maildrop get's that from the DB and updates -# it) and deliver or fail temporarily if not available -# - -`test -f {dist_postfix_vmail_mailbox_base}/mailfilters/$HOST/$USER/.mailfilter` -if ( $RETURNCODE == 0 ) -{ - include "{dist_postfix_vmail_mailbox_base}/mailfilters/$HOST/$USER/.mailfilter" -} -else -{ - if ( "$DEFAULT" ne "" ) - { - to "$DEFAULT" - } - else - { - EXITCODE=75 - exit - } -} \ No newline at end of file diff --git a/install/tpl/server.ini.master b/install/tpl/server.ini.master index d5bd6f9e23..172b68b2fa 100644 --- a/install/tpl/server.ini.master +++ b/install/tpl/server.ini.master @@ -38,6 +38,8 @@ homedir_path=/var/vmail maildir_format=maildir dkim_path=/var/lib/amavis/dkim dkim_strength=1024 +content_filter=rspamd +rspamd_password= mailuser_uid=5000 mailuser_gid=5000 mailuser_name=vmail diff --git a/interface/web/admin/form/server_config.tform.php b/interface/web/admin/form/server_config.tform.php index 19938e7690..3eec00e9d8 100644 --- a/interface/web/admin/form/server_config.tform.php +++ b/interface/web/admin/form/server_config.tform.php @@ -331,7 +331,12 @@ $form["tabs"]['server'] = array( ), 'value' => '', 'width' => '40', - 'maxlength' => '255' + 'maxlength' => '255', + 'filters' => array( 0 => array( + 'event' => 'SAVE', + 'type' => 'TRIM' + ), + ) ), 'monit_user' => array( 'datatype' => 'VARCHAR', @@ -345,7 +350,12 @@ $form["tabs"]['server'] = array( 'default' => '', 'value' => '', 'width' => '40', - 'maxlength' => '255' + 'maxlength' => '255', + 'filters' => array( 0 => array( + 'event' => 'SAVE', + 'type' => 'TRIM' + ), + ) ), 'monit_password' => array( 'datatype' => 'VARCHAR', @@ -353,7 +363,12 @@ $form["tabs"]['server'] = array( 'default' => '', 'value' => '', 'width' => '40', - 'maxlength' => '255' + 'maxlength' => '255', + 'filters' => array( 0 => array( + 'event' => 'SAVE', + 'type' => 'TRIM' + ), + ) ), 'munin_url' => array( 'datatype' => 'VARCHAR', @@ -365,7 +380,12 @@ $form["tabs"]['server'] = array( ), 'value' => '', 'width' => '40', - 'maxlength' => '255' + 'maxlength' => '255', + 'filters' => array( 0 => array( + 'event' => 'SAVE', + 'type' => 'TRIM' + ), + ) ), 'munin_user' => array( 'datatype' => 'VARCHAR', @@ -379,7 +399,12 @@ $form["tabs"]['server'] = array( 'default' => '', 'value' => '', 'width' => '40', - 'maxlength' => '255' + 'maxlength' => '255', + 'filters' => array( 0 => array( + 'event' => 'SAVE', + 'type' => 'TRIM' + ), + ) ), 'munin_password' => array( 'datatype' => 'VARCHAR', @@ -387,7 +412,12 @@ $form["tabs"]['server'] = array( 'default' => '', 'value' => '', 'width' => '40', - 'maxlength' => '255' + 'maxlength' => '255', + 'filters' => array( 0 => array( + 'event' => 'SAVE', + 'type' => 'TRIM' + ), + ) ), 'nagios_url' => array( 'datatype' => 'VARCHAR', @@ -399,7 +429,12 @@ $form["tabs"]['server'] = array( ), 'value' => '', 'width' => '40', - 'maxlength' => '255' + 'maxlength' => '255', + 'filters' => array( 0 => array( + 'event' => 'SAVE', + 'type' => 'TRIM' + ), + ) ), 'nagios_user' => array( 'datatype' => 'VARCHAR', @@ -407,7 +442,12 @@ $form["tabs"]['server'] = array( 'default' => '', 'value' => '', 'width' => '40', - 'maxlength' => '255' + 'maxlength' => '255', + 'filters' => array( 0 => array( + 'event' => 'SAVE', + 'type' => 'TRIM' + ), + ) ), 'nagios_password' => array( 'datatype' => 'VARCHAR', @@ -415,7 +455,12 @@ $form["tabs"]['server'] = array( 'default' => '', 'value' => '', 'width' => '40', - 'maxlength' => '255' + 'maxlength' => '255', + 'filters' => array( 0 => array( + 'event' => 'SAVE', + 'type' => 'TRIM' + ), + ) ), 'monitor_system_updates' => array( 'datatype' => 'VARCHAR', @@ -494,6 +539,23 @@ $form["tabs"]['mail'] = array( 'width' => '40', 'maxlength' => '255' ), + 'content_filter' => array( + 'datatype' => 'VARCHAR', + 'formtype' => 'SELECT', + 'default' => 'rspamd', + 'value' => array('amavisd' => 'Amavisd', 'rspamd' => 'Rspamd') + ), + 'rspamd_password' => array( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '40', + 'maxlength' => '255', + 'filters' => array( 0 => array( 'event' => 'SAVE', + 'type' => 'TRIM'), + ), + ), 'dkim_path' => array( 'datatype' => 'VARCHAR', 'formtype' => 'TEXT', diff --git a/interface/web/admin/lib/lang/de_server_config.lng b/interface/web/admin/lib/lang/de_server_config.lng index e3ac698887..f05d36b6ce 100644 --- a/interface/web/admin/lib/lang/de_server_config.lng +++ b/interface/web/admin/lib/lang/de_server_config.lng @@ -299,4 +299,7 @@ $wb['log_retention_txt'] = 'Log retention (days)'; $wb['log_retention_error_ispositive'] = 'Log retention must be a number > 0'; $wb['php_default_name_txt'] = 'Beschreibung Standard PHP'; $wb['php_default_name_error_empty'] = 'Beschreibung Standard PHP ist leer.'; -?> +$wb['content_filter_txt'] = 'Content-Filter'; +$wb['rspamd_url_txt'] = 'Rspamd-URL'; +$wb['rspamd_user_txt'] = 'Rspamd-Benutzer'; +$wb['rspamd_password_txt'] = 'Rspamd-Passwort'; \ No newline at end of file diff --git a/interface/web/admin/lib/lang/en_server_config.lng b/interface/web/admin/lib/lang/en_server_config.lng index 7a960e552a..ce9d6e428f 100644 --- a/interface/web/admin/lib/lang/en_server_config.lng +++ b/interface/web/admin/lib/lang/en_server_config.lng @@ -301,4 +301,8 @@ $wb['log_retention_txt'] = 'Log retention (days)'; $wb['log_retention_error_ispositive'] = 'Log retention must be a number > 0'; $wb['php_default_name_txt'] = 'Description Default PHP-Version'; $wb['php_default_name_error_empty'] = 'Description Default PHP-Version must not be empty'; -?> +$wb['content_filter_txt'] = 'Content Filter'; +$wb['rspamd_url_txt'] = 'Rspamd URL'; +$wb['rspamd_user_txt'] = 'Rspamd User'; +$wb['rspamd_password_txt'] = 'Rspamd Password'; + diff --git a/interface/web/admin/server_config_edit.php b/interface/web/admin/server_config_edit.php index e446bf3add..9c344e0743 100644 --- a/interface/web/admin/server_config_edit.php +++ b/interface/web/admin/server_config_edit.php @@ -52,6 +52,21 @@ $app->load('tform_actions'); class page_action extends tform_actions { + function onShow() { + global $app, $conf; + + // get the config + $app->uses('getconf'); + $web_config = $app->getconf->get_server_config($conf['server_id'], 'web'); + + if($web_config['server_type'] == 'nginx'){ + unset($app->tform->formDef["tabs"]["fastcgi"]); + unset($app->tform->formDef["tabs"]["vlogger"]); + } + + parent::onShow(); + } + function onShowEdit() { global $app, $conf; @@ -64,11 +79,17 @@ class page_action extends tform_actions { $server_id = $this->id; $this->dataRecord = $app->getconf->get_server_config($server_id, $section); + + if($section == 'mail'){ + $server_config = $app->getconf->get_server_config($server_id, 'server'); + $rspamd_url = 'https://'.$server_config['hostname'].':8081/rspamd/'; + } } $record = $app->tform->getHTML($this->dataRecord, $this->active_tab, 'EDIT'); $record['id'] = $this->id; + if(isset($rspamd_url)) $record['rspamd_url'] = $rspamd_url; $app->tpl->setVar($record); } @@ -112,6 +133,49 @@ class page_action extends tform_actions { } } + function onAfterUpdate() { + global $app; + + if(isset($this->dataRecord['content_filter'])){ + $app->uses('ini_parser'); + $old_config = $app->ini_parser->parse_ini_string(stripslashes($this->oldDataRecord['config'])); + if($this->dataRecord['content_filter'] == 'rspamd' && $old_config['mail']['content_filter'] != $this->dataRecord['content_filter']){ + + $spamfilter_users = $app->db->queryAllRecords("SELECT * FROM spamfilter_users WHERE server_id = ?", intval($this->id)); + if(is_array($spamfilter_users) && !empty($spamfilter_users)){ + foreach($spamfilter_users as $spamfilter_user){ + $app->db->datalogUpdate('spamfilter_users', $spamfilter_user, 'id', $spamfilter_user["id"], true); + } + } + + $spamfilter_wblists = $app->db->queryAllRecords("SELECT * FROM spamfilter_wblist WHERE server_id = ?", intval($this->id)); + if(is_array($spamfilter_wblists) && !empty($spamfilter_wblists)){ + foreach($spamfilter_wblists as $spamfilter_wblist){ + $app->db->datalogUpdate('spamfilter_wblist', $spamfilter_wblist, 'wblist_id', $spamfilter_wblist["wblist_id"], true); + } + } + + $mail_users = $app->db->queryAllRecords("SELECT * FROM mail_user WHERE server_id = ? AND (autoresponder = 'y' OR move_junk = 'y')", intval($this->id)); + if(is_array($mail_users) && !empty($mail_users)){ + foreach($mail_users as $mail_user){ + if($mail_user['autoresponder'] == 'y'){ + $mail_user['autoresponder'] = 'n'; + $app->db->datalogUpdate('mail_user', $mail_user, 'mailuser_id', $mail_user["mailuser_id"], true); + $mail_user['autoresponder'] = 'y'; + $app->db->datalogUpdate('mail_user', $mail_user, 'mailuser_id', $mail_user["mailuser_id"], true); + } else { + $mail_user['move_junk'] = 'n'; + $app->db->datalogUpdate('mail_user', $mail_user, 'mailuser_id', $mail_user["mailuser_id"], true); + $mail_user['move_junk'] = 'y'; + $app->db->datalogUpdate('mail_user', $mail_user, 'mailuser_id', $mail_user["mailuser_id"], true); + } + + } + } + } + } + } + } $app->tform_actions = new page_action; diff --git a/interface/web/admin/templates/server_config_mail_edit.htm b/interface/web/admin/templates/server_config_mail_edit.htm index 5323e98b42..9b12dbc0a0 100644 --- a/interface/web/admin/templates/server_config_mail_edit.htm +++ b/interface/web/admin/templates/server_config_mail_edit.htm @@ -32,6 +32,20 @@ {tmpl_var name='dkim_strength'} +
+ +
+
+
+ + +
+
+ +
+
@@ -119,3 +133,24 @@ + + diff --git a/interface/web/mail/form/spamfilter_policy.tform.php b/interface/web/mail/form/spamfilter_policy.tform.php index 31e8b8092a..f0fc645cb8 100644 --- a/interface/web/mail/form/spamfilter_policy.tform.php +++ b/interface/web/mail/form/spamfilter_policy.tform.php @@ -216,6 +216,42 @@ $form["tabs"]['quarantine'] = array ( 'width' => '30', 'maxlength' => '255' ), + 'rspamd_greylisting' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'y', + 'value' => array(0 => 'n', 1 => 'y') + ), + 'rspamd_spam_greylisting_level' => array ( + 'datatype' => 'DOUBLE', + 'formtype' => 'TEXT', + 'default' => '0', + 'value' => '', + 'width' => '10', + 'maxlength' => '255' + ), + 'rspamd_spam_tag_level' => array ( + 'datatype' => 'DOUBLE', + 'formtype' => 'TEXT', + 'default' => '0', + 'value' => '', + 'width' => '10', + 'maxlength' => '255' + ), + 'rspamd_spam_tag_method' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'SELECT', + 'default' => 'rewrite_subject', + 'value' => array('add_header' => $app->lng('add_header_txt'), 'rewrite_subject' => $app->lng('rewrite_subject_txt')) + ), + 'rspamd_spam_kill_level' => array ( + 'datatype' => 'DOUBLE', + 'formtype' => 'TEXT', + 'default' => '0', + 'value' => '', + 'width' => '10', + 'maxlength' => '255' + ), //################################# // ENDE Datatable fields //################################# diff --git a/interface/web/mail/lib/lang/de.lng b/interface/web/mail/lib/lang/de.lng index 91418972dd..108d7d5cc0 100644 --- a/interface/web/mail/lib/lang/de.lng +++ b/interface/web/mail/lib/lang/de.lng @@ -45,4 +45,6 @@ $wb['Global Filters'] = 'Globale Filter'; $wb['Domain Alias'] = 'E-Mail Domain Alias'; $wb['Relay Recipients'] = 'Relay Empfänger'; $wb['Mailbox quota'] = 'E-Mail Konto Speichernutzung'; -?> +$wb['add_header_txt'] = 'Header (fügt "X-Spam: Yes" hinzu)'; +$wb['rewrite_subject_txt'] = 'Betreff (fügt "***SPAM***" am Anfang hinzu)'; + diff --git a/interface/web/mail/lib/lang/de_spamfilter_policy.lng b/interface/web/mail/lib/lang/de_spamfilter_policy.lng index 32acca4686..bb53335eb7 100644 --- a/interface/web/mail/lib/lang/de_spamfilter_policy.lng +++ b/interface/web/mail/lib/lang/de_spamfilter_policy.lng @@ -35,4 +35,11 @@ $wb['bad_header_admin_txt'] = 'Bad Header Administrator'; $wb['spam_admin_txt'] = 'SPAM Administrator'; $wb['message_size_limit_txt'] = 'Nachrichtengrößen Limit'; $wb['banned_rulenames_txt'] = 'Banned Richtliniennamen'; -?> +$wb['rspamd_greylisting_txt'] = 'Greylisting nutzen'; +$wb['rspamd_spam_greylisting_level_txt'] = 'Greylisting-Level'; +$wb['rspamd_spam_tag_level_txt'] = 'SPAM-Markierungslevel'; +$wb['rspamd_spam_tag_method_txt'] = 'SPAM-Markierungsmethode'; +$wb['rspamd_spam_kill_level_txt'] = 'SPAM-Reject-Level'; +$wb['btn_save_txt'] = 'Speichern'; +$wb['btn_cancel_txt'] = 'Abbrechen'; + diff --git a/interface/web/mail/lib/lang/en.lng b/interface/web/mail/lib/lang/en.lng index e320511bbc..d41761d25f 100644 --- a/interface/web/mail/lib/lang/en.lng +++ b/interface/web/mail/lib/lang/en.lng @@ -45,4 +45,5 @@ $wb['Global Filters'] = 'Global Filters'; $wb['Domain Alias'] = 'Domain Alias'; $wb["Relay Recipients"] = 'Relay Recipients'; $wb['Mailbox quota'] = 'Mailbox quota'; -?> +$wb['add_header_txt'] = 'Header (adds "X-Spam: Yes")'; +$wb['rewrite_subject_txt'] = 'Subject (adds "***SPAM***" at the beginning)'; diff --git a/interface/web/mail/lib/lang/en_spamfilter_policy.lng b/interface/web/mail/lib/lang/en_spamfilter_policy.lng index 2e0f05d6c0..f9e8a8e303 100644 --- a/interface/web/mail/lib/lang/en_spamfilter_policy.lng +++ b/interface/web/mail/lib/lang/en_spamfilter_policy.lng @@ -35,4 +35,11 @@ $wb["bad_header_admin_txt"] = 'Bad header admin'; $wb["spam_admin_txt"] = 'SPAM admin'; $wb["message_size_limit_txt"] = 'Message size limit'; $wb["banned_rulenames_txt"] = 'Banned rulenames'; -?> +$wb['rspamd_greylisting_txt'] = 'Use greylisting'; +$wb['rspamd_spam_greylisting_level_txt'] = 'Greylisting level'; +$wb['rspamd_spam_tag_level_txt'] = 'SPAM tag level'; +$wb['rspamd_spam_tag_method_txt'] = 'SPAM tag method'; +$wb['rspamd_spam_kill_level_txt'] = 'SPAM reject level'; +$wb['btn_save_txt'] = 'Save'; +$wb['btn_cancel_txt'] = 'Cancel'; +?> \ No newline at end of file diff --git a/interface/web/mail/mail_domain_edit.php b/interface/web/mail/mail_domain_edit.php index d7d6ea4c68..4d7b7d8d3d 100644 --- a/interface/web/mail/mail_domain_edit.php +++ b/interface/web/mail/mail_domain_edit.php @@ -273,7 +273,10 @@ class page_action extends tform_actions { } //* make sure that the email domain is lowercase - if(isset($this->dataRecord["domain"])) $this->dataRecord["domain"] = strtolower($this->dataRecord["domain"]); + if(isset($this->dataRecord["domain"])){ + $this->dataRecord["domain"] = $app->functions->idn_encode($this->dataRecord["domain"]); + $this->dataRecord["domain"] = strtolower($this->dataRecord["domain"]); + } parent::onSubmit(); diff --git a/interface/web/mail/mail_user_edit.php b/interface/web/mail/mail_user_edit.php index 910d7a096a..263b98ef31 100644 --- a/interface/web/mail/mail_user_edit.php +++ b/interface/web/mail/mail_user_edit.php @@ -295,7 +295,7 @@ class page_action extends tform_actions { "priority" => 10, "policy_id" => $policy_id, "email" => $this->dataRecord["email"], - "fullname" => $this->dataRecord["email"], + "fullname" => $app->functions->idn_decode($this->dataRecord["email"]), "local" => 'Y' ); $app->db->datalogInsert('spamfilter_users', $insert_data, 'id'); @@ -342,7 +342,7 @@ class page_action extends tform_actions { "priority" => 10, "policy_id" => $policy_id, "email" => $this->dataRecord["email"], - "fullname" => $this->dataRecord["email"], + "fullname" => $app->functions->idn_decode($this->dataRecord["email"]), "local" => 'Y' ); $app->db->datalogInsert('spamfilter_users', $insert_data, 'id'); diff --git a/interface/web/mail/spamfilter_policy_edit.php b/interface/web/mail/spamfilter_policy_edit.php index 5320506846..55a42fe847 100644 --- a/interface/web/mail/spamfilter_policy_edit.php +++ b/interface/web/mail/spamfilter_policy_edit.php @@ -49,6 +49,46 @@ $app->uses('tpl,tform,tform_actions'); $app->load('tform_actions'); class page_action extends tform_actions { + + function onShow() { + global $app, $conf; + + // get the config + $app->uses('getconf'); + $mail_config = $app->getconf->get_server_config($conf['server_id'], 'mail'); + + $content_filter = 'amavisd'; + if($mail_config['content_filter'] == 'rspamd'){ + $content_filter = 'rspamd'; + unset($app->tform->formDef["tabs"]["policy"]['fields']['banned_files_lover']); + unset($app->tform->formDef["tabs"]["policy"]['fields']['bad_header_lover']); + unset($app->tform->formDef["tabs"]["policy"]['fields']['bypass_virus_checks']); + unset($app->tform->formDef["tabs"]["policy"]['fields']['bypass_banned_checks']); + unset($app->tform->formDef["tabs"]["policy"]['fields']['bypass_header_checks']); + + unset($app->tform->formDef["tabs"]["taglevel"]['fields']['spam_tag_level']); + unset($app->tform->formDef["tabs"]["taglevel"]['fields']['spam_tag2_level']); + unset($app->tform->formDef["tabs"]["taglevel"]['fields']['spam_kill_level']); + unset($app->tform->formDef["tabs"]["taglevel"]['fields']['spam_dsn_cutoff_level']); + unset($app->tform->formDef["tabs"]["taglevel"]['fields']['spam_quarantine_cutoff_level']); + unset($app->tform->formDef["tabs"]["taglevel"]['fields']['spam_modifies_subj']); + unset($app->tform->formDef["tabs"]["taglevel"]['fields']['spam_subject_tag']); + unset($app->tform->formDef["tabs"]["taglevel"]['fields']['spam_subject_tag2']); + + unset($app->tform->formDef["tabs"]["quarantine"]); + unset($app->tform->formDef["tabs"]["other"]); + } else { + unset($app->tform->formDef["tabs"]["taglevel"]['fields']['rspamd_greylisting']); + unset($app->tform->formDef["tabs"]["taglevel"]['fields']['rspamd_spam_greylisting_level']); + unset($app->tform->formDef["tabs"]["taglevel"]['fields']['rspamd_spam_tag_level']); + unset($app->tform->formDef["tabs"]["taglevel"]['fields']['rspamd_spam_tag_method']); + unset($app->tform->formDef["tabs"]["taglevel"]['fields']['rspamd_spam_kill_level']); + } + $app->tpl->setVar("content_filter", $content_filter); + + parent::onShow(); + } + function onShowNew() { global $app, $conf; @@ -86,11 +126,37 @@ class page_action extends tform_actions { parent::onSubmit(); } + + function onAfterUpdate() { + global $app, $conf; + + $app->uses('getconf'); + $mail_config = $app->getconf->get_server_config($conf['server_id'], 'mail'); + + if($mail_config['content_filter'] == 'rspamd'){ + $record_has_changed = false; + if(isset($this->dataRecord['rspamd_spam_greylisting_level']) && !isset($this->dataRecord['rspamd_greylisting'])) $this->dataRecord['rspamd_greylisting'] = 'n'; + foreach($this->dataRecord as $key => $val) { + if(isset($this->oldDataRecord[$key]) && @$this->oldDataRecord[$key] != $val) { + // Record has changed + $record_has_changed = true; + } + } + + if($record_has_changed){ + $spamfilter_users = $app->db->queryAllRecords("SELECT * FROM spamfilter_users WHERE policy_id = ?", intval($this->id)); + + if(is_array($spamfilter_users) && !empty($spamfilter_users)){ + foreach($spamfilter_users as $spamfilter_user){ + $app->db->datalogUpdate('spamfilter_users', $spamfilter_user, 'id', $spamfilter_user["id"], true); + } + } + } + } + } } $app->tform_actions = new page_action; $app->tform_actions->onLoad(); - - -?> +?> \ No newline at end of file diff --git a/interface/web/mail/spamfilter_policy_list.php b/interface/web/mail/spamfilter_policy_list.php index c2ab38d5f7..2aa7c7bec1 100644 --- a/interface/web/mail/spamfilter_policy_list.php +++ b/interface/web/mail/spamfilter_policy_list.php @@ -16,9 +16,28 @@ $list_def_file = "list/spamfilter_policy.list.php"; $app->auth->check_module_permissions('mail'); $app->uses('listform_actions'); -//$app->listform_actions->SQLExtWhere = "wb = 'W'"; -$app->listform_actions->onLoad(); - - -?> +class list_action extends listform_actions { + + function onShow() { + global $app, $conf; + + // get the config + $app->uses('getconf'); + $mail_config = $app->getconf->get_server_config($conf['server_id'], 'mail'); + + $content_filter = 'amavisd'; + if($mail_config['content_filter'] == 'rspamd'){ + $content_filter = 'rspamd'; + } + $app->tpl->setVar("content_filter", $content_filter); + + parent::onShow(); + } + +} + +$list = new list_action; +//$list->SQLExtWhere = "wb = 'W'"; +$list->onLoad(); +?> \ No newline at end of file diff --git a/interface/web/mail/templates/spamfilter_policy_edit.htm b/interface/web/mail/templates/spamfilter_policy_edit.htm index 317bbdb822..eb8b6c1cbb 100644 --- a/interface/web/mail/templates/spamfilter_policy_edit.htm +++ b/interface/web/mail/templates/spamfilter_policy_edit.htm @@ -20,6 +20,7 @@ {tmpl_var name='spam_lover'} +
- +
-
\ No newline at end of file + diff --git a/interface/web/mail/templates/spamfilter_policy_list.htm b/interface/web/mail/templates/spamfilter_policy_list.htm index da1183d75f..84b1a04403 100644 --- a/interface/web/mail/templates/spamfilter_policy_list.htm +++ b/interface/web/mail/templates/spamfilter_policy_list.htm @@ -19,16 +19,20 @@ + + {tmpl_var name='search_limit'} + + @@ -40,8 +44,10 @@ {tmpl_var name="policy_name"} {tmpl_var name="virus_lover"} {tmpl_var name="spam_lover"} + {tmpl_var name="banned_files_lover"} {tmpl_var name="bad_header_lover"} + @@ -49,17 +55,17 @@ - {tmpl_var name='globalsearch_noresults_text_txt'} + {tmpl_var name='globalsearch_noresults_text_txt'} - + - \ No newline at end of file + diff --git a/interface/web/mail/templates/spamfilter_taglevel_edit.htm b/interface/web/mail/templates/spamfilter_taglevel_edit.htm index ba92662ba6..73fd4e6ac4 100644 --- a/interface/web/mail/templates/spamfilter_taglevel_edit.htm +++ b/interface/web/mail/templates/spamfilter_taglevel_edit.htm @@ -4,7 +4,7 @@

- +
@@ -32,6 +32,33 @@
+
+ +
+ +
+ {tmpl_var name='rspamd_greylisting'} +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
diff --git a/server/conf/apache_apps.vhost.master b/server/conf/apache_apps.vhost.master index ecd3ff1a0e..d77cde2e42 100644 --- a/server/conf/apache_apps.vhost.master +++ b/server/conf/apache_apps.vhost.master @@ -52,6 +52,16 @@ +{tmpl_if name="use_rspamd"} + + Order allow,deny + Allow from all + + RewriteEngine On + RewriteRule ^/rspamd$ /rspamd/ [R,L] + RewriteRule ^/rspamd/(.*) http://127.0.0.1:11334/$1 [P] +{/tmpl_if} + diff --git a/server/conf/autoresponder.master b/server/conf/autoresponder.master index 0126c998d4..3e84b802f2 100644 --- a/server/conf/autoresponder.master +++ b/server/conf/autoresponder.master @@ -4,7 +4,7 @@ if ($RETURNCODE==1) { if (!/^List-Unsubscribe:.*/:h ) { - if (!/^X-Spam-Flag: YES/:h ) + if (!/^(X-Spam-Flag: YES|X-Spam: Yes|Subject: \*\*\*\s*SPAM\s*\*\*\*.*)/:h ) { NOW=time if ({start_date} lt $NOW && {end_date} gt $NOW) @@ -20,4 +20,4 @@ if ($RETURNCODE==1) } } } -} \ No newline at end of file +} diff --git a/server/conf/nginx_apps.vhost.master b/server/conf/nginx_apps.vhost.master index 75daa4df8f..1c8c4e70ae 100644 --- a/server/conf/nginx_apps.vhost.master +++ b/server/conf/nginx_apps.vhost.master @@ -199,4 +199,29 @@ server { alias /var/lib/mailman/archives/public; autoindex on; } + + {use_rspamd}location /rspamd/ { + {use_rspamd}proxy_pass http://127.0.0.1:11334/; + {use_rspamd}rewrite ^//(.*) /$1; + {use_rspamd}proxy_set_header X-Forwarded-Proto $scheme; + {use_rspamd}proxy_set_header Host $host; + {use_rspamd}proxy_set_header X-Real-IP $remote_addr; + {use_rspamd}proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + {use_rspamd}proxy_pass_header Authorization; + {use_rspamd}client_max_body_size 0; + {use_rspamd}client_body_buffer_size 1m; + {use_rspamd}proxy_intercept_errors on; + {use_rspamd}proxy_buffering on; + {use_rspamd}proxy_buffer_size 128k; + {use_rspamd}proxy_buffers 256 16k; + {use_rspamd}proxy_busy_buffers_size 256k; + {use_rspamd}proxy_temp_file_write_size 256k; + {use_rspamd}proxy_max_temp_file_size 0; + {use_rspamd}proxy_read_timeout 300; + {use_rspamd} + {use_rspamd}location ~* ^/rspamd/(.+\.(jpg|jpeg|gif|css|png|js|ico|html?|xml|txt))$ { + {use_rspamd}alias /usr/share/rspamd/www/$1; + {use_rspamd}} + {use_rspamd}} + } diff --git a/server/conf/rspamd.local.lua.master b/server/conf/rspamd.local.lua.master new file mode 100644 index 0000000000..8ef81da264 --- /dev/null +++ b/server/conf/rspamd.local.lua.master @@ -0,0 +1,3 @@ +rspamd_config.R_DUMMY = function (task) + return true +end \ No newline at end of file diff --git a/server/conf/rspamd_antivirus.conf.master b/server/conf/rspamd_antivirus.conf.master new file mode 100644 index 0000000000..71427d7620 --- /dev/null +++ b/server/conf/rspamd_antivirus.conf.master @@ -0,0 +1,30 @@ +clamav { + # If set force this action if any virus is found (default unset: no action is forced) + #action = "reject"; + # if `true` only messages with non-image attachments will be checked (default true) + attachments_only = true; + # If `max_size` is set, messages > n bytes in size are not scanned + #max_size = 20000000; + # symbol to add (add it to metric if you want non-zero weight) + symbol = "CLAM_VIRUS"; + # type of scanner: "clamav", "fprot", "sophos" or "savapi" + type = "clamav"; + # For "savapi" you must also specify the following variable + #product_id = 12345; + # You can enable logging for clean messages + #log_clean = true; + # servers to query (if port is unspecified, scanner-specific default is used) + # can be specified multiple times to pool servers + # can be set to a path to a unix socket + # Enable this in local.d/antivirus.conf + #servers = "127.0.0.1:3310"; + servers = "/var/run/clamav/clamd.ctl"; + # if `patterns` is specified virus name will be matched against provided regexes and the related + # symbol will be yielded if a match is found. If no match is found, default symbol is yielded. + patterns { + # symbol_name = "pattern"; + JUST_EICAR = "^Eicar-Test-Signature$"; + } + # `whitelist` points to a map of IP addresses. Mail from these addresses is not scanned. + whitelist = "/etc/rspamd/antivirus.wl"; +} \ No newline at end of file diff --git a/server/conf/rspamd_classifier-bayes.conf.master b/server/conf/rspamd_classifier-bayes.conf.master new file mode 100644 index 0000000000..1688d57e21 --- /dev/null +++ b/server/conf/rspamd_classifier-bayes.conf.master @@ -0,0 +1,3 @@ +autolearn = [-0.01, 5.00]; +per_user = true; +per_language = true; \ No newline at end of file diff --git a/server/conf/rspamd_dkim_signing.conf.master b/server/conf/rspamd_dkim_signing.conf.master new file mode 100644 index 0000000000..0e55a7ead2 --- /dev/null +++ b/server/conf/rspamd_dkim_signing.conf.master @@ -0,0 +1,2 @@ +path = "/$domain.private"; +selector = "default"; \ No newline at end of file diff --git a/server/conf/rspamd_greylist.conf.master b/server/conf/rspamd_greylist.conf.master new file mode 100644 index 0000000000..74ea715a22 --- /dev/null +++ b/server/conf/rspamd_greylist.conf.master @@ -0,0 +1 @@ +servers = "127.0.0.1:6379"; \ No newline at end of file diff --git a/server/conf/rspamd_metrics.conf.master b/server/conf/rspamd_metrics.conf.master new file mode 100644 index 0000000000..f59eff0f01 --- /dev/null +++ b/server/conf/rspamd_metrics.conf.master @@ -0,0 +1,17 @@ +subject = "***SPAM*** %s"; + +symbol { + weight = 50; + name = "CLAM_VIRUS"; + description = "Clamav has found a virus."; +} +symbol { + weight = 50; + name = "JUST_EICAR"; + description = "Clamav has found a virus."; +} +symbol { + weight = 0.0; + name = "R_DUMMY"; + description = "Dummy symbol"; +} \ No newline at end of file diff --git a/server/conf/rspamd_metrics_override.conf.master b/server/conf/rspamd_metrics_override.conf.master new file mode 100644 index 0000000000..8e3df15edd --- /dev/null +++ b/server/conf/rspamd_metrics_override.conf.master @@ -0,0 +1,159 @@ +# RBL +symbol "RBL_SENDERSCORE" { + weight = 4.0; + description = "From address is listed in senderscore.com BL"; +} +symbol "RBL_SPAMHAUS_SBL" { + weight = 2.0; + description = "From address is listed in zen sbl"; +} +symbol "RBL_SPAMHAUS_CSS" { + weight = 2.0; + description = "From address is listed in zen css"; +} +symbol "RBL_SPAMHAUS_XBL" { + weight = 4.0; + description = "From address is listed in zen xbl"; +} +symbol "RBL_SPAMHAUS_XBL_ANY" { + weight = 4.0; + description = "From or receive address is listed in zen xbl (any list)"; +} +symbol "RBL_SPAMHAUS_PBL" { + weight = 2.0; + description = "From address is listed in zen pbl (ISP list)"; +} +symbol "RBL_SPAMHAUS_DROP" { + weight = 7.0; + description = "From address is listed in zen drop bl"; +} +symbol "RECEIVED_SPAMHAUS_XBL" { + weight = 3.0; + description = "Received address is listed in zen xbl"; + one_shot = true; +} +symbol "RBL_MAILSPIKE_WORST" { + weight = 2.0; + description = "From address is listed in RBL - worst possible reputation"; +} +symbol "RBL_MAILSPIKE_VERYBAD" { + weight = 1.5; + description = "From address is listed in RBL - very bad reputation"; +} +symbol "RBL_MAILSPIKE_BAD" { + weight = 1.0; + description = "From address is listed in RBL - bad reputation"; +} +symbol "RBL_SEM" { + weight = 1.0; + description = "Address is listed in Spameatingmonkey RBL"; +} +# /RBL +# SURBL +symbol "PH_SURBL_MULTI" { + weight = 5.5; + description = "SURBL: Phishing sites"; +} +symbol "MW_SURBL_MULTI" { + weight = 5.5; + description = "SURBL: Malware sites"; +} +symbol "ABUSE_SURBL" { + weight = 5.5; + description = "SURBL: ABUSE"; +} +symbol "CRACKED_SURBL" { + weight = 4.0; + description = "SURBL: cracked site"; +} +symbol "RAMBLER_URIBL" { + weight = 4.5; + description = "Rambler uribl"; + one_shot = true; +} +symbol "RAMBLER_EMAILBL" { + weight = 9.5; + description = "Rambler emailbl"; + one_shot = true; +} +symbol "MSBL_EBL" { + weight = 7.5; + description = "MSBL emailbl"; + one_shot = true; +} +symbol "SEM_URIBL" { + weight = 3.5; + description = "Spameatingmonkey uribl"; +} +symbol "SEM_URIBL_FRESH15" { + weight = 3.0; + description = "Spameatingmonkey uribl. Domains registered in the last 15 days (.AERO,.BIZ,.COM,.INFO,.NAME,.NET,.PRO,.SK,.TEL,.US)"; +} +symbol "DBL" { + weight = 0.0; + description = "DBL unknown result"; +} +symbol "DBL_SPAM" { + weight = 6.5; + description = "DBL uribl spam"; +} +symbol "DBL_PHISH" { + weight = 6.5; + description = "DBL uribl phishing"; +} +symbol "DBL_MALWARE" { + weight = 6.5; + description = "DBL uribl malware"; +} +symbol "DBL_BOTNET" { + weight = 5.5; + description = "DBL uribl botnet C&C domain"; +} +symbol "DBL_ABUSE" { + weight = 6.5; + description = "DBL uribl abused legit spam"; +} +symbol "DBL_ABUSE_REDIR" { + weight = 1.5; + description = "DBL uribl abused spammed redirector domain"; +} +symbol "DBL_ABUSE_PHISH" { + weight = 7.5; + description = "DBL uribl abused legit phish"; +} +symbol "DBL_ABUSE_MALWARE" { + weight = 7.5; + description = "DBL uribl abused legit malware"; +} +symbol "DBL_ABUSE_BOTNET" { + weight = 5.5; + description = "DBL uribl abused legit botnet C&C"; +} +symbol "URIBL_BLACK" { + weight = 7.5; + description = "uribl.com black url"; +} +symbol "URIBL_RED" { + weight = 3.5; + description = "uribl.com red url"; +} +symbol "URIBL_GREY" { + weight = 1.5; + description = "uribl.com grey url"; + one_shot = true; +} +symbol "URIBL_SBL" { + weight = 6.5; + description = "Spamhaus SBL URIBL"; +} +symbol "URIBL_SBL_CSS" { + weight = 6.5; + description = "Spamhaus SBL CSS URIBL"; +} +symbol "RBL_SARBL_BAD" { + weight = 2.5; + description = "A domain listed in the mail is blacklisted in SARBL"; +} +# /SURBL +actions { +} \ No newline at end of file diff --git a/server/conf/rspamd_mx_check.conf.master b/server/conf/rspamd_mx_check.conf.master new file mode 100644 index 0000000000..0a628f9c83 --- /dev/null +++ b/server/conf/rspamd_mx_check.conf.master @@ -0,0 +1,9 @@ +enabled = true; +servers = "localhost"; +key_prefix = "rmx"; +symbol_bad_mx = "MX_INVALID"; +symbol_no_mx = "MX_MISSING"; +symbol_good_mx = "MX_GOOD"; +expire = 86400; +expire_novalid = 7200; +greylist_invalid = false; \ No newline at end of file diff --git a/server/conf/rspamd_users.conf.master b/server/conf/rspamd_users.conf.master new file mode 100644 index 0000000000..975300bf9b --- /dev/null +++ b/server/conf/rspamd_users.conf.master @@ -0,0 +1,43 @@ +settings { + authenticated { + priority = 10; + authenticated = yes; + #apply "default" { groups_disabled = ["rbl", "spf"]; } + apply "default" { + symbols_enabled = []; + symbols_disabled = []; + groups_enabled = []; + groups_disabled = []; + } + } + whitelist { + priority = 10; + rcpt = "postmaster"; + rcpt = "hostmaster"; + rcpt = "abuse"; + want_spam = yes; + } + whitelist-ip { + priority = 10; + + ip = ""; + + + want_spam = yes; + } + whitelist-timmehosting { + priority = 20; + from = "@timmehosting.de"; + from = "@timmehosting.com"; + want_spam = yes; + } + whitelist-ca { + priority = 20; + from = "@comodo.com"; + from = "@geotrust.com"; + from = "@geotrusteurope.com"; + want_spam = yes; + } + .include(try=true; glob=true) "$LOCAL_CONFDIR/local.d/users/*.conf" + .include(try=true; priority=1,duplicate=merge) "$LOCAL_CONFDIR/local.d/users.local.conf" +} diff --git a/server/conf/rspamd_users.inc.conf.master b/server/conf/rspamd_users.inc.conf.master new file mode 100644 index 0000000000..1fe08439a7 --- /dev/null +++ b/server/conf/rspamd_users.inc.conf.master @@ -0,0 +1,41 @@ +spamfilter_users- { + priority = ; + rcpt = ""; + + want_spam = yes; + + + apply "default" { + CLAM_VIRUS = 1999.0; + JUST_EICAR = 1999.0; + actions { + reject = 999.0; + } + } + + + apply "default" { + CLAM_VIRUS = -999.0; + JUST_EICAR = -999.0; + actions { + greylist = ; + + = ; + reject = ; + } + } + + + apply "default" { + CLAM_VIRUS = ; + JUST_EICAR = ; + actions { + greylist = ; + + = ; + reject = ; + } + } + + +} \ No newline at end of file diff --git a/server/conf/rspamd_wblist.inc.conf.master b/server/conf/rspamd_wblist.inc.conf.master new file mode 100644 index 0000000000..fc06127eae --- /dev/null +++ b/server/conf/rspamd_wblist.inc.conf.master @@ -0,0 +1,18 @@ +spamfilter_wblist- { + priority = ; + from = ""; + rcpt = ""; + + want_spam = yes; + + apply "default" { + R_DUMMY = 999.0; + actions { + reject = 0.2; + add_header = 0.1; + greylist = 0.1; + rewrite_subject = 0.1; + } + } + +} \ No newline at end of file diff --git a/server/conf/rspamd_worker-controller.inc.master b/server/conf/rspamd_worker-controller.inc.master new file mode 100644 index 0000000000..75b744c883 --- /dev/null +++ b/server/conf/rspamd_worker-controller.inc.master @@ -0,0 +1,8 @@ +# Included from top-level .conf file + +type = "controller"; +count = 1; +password = ""; +secure_ip = "127.0.0.1"; +secure_ip = "::1"; +static_dir = "${WWWDIR}"; \ No newline at end of file diff --git a/server/conf/sieve_filter.master b/server/conf/sieve_filter.master index bfd75c4d43..13c08dd56b 100644 --- a/server/conf/sieve_filter.master +++ b/server/conf/sieve_filter.master @@ -1,4 +1,4 @@ -require ["fileinto", "regex", "vacation", "imap4flags", "envelope", "subaddress"]; +require ["fileinto", "regex", "date", "relational", "vacation", "imap4flags", "envelope", "subaddress", "copy", "reject"]; # Send a copy of email to @@ -9,7 +9,7 @@ redirect ""; # Move spam to spam folder -if header :contains "X-Spam-Flag" "YES" { +if anyof (header :contains "X-Spam-Flag" "YES", header :contains "X-Spam" "Yes", header :contains "subject" "*** SPAM ***", header :contains "subject" "***SPAM***") { fileinto "Junk"; # Stop here so that we do not reply on spams stop; @@ -26,7 +26,7 @@ keep; ################################################################# # Move spam to spam folder -if header :contains "X-Spam-Flag" "YES" { +if anyof (header :contains "X-Spam-Flag" "YES", header :contains "X-Spam" "Yes", header :contains "subject" "*** SPAM ***", header :contains "subject" "***SPAM***") { fileinto "Junk"; # Stop here so that we do not reply on spams stop; diff --git a/server/conf/sieve_filter_1.2.master b/server/conf/sieve_filter_1.2.master index 8a1c80713f..5244693102 100644 --- a/server/conf/sieve_filter_1.2.master +++ b/server/conf/sieve_filter_1.2.master @@ -1,8 +1,8 @@ -require ["fileinto", "regex", "date", "relational", "vacation", "imap4flags", "envelope", "subaddress"]; +require ["fileinto", "regex", "date", "relational", "vacation", "imap4flags", "envelope", "subaddress", "copy", "reject"]; # Move spam to spam folder -if header :contains "X-Spam-Flag" "YES" { +if anyof (header :contains "X-Spam-Flag" "YES", header :contains "X-Spam" "Yes", header :contains "subject" "*** SPAM ***", header :contains "subject" "***SPAM***") { fileinto "Junk"; # Stop here so that we do not reply on spams stop; @@ -26,7 +26,7 @@ keep; ################################################################# # Move spam to spam folder -if header :contains "X-Spam-Flag" "YES" { +if anyof (header :contains "X-Spam-Flag" "YES", header :contains "X-Spam" "Yes", header :contains "subject" "*** SPAM ***", header :contains "subject" "***SPAM***") { # Stop here so that we do not reply on spams stop; } diff --git a/server/mods-available/mail_module.inc.php b/server/mods-available/mail_module.inc.php index 8460d5d96a..ffb72d68f4 100644 --- a/server/mods-available/mail_module.inc.php +++ b/server/mods-available/mail_module.inc.php @@ -56,6 +56,12 @@ class mail_module { 'mail_mailinglist_insert', 'mail_mailinglist_update', 'mail_mailinglist_delete', + 'spamfilter_users_insert', + 'spamfilter_users_update', + 'spamfilter_users_delete', + 'spamfilter_wblist_insert', + 'spamfilter_wblist_update', + 'spamfilter_wblist_delete', 'mail_ml_member_insert', 'mail_ml_member_update', 'mail_ml_member_delete'); @@ -107,6 +113,10 @@ class mail_module { $app->modules->registerTableHook('mail_mailinglist', 'mail_module', 'process'); $app->modules->registerTableHook('mail_ml_membership', 'mail_module', 'process'); + $app->modules->registerTableHook('spamfilter_users', 'mail_module', 'process'); + $app->modules->registerTableHook('spamfilter_wblist', 'mail_module', 'process'); + + $app->services->registerService('rspamd', 'mail_module', 'restartRspamd'); } /* @@ -163,9 +173,36 @@ class mail_module { if($action == 'u') $app->plugins->raiseEvent('mail_ml_member_update', $data); if($action == 'd') $app->plugins->raiseEvent('mail_ml_member_delete', $data); break; + case 'spamfilter_users': + if($action == 'i') $app->plugins->raiseEvent('spamfilter_users_insert', $data); + if($action == 'u') $app->plugins->raiseEvent('spamfilter_users_update', $data); + if($action == 'd') $app->plugins->raiseEvent('spamfilter_users_delete', $data); + break; + case 'spamfilter_wblist': + if($action == 'i') $app->plugins->raiseEvent('spamfilter_wblist_insert', $data); + if($action == 'u') $app->plugins->raiseEvent('spamfilter_wblist_update', $data); + if($action == 'd') $app->plugins->raiseEvent('spamfilter_wblist_delete', $data); + break; } // end switch } // end function + function restartRspamd($action = 'reload') { + global $app; + + $app->uses('system'); + + $daemon = 'rspamd'; + + $retval = array('output' => '', 'retval' => 0); + if($action == 'restart') { + exec($app->system->getinitcommand($daemon, 'restart').' 2>&1', $retval['output'], $retval['retval']); + } else { + exec($app->system->getinitcommand($daemon, 'reload').' 2>&1', $retval['output'], $retval['retval']); + } + return $retval; + } + + } // end class ?> diff --git a/server/plugins-available/apps_vhost_plugin.inc.php b/server/plugins-available/apps_vhost_plugin.inc.php index b843e3c8a4..32a62174ff 100644 --- a/server/plugins-available/apps_vhost_plugin.inc.php +++ b/server/plugins-available/apps_vhost_plugin.inc.php @@ -106,6 +106,16 @@ class apps_vhost_plugin { $vhost_port_listen = '#'; } $tpl->setVar('vhost_port_listen', $vhost_port_listen); + + $mail_config = $app->getconf->get_server_config($conf['server_id'], 'mail'); + if($mail_config['content_filter'] == 'rspamd'){ + $use_rspamd = true; + exec('/usr/sbin/a2enmod proxy'); + exec('/usr/sbin/a2enmod proxy_http'); + } else { + $use_rspamd = false; + } + $tpl->setVar('use_rspamd', $use_rspamd); $content = $tpl->grab(); @@ -184,6 +194,14 @@ class apps_vhost_plugin { $content = str_replace('{use_tcp}', $use_tcp, $content); $content = str_replace('{use_socket}', $use_socket, $content); + $mail_config = $app->getconf->get_server_config($conf['server_id'], 'mail'); + if($mail_config['content_filter'] == 'rspamd'){ + $use_rspamd = ''; + } else { + $use_rspamd = '#'; + } + $content = str_replace('{use_rspamd}', $use_rspamd, $content); + // Fix socket path on PHP 7 systems if(file_exists('/var/run/php/php7.0-fpm.sock')) $content = str_replace('/var/run/php5-fpm.sock', '/var/run/php/php7.0-fpm.sock', $content); if(file_exists('/var/run/php/php7.1-fpm.sock')) $content = str_replace('/var/run/php5-fpm.sock', '/var/run/php/php7.1-fpm.sock', $content); @@ -221,7 +239,3 @@ class apps_vhost_plugin { } // end class - - - -?> diff --git a/server/plugins-available/postfix_server_plugin.inc.php b/server/plugins-available/postfix_server_plugin.inc.php index 64c5571390..ea0c951dcf 100644 --- a/server/plugins-available/postfix_server_plugin.inc.php +++ b/server/plugins-available/postfix_server_plugin.inc.php @@ -60,15 +60,15 @@ class postfix_server_plugin { Register for the events */ - $app->plugins->registerEvent('server_insert', 'postfix_server_plugin', 'insert'); - $app->plugins->registerEvent('server_update', 'postfix_server_plugin', 'update'); - - + $app->plugins->registerEvent('server_insert', $this->plugin_name, 'insert'); + $app->plugins->registerEvent('server_update', $this->plugin_name, 'update'); + $app->plugins->registerEvent('server_ip_insert', $this->plugin_name, 'server_ip'); + $app->plugins->registerEvent('server_ip_update', $this->plugin_name, 'server_ip'); + $app->plugins->registerEvent('server_ip_delete', $this->plugin_name, 'server_ip'); } function insert($event_name, $data) { - global $app, $conf; $this->update($event_name, $data); @@ -116,7 +116,7 @@ class postfix_server_plugin { if($rbl_hosts != ''){ $rbl_hosts = explode(",", $rbl_hosts); } - $options = explode(", ", exec("postconf -h smtpd_recipient_restrictions")); + $options = preg_split("/,\s*/", exec("postconf -h smtpd_recipient_restrictions")); $new_options = array(); foreach ($options as $key => $value) { if (!preg_match('/reject_rbl_client/', $value)) { @@ -162,7 +162,8 @@ class postfix_server_plugin { } if($app->system->is_installed('dovecot')) { - $temp = exec("postconf -n virtual_transport", $out); + $out = null; + exec("postconf -n virtual_transport", $out); if ($mail_config["mailbox_virtual_uidgid_maps"] == 'y') { // If dovecot switch to lmtp if($out[0] != "virtual_transport = lmtp:unix:private/dovecot-lmtp") { @@ -182,12 +183,139 @@ class postfix_server_plugin { } } - exec("postconf -e 'mailbox_size_limit = ".intval($mail_config['mailbox_size_limit']*1024*1024)."'"); //TODO : no reload? - exec("postconf -e 'message_size_limit = ".intval($mail_config['message_size_limit']*1024*1024)."'"); //TODO : no reload? + if($mail_config['content_filter'] != $old_ini_data['mail']['content_filter']) { + if($mail_config['content_filter'] == 'rspamd'){ + exec("postconf -X 'receive_override_options'"); + exec("postconf -X 'content_filter'"); + + exec("postconf -e 'smtpd_milters = inet:localhost:11332'"); + exec("postconf -e 'milter_protocol = 6'"); + exec("postconf -e 'milter_mail_macros = i {mail_addr} {client_addr} {client_name} {auth_authen}'"); + exec("postconf -e 'milter_default_action = accept'"); + + exec("postconf -e 'smtpd_sender_restrictions = check_sender_access mysql:/etc/postfix/mysql-virtual_sender.cf, permit_mynetworks, permit_sasl_authenticated'"); + + $new_options = array(); + $options = preg_split("/,\s*/", exec("postconf -h smtpd_recipient_restrictions")); + foreach ($options as $key => $value) { + if (!preg_match('/check_policy_service\s+inet:127.0.0.1:10023/', $value)) { + $new_options[] = $value; + } + } + exec("postconf -e 'smtpd_recipient_restrictions = ".implode(", ", $new_options)."'"); + + if(!is_dir('/etc/rspamd/local.d/')){ + $app->system->mkdirpath('/etc/rspamd/local.d/'); + } + + $this->server_ip($event_name, $data); + + if(file_exists($conf['rootpath'].'/conf-custom/rspamd_antivirus.conf.master')) { + exec('cp '.$conf['rootpath'].'/conf-custom/rspamd_antivirus.conf.master /etc/rspamd/local.d/antivirus.conf'); + } else { + exec('cp '.$conf['rootpath'].'/conf/rspamd_antivirus.conf.master /etc/rspamd/local.d/antivirus.conf'); + } + + if(file_exists($conf['rootpath'].'/conf-custom/rspamd_classifier-bayes.conf.master')) { + exec('cp '.$conf['rootpath'].'/conf-custom/rspamd_classifier-bayes.conf.master /etc/rspamd/local.d/classifier-bayes.conf'); + } else { + exec('cp '.$conf['rootpath'].'/conf/rspamd_classifier-bayes.conf.master /etc/rspamd/local.d/classifier-bayes.conf'); + } + + if(file_exists($conf['rootpath'].'/conf-custom/rspamd_greylist.conf.master')) { + exec('cp '.$conf['rootpath'].'/conf-custom/rspamd_greylist.conf.master /etc/rspamd/local.d/greylist.conf'); + } else { + exec('cp '.$conf['rootpath'].'/conf/rspamd_greylist.conf.master /etc/rspamd/local.d/greylist.conf'); + } + + if(file_exists($conf['rootpath'].'/conf-custom/rspamd_metrics.conf.master')) { + exec('cp '.$conf['rootpath'].'/conf-custom/rspamd_metrics.conf.master /etc/rspamd/local.d/metrics.conf'); + } else { + exec('cp '.$conf['rootpath'].'/conf/rspamd_metrics.conf.master /etc/rspamd/local.d/metrics.conf'); + } + + if(file_exists($conf['rootpath'].'/conf-custom/rspamd_metrics_override.conf.master')) { + exec('cp '.$conf['rootpath'].'/conf-custom/rspamd_metrics_override.conf.master /etc/rspamd/override.d/metrics.conf'); + } else { + exec('cp '.$conf['rootpath'].'/conf/rspamd_metrics_override.conf.master /etc/rspamd/override.d/metrics.conf'); + } + + if(file_exists($conf['rootpath'].'/conf-custom/rspamd_mx_check.conf.master')) { + exec('cp '.$conf['rootpath'].'/conf-custom/rspamd_mx_check.conf.master /etc/rspamd/local.d/mx_check.conf'); + } else { + exec('cp '.$conf['rootpath'].'/conf/rspamd_mx_check.conf.master /etc/rspamd/local.d/mx_check.conf'); + } + + if(file_exists($conf['rootpath'].'/conf-custom/rspamd.local.lua.master')) { + exec('cp '.$conf['rootpath'].'/conf-custom/rspamd.local.lua.master /etc/rspamd/rspamd.local.lua'); + } else { + exec('cp '.$conf['rootpath'].'/conf/rspamd.local.lua.master /etc/rspamd/rspamd.local.lua'); + } + + $tpl = new tpl(); + $tpl->newTemplate('rspamd_dkim_signing.conf.master'); + $tpl->setVar('dkim_path', $mail_config['dkim_path']); + $app->system->file_put_contents('/etc/rspamd/local.d/dkim_signing.conf', $tpl->grab()); + + $app->system->add_user_to_group('amavis', '_rspamd'); + + if(strpos($app->system->file_get_contents('/etc/rspamd/rspamd.conf'), '.include "$LOCAL_CONFDIR/local.d/users.conf"') === false){ + $app->uses('file'); + $app->file->af('/etc/rspamd/rspamd.conf', '.include "$LOCAL_CONFDIR/local.d/users.conf"'); + } + + if(is_file('/etc/init.d/rspamd')) $app->services->restartServiceDelayed('rspamd', 'reload'); + } + if($mail_config['content_filter'] == 'amavisd'){ + exec("postconf -X 'smtpd_milters'"); + exec("postconf -X 'milter_protocol'"); + exec("postconf -X 'milter_mail_macros'"); + exec("postconf -X 'milter_default_action'"); + + exec("postconf -e 'receive_override_options = no_address_mappings'"); + exec("postconf -e 'content_filter = amavis:[127.0.0.1]:10024'"); + + exec("postconf -e 'smtpd_sender_restrictions = check_sender_access mysql:/etc/postfix/mysql-virtual_sender.cf regexp:/etc/postfix/tag_as_originating.re, permit_mynetworks, permit_sasl_authenticated, check_sender_access regexp:/etc/postfix/tag_as_foreign.re'"); + } + } + if($mail_config['content_filter'] == 'rspamd' && ($mail_config['rspamd_password'] != $old_ini_data['mail']['rspamd_password'] || $mail_config['content_filter'] != $old_ini_data['mail']['content_filter'])) { + $tpl = new tpl(); + $tpl->newTemplate('rspamd_worker-controller.inc.master'); + $tpl->setVar('rspamd_password', $mail_config['rspamd_password']); + $app->system->file_put_contents('/etc/rspamd/local.d/worker-controller.inc', $tpl->grab()); + if(is_file('/etc/init.d/rspamd')) $app->services->restartServiceDelayed('rspamd', 'reload'); + } + exec("postconf -e 'mailbox_size_limit = ".intval($mail_config['mailbox_size_limit']*1024*1024)."'"); //TODO : no reload? + exec("postconf -e 'message_size_limit = ".intval($mail_config['message_size_limit']*1024*1024)."'"); //TODO : no reload? + } -} // end class + function server_ip($event_name, $data) { + global $app, $conf; + + // get the config + $app->uses("getconf,system"); + $app->load('tpl'); -?> + $mail_config = $app->getconf->get_server_config($conf['server_id'], 'mail'); + + if($mail_config['content_filter'] == 'rspamd'){ + $tpl = new tpl(); + $tpl->newTemplate('rspamd_users.conf.master'); + + $whitelist_ips = array(); + $ips = $app->db->queryAllRecords("SELECT * FROM server_ip WHERE server_id = ?", $conf['server_id']); + if(is_array($ips) && !empty($ips)){ + foreach($ips as $ip){ + $whitelist_ips[] = array('ip' => $ip['ip_address']); + } + } + $tpl->setLoop('whitelist_ips', $whitelist_ips); + $app->system->file_put_contents('/etc/rspamd/local.d/users.conf', $tpl->grab()); + + if(is_file('/etc/init.d/rspamd')) $app->services->restartServiceDelayed('rspamd', 'reload'); + } + } +} // end class diff --git a/server/plugins-available/rspamd_plugin.inc.php b/server/plugins-available/rspamd_plugin.inc.php new file mode 100644 index 0000000000..e3fb16b800 --- /dev/null +++ b/server/plugins-available/rspamd_plugin.inc.php @@ -0,0 +1,210 @@ +plugins->registerEvent('spamfilter_users_insert', $this->plugin_name, 'spamfilter_users_insert'); + $app->plugins->registerEvent('spamfilter_users_update', $this->plugin_name, 'spamfilter_users_update'); + $app->plugins->registerEvent('spamfilter_users_delete', $this->plugin_name, 'spamfilter_users_delete'); + + //* spamfilter_wblist + $app->plugins->registerEvent('spamfilter_wblist_insert', $this->plugin_name, 'spamfilter_wblist_insert'); + $app->plugins->registerEvent('spamfilter_wblist_update', $this->plugin_name, 'spamfilter_wblist_update'); + $app->plugins->registerEvent('spamfilter_wblist_delete', $this->plugin_name, 'spamfilter_wblist_delete'); + } + + function spamfilter_users_insert($event_name, $data) { + global $app, $conf; + + $this->action = 'insert'; + // just run the spamfilter_users_update function + $this->spamfilter_users_update($event_name, $data); + } + + function spamfilter_users_update($event_name, $data) { + global $app, $conf; + + // get the config + $app->uses('getconf,system,functions'); + $mail_config = $app->getconf->get_server_config($conf['server_id'], 'mail'); + + if($mail_config['content_filter'] == 'rspamd'){ + $policy = $app->db->queryOneRecord("SELECT * FROM spamfilter_policy WHERE id = ?", intval($data['new']['policy_id'])); + + //* Create the config file + $user_file = $this->users_config_dir.'spamfilter_user_'.intval($data['new']['id']).'.conf'; + + if($data['new']['local'] == 'Y' && is_array($policy) && !empty($policy)){ + if(!is_dir($this->users_config_dir)){ + $app->system->mkdirpath($this->users_config_dir); + } + + $app->load('tpl'); + + $tpl = new tpl(); + $tpl->newTemplate('rspamd_users.inc.conf.master'); + $tpl->setVar('record_id', intval($data['new']['id'])); + $tpl->setVar('priority', intval($data['new']['priority'])); + $tpl->setVar('recipient', $app->functions->idn_encode($data['new']['email'])); + + $tpl->setVar('rspamd_greylisting', $policy['rspamd_greylisting']); + $tpl->setVar('rspamd_spam_greylisting_level', floatval($policy['rspamd_spam_greylisting_level'])); + + $tpl->setVar('rspamd_spam_tag_level', floatval($policy['rspamd_spam_tag_level'])); + $tpl->setVar('rspamd_spam_tag_method', $policy['rspamd_spam_tag_method']); + + $tpl->setVar('rspamd_spam_kill_level', floatval($policy['rspamd_spam_kill_level'])); + $tpl->setVar('rspamd_virus_kill_level', floatval($policy['rspamd_spam_kill_level']) + 1000); + + $spam_lover_virus_lover = ''; + if($policy['spam_lover'] == 'Y' && $policy['virus_lover'] == 'Y') $spam_lover_virus_lover = 'spam_lover_AND_virus_lover'; + if($policy['spam_lover'] == 'Y' && $policy['virus_lover'] != 'Y') $spam_lover_virus_lover = 'spam_lover_AND_NOTvirus_lover'; + if($policy['spam_lover'] != 'Y' && $policy['virus_lover'] == 'Y') $spam_lover_virus_lover = 'NOTspam_lover_AND_virus_lover'; + if($policy['spam_lover'] != 'Y' && $policy['virus_lover'] != 'Y') $spam_lover_virus_lover = 'NOTspam_lover_AND_NOTvirus_lover'; + + $tpl->setVar('spam_lover_virus_lover', $spam_lover_virus_lover); + + //$groups_disabled = array(); + //if($policy['virus_lover'] == 'Y') $groups_disabled[] = ''; + + $app->system->file_put_contents($user_file, $tpl->grab()); + } else { + if(is_file($user_file)) unlink($user_file); + } + //if(is_file('/etc/init.d/rspamd')) exec('/etc/init.d/rspamd reload &> /dev/null'); + if(is_file('/etc/init.d/rspamd')) $app->services->restartServiceDelayed('rspamd', 'reload'); + } + } + + function spamfilter_users_delete($event_name, $data) { + global $app, $conf; + + // get the config + $app->uses('getconf'); + $mail_config = $app->getconf->get_server_config($conf['server_id'], 'mail'); + + if($mail_config['content_filter'] == 'rspamd'){ + //* delete the config file + $user_file = $this->users_config_dir.'spamfilter_user_'.intval($data['old']['id']).'.conf'; + if(is_file($user_file)) unlink($user_file); + //if(is_file('/etc/init.d/rspamd')) exec('/etc/init.d/rspamd reload &> /dev/null'); + if(is_file('/etc/init.d/rspamd')) $app->services->restartServiceDelayed('rspamd', 'reload'); + } + } + + function spamfilter_wblist_insert($event_name, $data) { + global $app, $conf; + + $this->action = 'insert'; + // just run the spamfilter_wblist_update function + $this->spamfilter_wblist_update($event_name, $data); + } + + function spamfilter_wblist_update($event_name, $data) { + global $app, $conf; + + $app->uses('getconf,system,functions'); + $mail_config = $app->getconf->get_server_config($conf['server_id'], 'mail'); + + if($mail_config['content_filter'] == 'rspamd'){ + $recipient = $app->db->queryOneRecord("SELECT email FROM spamfilter_users WHERE id = ?", intval($data['new']['rid'])); + //* Create the config file + $wblist_file = $this->users_config_dir.'spamfilter_wblist_'.intval($data['new']['wblist_id']).'.conf'; + + if($data['new']['active'] == 'y' && is_array($recipient) && !empty($recipient)){ + if(!is_dir($this->users_config_dir)){ + $app->system->mkdirpath($this->users_config_dir); + } + + $app->load('tpl'); + + $tpl = new tpl(); + $tpl->newTemplate('rspamd_wblist.inc.conf.master'); + $tpl->setVar('record_id', intval($data['new']['wblist_id'])); + $tpl->setVar('priority', intval($data['new']['priority'])); + $tpl->setVar('from', $app->functions->idn_encode($data['new']['email'])); + $tpl->setVar('recipient', $app->functions->idn_encode($recipient['email'])); + //$tpl->setVar('action', ($data['new']['wb'] == 'W'? 'want_spam = yes;' : 'action = "reject";')); + $tpl->setVar('wblist', $data['new']['wb']); + + $app->system->file_put_contents($wblist_file, $tpl->grab()); + } else { + if(is_file($wblist_file)) unlink($wblist_file); + } + //if(is_file('/etc/init.d/rspamd')) exec('/etc/init.d/rspamd reload &> /dev/null'); + if(is_file('/etc/init.d/rspamd')) $app->services->restartServiceDelayed('rspamd', 'reload'); + } + } + + function spamfilter_wblist_delete($event_name, $data) { + global $app, $conf; + + $app->uses('getconf'); + $mail_config = $app->getconf->get_server_config($conf['server_id'], 'mail'); + + if($mail_config['content_filter'] == 'rspamd'){ + //* delete the config file + $wblist_file = $this->users_config_dir.'spamfilter_wblist_'.intval($data['old']['wblist_id']).'.conf'; + if(is_file($wblist_file)) unlink($wblist_file); + //if(is_file('/etc/init.d/rspamd')) exec('/etc/init.d/rspamd reload &> /dev/null'); + if(is_file('/etc/init.d/rspamd')) $app->services->restartServiceDelayed('rspamd', 'reload'); + } + } + +} // end class +?> \ No newline at end of file -- GitLab