Implement Google FBL
This commit is contained in:
8 files changed
+113
-9
No files matched your search
@@ -74,7 +74,11 @@ Generate a keypair for rspamd with `rspamadm keypair gen` and add it to /etc/rsp
|
|||||||
|
|
||||||
Set a password for the web interface with `rspamadm pw` and add the hash for it to /etc/rspamd/override.d/worker-controller.inc
|
Set a password for the web interface with `rspamadm pw` and add the hash for it to /etc/rspamd/override.d/worker-controller.inc
|
||||||
|
|
||||||
Configure the Rspamd dynamic settings map by replacing `CHANGE_ME_TO_A_LONG_RANDOM_SECRET` with the same value in `/var/www/mail/common_config.php` and `/etc/rspamd/rspamd.conf.override`. Generate a secret with `openssl rand -hex 32`. Also replace the example hostname in the Rspamd override URL with your mail server's public hostname. The endpoint returns the settings map in Rspamd's UCL format and is authenticated because the map contains mailbox addresses and filtering preferences. Users can configure exact sender addresses to block or whitelist in their account settings; whitelisting uses Rspamd's `want_spam` option and bypasses all Rspamd checks, including virus scanning.
|
Configure the Rspamd dynamic maps by replacing `CHANGE_ME_TO_A_LONG_RANDOM_SECRET` with the same value in `/var/www/mail/common_config.php`, `/etc/rspamd/rspamd.conf.override`, and `/etc/rspamd/lua/rspamd.local.lua`. Generate a secret with `openssl rand -hex 32`. Also replace the example hostname in both Rspamd URLs with your mail server's public hostname. The authenticated settings endpoint returns Rspamd's UCL settings map; the feedback ID endpoint returns the active mailbox-to-ID map. Users can configure exact sender addresses to block or whitelist in their account settings; whitelisting uses Rspamd's `want_spam` option and bypasses all Rspamd checks, including virus scanning.
|
||||||
|
|
||||||
|
Each mailbox receives a unique 15-character Feedback Loop sender ID. Rspamd adds it to authenticated outgoing messages as `Feedback-ID: :::<id>` before DKIM signing, replacing any existing `Feedback-ID` header so the resulting message contains only one. The account settings and admin mailbox editor display the ID.
|
||||||
|
|
||||||
|
Google FBL reporting requires mail to be DKIM-signed by a domain verified in Google Postmaster Tools. Publish the sending IPs in SPF and ensure the IPs have valid PTR records; FBL reports apply only to Gmail recipients.
|
||||||
|
|
||||||
Generate DKIM signing keys and add them to /etc/rspamd/local.d/arc.conf /etc/rspamd/local.d/dkim_signing.conf, then add the printed DNS records to your domain:
|
Generate DKIM signing keys and add them to /etc/rspamd/local.d/arc.conf /etc/rspamd/local.d/dkim_signing.conf, then add the printed DNS records to your domain:
|
||||||
```
|
```
|
||||||
|
|||||||
+11
-1
@@ -9,7 +9,7 @@ const DBHOST = 'localhost'; // Database host
|
|||||||
const DBUSER = 'postfix'; // Database user
|
const DBUSER = 'postfix'; // Database user
|
||||||
const DBPASS = 'YOUR_PASSWORD'; // Database password
|
const DBPASS = 'YOUR_PASSWORD'; // Database password
|
||||||
const DBNAME = 'postfix'; // Database
|
const DBNAME = 'postfix'; // Database
|
||||||
const DBVERSION = 7; // Database schema version
|
const DBVERSION = 8; // Database schema version
|
||||||
const INACTIVITY_PERIOD_MONTHS = [1, 6, 12, 24]; // Allowed inactivity periods in months - don't forget to update get_inactivity_period_options on changes here and if an option is removed, you should also update accounts in the database mailbox table
|
const INACTIVITY_PERIOD_MONTHS = [1, 6, 12, 24]; // Allowed inactivity periods in months - don't forget to update get_inactivity_period_options on changes here and if an option is removed, you should also update accounts in the database mailbox table
|
||||||
const DEFAULT_INACTIVITY_PERIOD = 12; // Default inactivity period in months
|
const DEFAULT_INACTIVITY_PERIOD = 12; // Default inactivity period in months
|
||||||
const ALLOW_ACCOUNT_NEVER_DELETE = false; // Whether to allow users to set their inactivity period to "never delete"
|
const ALLOW_ACCOUNT_NEVER_DELETE = false; // Whether to allow users to set their inactivity period to "never delete"
|
||||||
@@ -101,6 +101,16 @@ function get_inactivity_period_options(): array
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function generate_feedback_id( PDO $db ): string
|
||||||
|
{
|
||||||
|
$stmt = $db->prepare( 'SELECT 1 FROM mailbox WHERE feedback_id = ? LIMIT 1;' );
|
||||||
|
do {
|
||||||
|
$feedback_id = substr( bin2hex( random_bytes( 8 ) ), 0, 15 );
|
||||||
|
$stmt->execute( [ $feedback_id ] );
|
||||||
|
} while ( $stmt->fetchColumn() );
|
||||||
|
return $feedback_id;
|
||||||
|
}
|
||||||
|
|
||||||
function get_db_instance(): PDO
|
function get_db_instance(): PDO
|
||||||
{
|
{
|
||||||
static $db = null;
|
static $db = null;
|
||||||
|
|||||||
@@ -6,3 +6,50 @@ rspamd_config.AUTHENTICATED_USER = {
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local lua_mime = require "lua_mime"
|
||||||
|
local lua_util = require "lua_util"
|
||||||
|
local rspamd_logger = require "rspamd_logger"
|
||||||
|
local feedback_ids = rspamd_config:add_map{
|
||||||
|
type = 'map',
|
||||||
|
url = 'https://mail.danwin1210.de/rspamd_feedback_ids.php?token=CHANGE_ME_TO_A_LONG_RANDOM_SECRET',
|
||||||
|
description = 'Google Feedback Loop sender IDs',
|
||||||
|
}
|
||||||
|
|
||||||
|
if not feedback_ids then
|
||||||
|
error('cannot load Google Feedback Loop sender ID map')
|
||||||
|
end
|
||||||
|
|
||||||
|
rspamd_config:register_symbol{
|
||||||
|
name = 'GOOGLE_FEEDBACK_ID',
|
||||||
|
type = 'prefilter',
|
||||||
|
priority = lua_util.symbols_priorities.top,
|
||||||
|
flags = 'empty,nostat',
|
||||||
|
callback = function(task)
|
||||||
|
local user = task:get_user()
|
||||||
|
if not user then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local feedback_id = feedback_ids:get_key(user:lower())
|
||||||
|
if not feedback_id then
|
||||||
|
rspamd_logger.errx(task, 'no Google Feedback Loop ID found for authenticated user %s', user)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if #feedback_id < 5 or #feedback_id > 15 or not feedback_id:match('^[a-f0-9]$') then
|
||||||
|
rspamd_logger.errx(task, 'invalid Google Feedback Loop ID for authenticated user %s', user)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
lua_mime.modify_headers(task, {
|
||||||
|
remove = { ['Feedback-ID'] = 0 },
|
||||||
|
add = {
|
||||||
|
['Feedback-ID'] = {
|
||||||
|
order = 1,
|
||||||
|
value = ':::' .. feedback_id,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
order = { 'Feedback-ID' },
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
}
|
||||||
@@ -1098,3 +1098,7 @@ msgstr ""
|
|||||||
#: www/manage_account.php:492
|
#: www/manage_account.php:492
|
||||||
msgid "Update sender rules"
|
msgid "Update sender rules"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: www/manage_account.php www/admin.php
|
||||||
|
msgid "Google Feedback Loop ID"
|
||||||
|
msgstr ""
|
||||||
@@ -36,7 +36,7 @@ $createTableStatements = [
|
|||||||
'dmarc_report_record_reason' => "CREATE TABLE IF NOT EXISTS `dmarc_report_record_reason` (`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `record_id` bigint(20) unsigned NOT NULL, `type` varchar(255) NOT NULL, `comment` varchar(255) NOT NULL, PRIMARY KEY (`id`), KEY `record_id` (`record_id`), CONSTRAINT `dmarc_report_record_reason_ibfk_1` FOREIGN KEY (`record_id`) REFERENCES `dmarc_report_records` (`id`) ON DELETE CASCADE) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;",
|
'dmarc_report_record_reason' => "CREATE TABLE IF NOT EXISTS `dmarc_report_record_reason` (`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `record_id` bigint(20) unsigned NOT NULL, `type` varchar(255) NOT NULL, `comment` varchar(255) NOT NULL, PRIMARY KEY (`id`), KEY `record_id` (`record_id`), CONSTRAINT `dmarc_report_record_reason_ibfk_1` FOREIGN KEY (`record_id`) REFERENCES `dmarc_report_records` (`id`) ON DELETE CASCADE) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;",
|
||||||
'dmarc_report_record_spf_result' => "CREATE TABLE IF NOT EXISTS `dmarc_report_record_spf_result` (`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `record_id` bigint(20) unsigned NOT NULL, `domain` varchar(255) NOT NULL, `result` varchar(255) NOT NULL, `scope` varchar(255) NOT NULL, PRIMARY KEY (`id`), KEY `record_id` (`record_id`), CONSTRAINT `dmarc_report_record_spf_result_ibfk_2` FOREIGN KEY (`record_id`) REFERENCES `dmarc_report_records` (`id`) ON DELETE CASCADE ON UPDATE CASCADE) DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;",
|
'dmarc_report_record_spf_result' => "CREATE TABLE IF NOT EXISTS `dmarc_report_record_spf_result` (`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `record_id` bigint(20) unsigned NOT NULL, `domain` varchar(255) NOT NULL, `result` varchar(255) NOT NULL, `scope` varchar(255) NOT NULL, PRIMARY KEY (`id`), KEY `record_id` (`record_id`), CONSTRAINT `dmarc_report_record_spf_result_ibfk_2` FOREIGN KEY (`record_id`) REFERENCES `dmarc_report_records` (`id`) ON DELETE CASCADE ON UPDATE CASCADE) DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;",
|
||||||
'domain_admins' => "CREATE TABLE IF NOT EXISTS `domain_admins` (`username` varchar(255) NOT NULL, `domain` varchar(255) NOT NULL, `created` datetime NOT NULL DEFAULT '2000-01-01 00:00:00', `active` tinyint(1) NOT NULL DEFAULT 1, `id` bigint(20) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`), KEY `username` (`username`), KEY `active` (`active`), KEY `domain` (`domain`), CONSTRAINT `domain_admins_ibfk_1` FOREIGN KEY (`domain`) REFERENCES `domain` (`domain`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `domain_admins_ibfk_2` FOREIGN KEY (`username`) REFERENCES `admin` (`username`) ON DELETE CASCADE ON UPDATE CASCADE) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;",
|
'domain_admins' => "CREATE TABLE IF NOT EXISTS `domain_admins` (`username` varchar(255) NOT NULL, `domain` varchar(255) NOT NULL, `created` datetime NOT NULL DEFAULT '2000-01-01 00:00:00', `active` tinyint(1) NOT NULL DEFAULT 1, `id` bigint(20) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`), KEY `username` (`username`), KEY `active` (`active`), KEY `domain` (`domain`), CONSTRAINT `domain_admins_ibfk_1` FOREIGN KEY (`domain`) REFERENCES `domain` (`domain`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `domain_admins_ibfk_2` FOREIGN KEY (`username`) REFERENCES `admin` (`username`) ON DELETE CASCADE ON UPDATE CASCADE) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;",
|
||||||
'mailbox' => "CREATE TABLE IF NOT EXISTS `mailbox` (`username` varchar(255) NOT NULL, `password` varchar(255) NOT NULL DEFAULT '', `quota` bigint(20) NOT NULL DEFAULT 0, `local_part` varchar(255) NOT NULL DEFAULT '', `domain` varchar(255) NOT NULL DEFAULT '', `created` datetime NOT NULL DEFAULT current_timestamp(), `modified` datetime NOT NULL DEFAULT current_timestamp(), `active` tinyint(1) NOT NULL DEFAULT 1, `password_hash_type` varchar(20) NOT NULL DEFAULT '', `openpgpkey_wkd` char(32) NOT NULL DEFAULT '', `pgp_key` text DEFAULT NULL, `pgp_verified` tinyint(1) NOT NULL DEFAULT 0, `tfa` tinyint(1) NOT NULL DEFAULT 0, `totp_secret` varchar(64) DEFAULT NULL, `last_login` bigint(20) unsigned DEFAULT NULL, `inactivity_period` tinyint unsigned NOT NULL DEFAULT 12, `spam_reject_score` tinyint unsigned NOT NULL DEFAULT 15, `blocked_senders` text NOT NULL DEFAULT '', `whitelisted_senders` text NOT NULL DEFAULT '', `enforce_tls_in` tinyint(1) NOT NULL DEFAULT 1, `enforce_tls_out` tinyint(1) NOT NULL DEFAULT 1, PRIMARY KEY (`username`), KEY `domain` (`domain`), KEY `active` (`active`), KEY `openpgpkey_wkd` (`openpgpkey_wkd`), KEY `inactivity_period` (`inactivity_period`), KEY `spam_reject_score` (`spam_reject_score`), CONSTRAINT `mailbox_ibfk_2` FOREIGN KEY (`domain`) REFERENCES `domain` (`domain`) ON UPDATE CASCADE) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;",
|
'mailbox' => "CREATE TABLE IF NOT EXISTS `mailbox` (`username` varchar(255) NOT NULL, `password` varchar(255) NOT NULL DEFAULT '', `quota` bigint(20) NOT NULL DEFAULT 0, `local_part` varchar(255) NOT NULL DEFAULT '', `domain` varchar(255) NOT NULL DEFAULT '', `created` datetime NOT NULL DEFAULT current_timestamp(), `modified` datetime NOT NULL DEFAULT current_timestamp(), `active` tinyint(1) NOT NULL DEFAULT 1, `password_hash_type` varchar(20) NOT NULL DEFAULT '', `openpgpkey_wkd` char(32) NOT NULL DEFAULT '', `pgp_key` text DEFAULT NULL, `pgp_verified` tinyint(1) NOT NULL DEFAULT 0, `tfa` tinyint(1) NOT NULL DEFAULT 0, `totp_secret` varchar(64) DEFAULT NULL, `last_login` bigint(20) unsigned DEFAULT NULL, `inactivity_period` tinyint unsigned NOT NULL DEFAULT 12, `spam_reject_score` tinyint unsigned NOT NULL DEFAULT 15, `blocked_senders` text NOT NULL DEFAULT '', `whitelisted_senders` text NOT NULL DEFAULT '', `feedback_id` char(15) CHARACTER SET ascii COLLATE ascii_bin NOT NULL, `enforce_tls_in` tinyint(1) NOT NULL DEFAULT 1, `enforce_tls_out` tinyint(1) NOT NULL DEFAULT 1, PRIMARY KEY (`username`), UNIQUE KEY `feedback_id` (`feedback_id`), KEY `domain` (`domain`), KEY `active` (`active`), KEY `openpgpkey_wkd` (`openpgpkey_wkd`), KEY `inactivity_period` (`inactivity_period`), KEY `spam_reject_score` (`spam_reject_score`), CONSTRAINT `mailbox_ibfk_2` FOREIGN KEY (`domain`) REFERENCES `domain` (`domain`) ON UPDATE CASCADE) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;",
|
||||||
'monitored_mailboxes' => "CREATE TABLE IF NOT EXISTS `monitored_mailboxes` (`username` varchar(255) NOT NULL, `last_login` int(11) NOT NULL, PRIMARY KEY (`username`), KEY `lastlogin` (`last_login`), CONSTRAINT `monitored_mailboxes_ibfk_1` FOREIGN KEY (`username`) REFERENCES `mailbox` (`username`) ON DELETE CASCADE ON UPDATE CASCADE) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;",
|
'monitored_mailboxes' => "CREATE TABLE IF NOT EXISTS `monitored_mailboxes` (`username` varchar(255) NOT NULL, `last_login` int(11) NOT NULL, PRIMARY KEY (`username`), KEY `lastlogin` (`last_login`), CONSTRAINT `monitored_mailboxes_ibfk_1` FOREIGN KEY (`username`) REFERENCES `mailbox` (`username`) ON DELETE CASCADE ON UPDATE CASCADE) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;",
|
||||||
'tls_report' => "CREATE TABLE IF NOT EXISTS `tls_report` (`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `report_id` varchar(255) NOT NULL, `organization` varchar(255) NOT NULL, `contact` varchar(255) NOT NULL, `start` datetime NOT NULL, `end` datetime NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `report_id_organization` (`report_id`,`organization`), KEY `start_end` (`start`,`end`)) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;",
|
'tls_report' => "CREATE TABLE IF NOT EXISTS `tls_report` (`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `report_id` varchar(255) NOT NULL, `organization` varchar(255) NOT NULL, `contact` varchar(255) NOT NULL, `start` datetime NOT NULL, `end` datetime NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `report_id_organization` (`report_id`,`organization`), KEY `start_end` (`start`,`end`)) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;",
|
||||||
'tls_report_policy' => "CREATE TABLE IF NOT EXISTS `tls_report_policy` (`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `report_id` bigint(20) unsigned NOT NULL, `policy_type` varchar(255) NOT NULL, `policy_string` text NOT NULL, `policy_domain` varchar(255) NOT NULL, `mx_host` text NOT NULL, `success` int(11) NOT NULL, `failure` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `report_id` (`report_id`), KEY `policy_domain` (`policy_domain`), CONSTRAINT `tls_report_policy_ibfk_1` FOREIGN KEY (`report_id`) REFERENCES `tls_report` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `tls_report_policy_ibfk_3` FOREIGN KEY (`policy_domain`) REFERENCES `domain` (`domain`) ON DELETE CASCADE) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;",
|
'tls_report_policy' => "CREATE TABLE IF NOT EXISTS `tls_report_policy` (`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `report_id` bigint(20) unsigned NOT NULL, `policy_type` varchar(255) NOT NULL, `policy_string` text NOT NULL, `policy_domain` varchar(255) NOT NULL, `mx_host` text NOT NULL, `success` int(11) NOT NULL, `failure` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `report_id` (`report_id`), KEY `policy_domain` (`policy_domain`), CONSTRAINT `tls_report_policy_ibfk_1` FOREIGN KEY (`report_id`) REFERENCES `tls_report` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `tls_report_policy_ibfk_3` FOREIGN KEY (`policy_domain`) REFERENCES `domain` (`domain`) ON DELETE CASCADE) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;",
|
||||||
@@ -91,6 +91,22 @@ try{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ( $version < 8 ) {
|
||||||
|
$stmt = $db->query( "SHOW COLUMNS FROM `mailbox` LIKE 'feedback_id';" );
|
||||||
|
if ( ! $stmt->fetch() ) {
|
||||||
|
$db->exec( 'ALTER TABLE `mailbox` ADD COLUMN `feedback_id` char(15) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL AFTER `whitelisted_senders`;' );
|
||||||
|
}
|
||||||
|
$stmt = $db->query( "SELECT `username` FROM `mailbox` WHERE `feedback_id` IS NULL OR `feedback_id` = '';" );
|
||||||
|
$update_feedback_id = $db->prepare( 'UPDATE `mailbox` SET `feedback_id` = ? WHERE `username` = ?;' );
|
||||||
|
while ( $mailbox = $stmt->fetch( PDO::FETCH_ASSOC ) ) {
|
||||||
|
$update_feedback_id->execute( [ generate_feedback_id( $db ), $mailbox[ 'username' ] ] );
|
||||||
|
}
|
||||||
|
$stmt = $db->query( "SHOW INDEX FROM `mailbox` WHERE `Key_name` = 'feedback_id';" );
|
||||||
|
if ( ! $stmt->fetch() ) {
|
||||||
|
$db->exec( 'ALTER TABLE `mailbox` ADD UNIQUE INDEX `feedback_id` (`feedback_id`);' );
|
||||||
|
}
|
||||||
|
$db->exec( 'ALTER TABLE `mailbox` MODIFY COLUMN `feedback_id` char(15) CHARACTER SET ascii COLLATE ascii_bin NOT NULL;' );
|
||||||
|
}
|
||||||
$db->beginTransaction();
|
$db->beginTransaction();
|
||||||
$stmt=$db->prepare("UPDATE `settings` SET `value`=? WHERE `setting`='version';");
|
$stmt=$db->prepare("UPDATE `settings` SET `value`=? WHERE `setting`='version';");
|
||||||
$stmt->execute([DBVERSION]);
|
$stmt->execute([DBVERSION]);
|
||||||
|
|||||||
+4
-3
@@ -398,8 +398,8 @@ if ( $_SERVER[ 'REQUEST_METHOD' ] === 'POST' ) {
|
|||||||
$alias_goto = rtrim( $alias_goto, ',' );
|
$alias_goto = rtrim( $alias_goto, ',' );
|
||||||
$stmt = $db->prepare( 'INSERT INTO alias (address, goto, domain, created, modified, enforce_tls_in, active) VALUES (?, ?, ?, NOW(), NOW(), ?, ?);' );
|
$stmt = $db->prepare( 'INSERT INTO alias (address, goto, domain, created, modified, enforce_tls_in, active) VALUES (?, ?, ?, NOW(), NOW(), ?, ?);' );
|
||||||
$stmt->execute( [ $email, $alias_goto, $domain, ( isset( $_POST[ 'enforce_tls_in' ] ) ? 1 : 0 ), ( isset( $_POST[ 'active' ] ) ? 1 : 0 ) ] );
|
$stmt->execute( [ $email, $alias_goto, $domain, ( isset( $_POST[ 'enforce_tls_in' ] ) ? 1 : 0 ), ( isset( $_POST[ 'active' ] ) ? 1 : 0 ) ] );
|
||||||
$stmt = $db->prepare( 'INSERT INTO mailbox (username, password, quota, local_part, domain, created, modified, password_hash_type, openpgpkey_wkd, enforce_tls_in, enforce_tls_out, active) VALUES(?, ?, ?, ?, ?, NOW(), NOW(), ?, ?, ?, ?, ?);' );
|
$stmt = $db->prepare( 'INSERT INTO mailbox (username, password, quota, local_part, domain, created, modified, password_hash_type, openpgpkey_wkd, feedback_id, enforce_tls_in, enforce_tls_out, active) VALUES(?, ?, ?, ?, ?, NOW(), NOW(), ?, ?, ?, ?, ?, ?);' );
|
||||||
$stmt->execute( [ $email, $hash, DEFAULT_QUOTA, $user, $domain, '{ARGON2ID}', z_base32_encode( hash( 'sha1', mb_strtolower( $user ), true ) ), ( isset( $_POST[ 'enforce_tls_in' ] ) ? 1 : 0 ), ( isset( $_POST[ 'enforce_tls_out' ] ) ? 1 : 0 ), ( isset( $_POST[ 'active' ] ) ? 1 : 0 ) ] );
|
$stmt->execute( [ $email, $hash, DEFAULT_QUOTA, $user, $domain, '{ARGON2ID}', z_base32_encode( hash( 'sha1', mb_strtolower( $user ), true ) ), generate_feedback_id( $db ), ( isset( $_POST[ 'enforce_tls_in' ] ) ? 1 : 0 ), ( isset( $_POST[ 'enforce_tls_out' ] ) ? 1 : 0 ), ( isset( $_POST[ 'active' ] ) ? 1 : 0 ) ] );
|
||||||
$msg .= '<div class="green" role="alert">'.htmlspecialchars(_('Successfully created new mailbox!')).'</div>';
|
$msg .= '<div class="green" role="alert">'.htmlspecialchars(_('Successfully created new mailbox!')).'</div>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1171,13 +1171,14 @@ function send_new_mailbox(): void
|
|||||||
function send_edit_mailbox(): void
|
function send_edit_mailbox(): void
|
||||||
{
|
{
|
||||||
$db = get_db_instance();
|
$db = get_db_instance();
|
||||||
$stmt = $db->prepare( 'SELECT a.goto, m.active, m.enforce_tls_in, m.enforce_tls_out, m.inactivity_period, m.spam_reject_score, m.blocked_senders, m.whitelisted_senders FROM alias AS a INNER JOIN mailbox AS m ON (m.username=a.address) WHERE m.username = ?;' );
|
$stmt = $db->prepare( 'SELECT a.goto, m.active, m.enforce_tls_in, m.enforce_tls_out, m.inactivity_period, m.spam_reject_score, m.blocked_senders, m.whitelisted_senders, m.feedback_id FROM alias AS a INNER JOIN mailbox AS m ON (m.username=a.address) WHERE m.username = ?;' );
|
||||||
$stmt->execute( [ $_REQUEST[ 'user' ] ] );
|
$stmt->execute( [ $_REQUEST[ 'user' ] ] );
|
||||||
if ( $email = $stmt->fetch( PDO::FETCH_ASSOC ) ) {
|
if ( $email = $stmt->fetch( PDO::FETCH_ASSOC ) ) {
|
||||||
$aliases = explode( ',', $email[ 'goto' ] );
|
$aliases = explode( ',', $email[ 'goto' ] );
|
||||||
$aliases_to = implode( "\n", array_diff( $aliases, [ $_REQUEST[ 'user' ] ] ) );
|
$aliases_to = implode( "\n", array_diff( $aliases, [ $_REQUEST[ 'user' ] ] ) );
|
||||||
?>
|
?>
|
||||||
<h2><?php printf(htmlspecialchars(_('Edit mailbox %s')), htmlspecialchars( $_REQUEST[ 'user' ] ) ); ?></h2>
|
<h2><?php printf(htmlspecialchars(_('Edit mailbox %s')), htmlspecialchars( $_REQUEST[ 'user' ] ) ); ?></h2>
|
||||||
|
<p><?php echo htmlspecialchars(_('Google Feedback Loop ID')); ?>: <code>:::<?php echo htmlspecialchars( $email[ 'feedback_id' ] ); ?></code></p>
|
||||||
<form class="form_limit" action="admin.php" method="post">
|
<form class="form_limit" action="admin.php" method="post">
|
||||||
<input type="hidden" name="csrf_token" value="<?php echo $_SESSION[ 'csrf_token' ]; ?>">
|
<input type="hidden" name="csrf_token" value="<?php echo $_SESSION[ 'csrf_token' ]; ?>">
|
||||||
<input type="hidden" name="user" value="<?php echo htmlspecialchars( $_REQUEST[ 'user' ] ); ?>">
|
<input type="hidden" name="user" value="<?php echo htmlspecialchars( $_REQUEST[ 'user' ] ); ?>">
|
||||||
|
|||||||
+2
-3
@@ -69,8 +69,8 @@ if ( isset( $_POST[ 'user' ] ) ) {
|
|||||||
$hash = password_hash( $_POST[ 'pwd' ], PASSWORD_ARGON2ID );
|
$hash = password_hash( $_POST[ 'pwd' ], PASSWORD_ARGON2ID );
|
||||||
$stmt = $db->prepare( 'INSERT INTO alias (address, goto, domain, created, modified) VALUES (?, ?, ?, NOW(), NOW());' );
|
$stmt = $db->prepare( 'INSERT INTO alias (address, goto, domain, created, modified) VALUES (?, ?, ?, NOW(), NOW());' );
|
||||||
$stmt->execute( [ "$user@$domain", "$user@$domain", $domain ] );
|
$stmt->execute( [ "$user@$domain", "$user@$domain", $domain ] );
|
||||||
$stmt = $db->prepare( 'INSERT INTO mailbox (username, password, quota, local_part, domain, created, modified, password_hash_type, openpgpkey_wkd) VALUES(?, ?, ?, ?, ?, NOW(), NOW(), ?, ?);' );
|
$stmt = $db->prepare( 'INSERT INTO mailbox (username, password, quota, local_part, domain, created, modified, password_hash_type, openpgpkey_wkd, feedback_id) VALUES(?, ?, ?, ?, ?, NOW(), NOW(), ?, ?, ?);' );
|
||||||
$stmt->execute( [ "$user@$domain", $hash, DEFAULT_QUOTA, $user, $domain, '{ARGON2ID}', z_base32_encode( hash( 'sha1', mb_strtolower( $user ), true ) ) ] );
|
$stmt->execute( [ "$user@$domain", $hash, DEFAULT_QUOTA, $user, $domain, '{ARGON2ID}', z_base32_encode( hash( 'sha1', mb_strtolower( $user ), true ) ), generate_feedback_id( $db ) ] );
|
||||||
$msg .= '<div class="green" role="alert">'.htmlspecialchars(_('Successfully created new mailbox!')).'</div>';
|
$msg .= '<div class="green" role="alert">'.htmlspecialchars(_('Successfully created new mailbox!')).'</div>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -135,4 +135,3 @@ if( ! REGISTRATION_ENABLED ) {
|
|||||||
</main>
|
</main>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
require_once( '../common_config.php' );
|
||||||
|
|
||||||
|
header( 'Content-Type: text/plain; charset=utf-8' );
|
||||||
|
header( 'Cache-Control: no-store' );
|
||||||
|
header( 'Expires: 600' );
|
||||||
|
|
||||||
|
$token = $_GET[ 'token' ] ?? '';
|
||||||
|
if ( ! in_array( $_SERVER[ 'REQUEST_METHOD' ], [ 'GET', 'HEAD' ], true ) || ! hash_equals( RSPAMD_SETTINGS_MAP_TOKEN, $token ) ) {
|
||||||
|
http_response_code( 403 );
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$db = get_db_instance();
|
||||||
|
$stmt = $db->query( 'SELECT username, feedback_id FROM mailbox WHERE active = 1;' );
|
||||||
|
while ( $mailbox = $stmt->fetch( PDO::FETCH_ASSOC ) ) {
|
||||||
|
if ( ! preg_match( '/^[a-f0-9]{5,15}$/', $mailbox[ 'feedback_id' ] ) ) {
|
||||||
|
http_response_code( 500 );
|
||||||
|
error_log( 'Invalid Google Feedback Loop ID for mailbox ' . $mailbox[ 'username' ] );
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
echo mb_strtolower( $mailbox[ 'username' ] ) . "\t" . $mailbox[ 'feedback_id' ] . "\n";
|
||||||
|
}
|
||||||
Reference in new issue
Block a user