fix: postfix-main.cf may depend upon postfix-master.cf (#3880)

Custom parameters must be referenced to be retained when `postconf -n` is run. If those parameters are referenced by `postfix-master.cf` this needs to update `master.cf` before updating `main.cf`.
This commit is contained in:
Brennan Kinney 2024-05-03 11:12:34 +12:00 committed by GitHub
parent 7822a97430
commit e2c2a22dcf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 51 additions and 17 deletions

View file

@ -15,6 +15,9 @@ function setup_file() {
function teardown_file() { _default_teardown ; }
# The `postconf` command can query both `main.cf` and `master.cf` at `/etc/postfix/`.
# Reference: http://www.postfix.org/postconf.1.html
@test "Postfix - 'postfix-main.cf' overrides applied to '/etc/postfix/main.cf'" {
_run_in_container grep -q 'max_idle = 600s' /tmp/docker-mailserver/postfix-main.cf
assert_success
@ -37,6 +40,24 @@ function teardown_file() { _default_teardown ; }
assert_output --partial '-o smtpd_sasl_security_options=noanonymous'
}
# Custom parameter support works correctly:
# 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'
#shellcheck disable=SC2016
assert_output '$custom_parameter'
# 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'
}
@test "Dovecot - 'dovecot.cf' overrides applied to '/etc/dovecot/local.conf'" {
_run_in_container grep -q 'mail_max_userip_connections = 69' /tmp/docker-mailserver/dovecot.cf
assert_success