mirror of
https://github.com/docker-mailserver/docker-mailserver
synced 2026-10-26 14:30:24 +01:00
Postfix LDAP configs are now generated at startup to `/etc/postfix/ldap/<KIND>.cf`
(`users`, `groups`, `aliases`, `domains`, `senders`) from these sources, later ones take precedence:
1. Defaults (`version = 3`, `result_attribute = mail`, `senders`: `mail, uid`).
2. `LDAP_<SETTING>` ENV for all configs.
3. The custom config `ldap-<KIND>.cf` from the DMS config volume (now also supported for `senders`).
4. `POSTFIX_<KIND>_<SETTING>` ENV for a single config.
A config without `query_filter` is not generated and its lookup table is not configured
(including `smtpd_sender_login_maps` with `SPOOF_PROTECTION=1`). Previously all lookup
tables were always configured, as the default configs shipped by the image always existed.
Breaking:
- `LDAP_QUERY_FILTER_{USER,GROUP,ALIAS,DOMAIN,SENDERS}` are renamed to
`POSTFIX_{USERS,GROUPS,ALIASES,DOMAINS,SENDERS}_QUERY_FILTER` (an error is logged when the old ENV is set).
- `/etc/postfix/ldap-*.cf` moved to `/etc/postfix/ldap/*.cf`, the default configs (with default query filters) were removed.
Reworked from the original "Config Templates" proposal: Dovecot (already reworked for Dovecot 2.4)
and SASLAuthd are unchanged, and no template files or additional dependencies (`zenv`, `envsubst`) are required.
Signed-off-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
38 lines
1.2 KiB
Bash
38 lines
1.2 KiB
Bash
load "${REPOSITORY_ROOT}/test/helper/common"
|
|
|
|
source "${REPOSITORY_ROOT}/target/scripts/helpers/log.sh"
|
|
source "${REPOSITORY_ROOT}/target/scripts/helpers/utils.sh"
|
|
source "${REPOSITORY_ROOT}/target/scripts/startup/setup.d/ldap.sh"
|
|
|
|
BATS_TEST_NAME_PREFIX='[Postfix LDAP config] '
|
|
|
|
@test "renders only known settings with a non-empty ENV of the given prefix" {
|
|
export TEST_SEARCH_BASE='ou=users,dc=example,dc=test'
|
|
export TEST_QUERY_FILTER='(&(mail=%s)(objectClass=*))'
|
|
export TEST_START_TLS=''
|
|
export TEST_MESSAGE_SIZE_LIMIT='1000'
|
|
|
|
run _postfix_ldap_settings_from_env 'TEST_'
|
|
assert_success
|
|
assert_output "$(printf '%s\n' \
|
|
'search_base = ou=users,dc=example,dc=test' \
|
|
'query_filter = (&(mail=%s)(objectClass=*))')"
|
|
}
|
|
|
|
@test "cleanses config (normalized white-space, no empty values, last key wins)" {
|
|
run _cleanse_config < <(printf '%s\n' \
|
|
'version = 3' \
|
|
'result_attribute = mail' \
|
|
' server_host = ldap://first' \
|
|
'result_attribute = mail, uid' \
|
|
'server_host=ldap://second' \
|
|
'bind_pw =' \
|
|
'query_filter = (mail=%s)')
|
|
assert_success
|
|
assert_output "$(printf '%s\n' \
|
|
'query_filter = (mail=%s)' \
|
|
'result_attribute = mail, uid' \
|
|
'server_host = ldap://second' \
|
|
'version = 3')"
|
|
}
|