Initial regexp-send-only alias implementation

This commit is contained in:
Noah Overcash 2024-06-02 13:55:56 -04:00
parent f8b3f40276
commit a479b2015d
No known key found for this signature in database
7 changed files with 37 additions and 1 deletions

View file

@ -138,6 +138,7 @@ function _postfix_dovecot_changes() {
# Regenerate system + virtual account aliases via `helpers/aliases.sh`:
[[ ${CHANGED} =~ ${DMS_DIR}/postfix-virtual.cf ]] && _handle_postfix_virtual_config
[[ ${CHANGED} =~ ${DMS_DIR}/postfix-regexp.cf ]] && _handle_postfix_regexp_config
[[ ${CHANGED} =~ ${DMS_DIR}/postfix-regexp-send-only.cf ]] && _handle_postfix_regexp_send_only_config
[[ ${CHANGED} =~ ${DMS_DIR}/postfix-aliases.cf ]] && _handle_postfix_aliases_config
# Legacy workaround handled here, only seems necessary for _create_accounts:

View file

@ -30,6 +30,17 @@ function _handle_postfix_regexp_config() {
fi
}
function _handle_postfix_regexp_send_only_config() {
: >/etc/postfix/regexp-send-only
if [[ -f /tmp/docker-mailserver/postfix-regexp-send-only.cf ]]; then
_log 'trace' "Adding regexp-send-only alias file postfix-regexp-send-only.cf"
cp -f /tmp/docker-mailserver/postfix-regexp-send-only.cf /etc/postfix/regexp-send-only
# we specifically do NOT append this to virtual_alias_maps
fi
}
function _handle_postfix_aliases_config() {
_log 'trace' 'Configuring root alias'

View file

@ -34,6 +34,7 @@ function _monitored_files_checksums() {
"${DMS_DIR}/postfix-accounts.cf"
"${DMS_DIR}/postfix-virtual.cf"
"${DMS_DIR}/postfix-regexp.cf"
"${DMS_DIR}/postfix-regexp-send-only.cf"
"${DMS_DIR}/postfix-aliases.cf"
"${DMS_DIR}/postfix-relaymap.cf"
"${DMS_DIR}/postfix-sasl-password.cf"

View file

@ -14,7 +14,11 @@ function _setup_spoof_protection() {
# NOTE: This file is always created at startup, it potentially has content added.
# TODO: From section: "SPOOF_PROTECTION=1 handling for smtpd_sender_login_maps"
# https://github.com/docker-mailserver/docker-mailserver/issues/2819#issue-1402114383
if [[ -f /etc/postfix/regexp ]]; then
if [[ -f /etc/postfix/regexp && -f /etc/postfix/regexp-send-only ]]; then
postconf 'smtpd_sender_login_maps = unionmap:{ texthash:/etc/postfix/virtual, hash:/etc/aliases, pcre:/etc/postfix/maps/sender_login_maps.pcre, pcre:/etc/postfix/regexp, pcre:/etc/postfix/regexp-send-only }'
elif [[ -f /etc/postfix/regexp-send-only ]]; then
postconf 'smtpd_sender_login_maps = unionmap:{ texthash:/etc/postfix/virtual, hash:/etc/aliases, pcre:/etc/postfix/maps/sender_login_maps.pcre, pcre:/etc/postfix/regexp-send-only }'
elif [[ -f /etc/postfix/regexp ]]; then
postconf 'smtpd_sender_login_maps = unionmap:{ texthash:/etc/postfix/virtual, hash:/etc/aliases, pcre:/etc/postfix/maps/sender_login_maps.pcre, pcre:/etc/postfix/regexp }'
else
postconf 'smtpd_sender_login_maps = texthash:/etc/postfix/virtual, hash:/etc/aliases, pcre:/etc/postfix/maps/sender_login_maps.pcre'