chore: Revise commentary + better filter

This commit is contained in:
Brennan Kinney 2024-05-02 19:33:24 +12:00 committed by GitHub
parent 400b1fd90c
commit 6b5e606533
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 7 deletions

View File

@ -119,14 +119,17 @@ function __postfix__setup_override_configuration() {
__postfix__log 'trace' "No extra Postfix master settings loaded because optional '${OVERRIDE_CONFIG_POSTFIX_MASTER}' was not provided"
fi
# NOTE: Must come after postfix-master.cf as custom parameter support only works provided either config references it.
# NOTE: `postfix-main.cf` should be handled after `postfix-master.cf` as custom parameters require an existing reference
# in either `main.cf` or `master.cf` prior to `postconf` reading `main.cf`, otherwise it is discarded from output.
local OVERRIDE_CONFIG_POSTFIX_MAIN='/tmp/docker-mailserver/postfix-main.cf'
if [[ -f ${OVERRIDE_CONFIG_POSTFIX_MAIN} ]]; then
cat "${OVERRIDE_CONFIG_POSTFIX_MAIN}" >>/etc/postfix/main.cf
_adjust_mtime_for_postfix_maincf
# Do not directly output to 'main.cf' as this causes a read-write-conflict
postconf -n >/tmp/postfix-main-new.cf 2>/dev/null
# Do not directly output to 'main.cf' as this causes a read-write-conflict.
# `postconf` output is filtered to skip expected warnings regarding overrides:
# https://github.com/docker-mailserver/docker-mailserver/pull/3880#discussion_r1510414576
postconf -n >/tmp/postfix-main-new.cf 2> >(grep -v 'overriding earlier entry')
mv /tmp/postfix-main-new.cf /etc/postfix/main.cf
_adjust_mtime_for_postfix_maincf

View File

@ -2,5 +2,6 @@ submission/inet/smtpd_sasl_security_options=noanonymous
# this is a test comment, please don't delete me :'(
# this is also a test comment, :O
# `postfix-main.cf` must be processed first before this custom parameter is in scope:
# DMS must first process `postfix-master.cf` to `master.cf` when any custom parameters are from `postfix-main.cf`
# before an updated `main.cf` is read via `postconf`, otherwise without an existing reference the parameter is excluded.
submission/inet/smtpd_client_restrictions=$custom_parameter

View File

@ -41,17 +41,20 @@ function teardown_file() { _default_teardown ; }
}
# Custom parameter support works correctly:
@test "Postfix - 'postfix-main.cf' should apply before 'postfix-master.cf'" {
# NOTE: This would only fail on a fresh container state, any restart would pass successfully:
# https://github.com/docker-mailserver/docker-mailserver/pull/3880
@test "Postfix - 'postfix-master.cf' should apply before 'postfix-main.cf'" {
# Retrieve the value for this setting, `postfix-master.cf` should have the override set:
_run_in_container postconf -Ph 'submission/inet/smtpd_client_restrictions'
assert_success
refute_output --partial 'postconf: warning: /etc/postfix/master.cf: undefined parameter: custom_parameter'
asset_output '$custom_parameter'
# As it's a custom parameter ($ prefix), ensure the parameters value is correctly configured:
# As it's a custom parameter (`$` prefix), ensure the parameter value expands correctly:
_run_in_container postconf -Phx 'submission/inet/smtpd_client_restrictions'
assert_success
refute_output --partial 'postconf: warning: /etc/postfix/master.cf: undefined parameter: custom_parameter'
assert_output 'cidr:{{!172.16.0.42 REJECT}}, permit_sasl_authenticated, reject'
refute_output 'postconf: warning: /etc/postfix/master.cf: undefined parameter: custom_parameter'
}
@test "Dovecot - 'dovecot.cf' overrides applied to '/etc/dovecot/local.conf'" {