mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2026-11-21 03:26:29 +03: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>
34 lines
1.5 KiB
Bash
34 lines
1.5 KiB
Bash
#!/bin/bash
|
|
|
|
function _setup_spoof_protection() {
|
|
if [[ ${SPOOF_PROTECTION} -eq 1 ]]; then
|
|
_log 'trace' 'Enabling and configuring spoof protection'
|
|
|
|
if [[ ${ACCOUNT_PROVISIONER} == 'LDAP' ]]; then
|
|
# Only LDAP configs with a `query_filter` exist (`setup.d/ldap.sh:_create_config_postfix()`):
|
|
local QUERY_KIND SENDER_LOGIN_MAPS=()
|
|
if [[ -f /etc/postfix/ldap/senders.cf ]]; then
|
|
SENDER_LOGIN_MAPS=('ldap:/etc/postfix/ldap/senders.cf')
|
|
else
|
|
for QUERY_KIND in 'users' 'aliases' 'groups'; do
|
|
[[ -f /etc/postfix/ldap/${QUERY_KIND}.cf ]] && SENDER_LOGIN_MAPS+=("ldap:/etc/postfix/ldap/${QUERY_KIND}.cf")
|
|
done
|
|
fi
|
|
postconf "smtpd_sender_login_maps = ${SENDER_LOGIN_MAPS[*]}"
|
|
else
|
|
# 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
|
|
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'
|
|
fi
|
|
fi
|
|
else
|
|
_log 'debug' 'Spoof protection is disabled'
|
|
# shellcheck disable=SC2016
|
|
postconf 'mua_sender_restrictions = $dms_smtpd_sender_restrictions'
|
|
fi
|
|
}
|