chore: `saslauthd.conf` generation - Use common `LDAP_` ENV in base

Similar to the prior commit, this ensures default ENV fallback doesn't accidentally override explicit user-provided config settings.
This commit is contained in:
polarathene 2023-09-03 17:01:22 +12:00
parent 54eebb9129
commit 4cc300f9b1
2 changed files with 8 additions and 9 deletions

View File

@ -1,2 +1,6 @@
ldap_bind_dn: ${BIND_DN}
ldap_bind_pw: ${BIND_PW}
ldap_servers: ${SERVER_HOST}
ldap_search_base: ${SEARCH_BASE}
ldap_filter: (&(uniqueIdentifier=%u)(mailEnabled=TRUE)) ldap_filter: (&(uniqueIdentifier=%u)(mailEnabled=TRUE))
ldap_referrals: yes ldap_referrals: yes

View File

@ -26,17 +26,12 @@ function _setup_saslauthd() {
gpasswd -a postfix sasl >/dev/null gpasswd -a postfix sasl >/dev/null
} }
function _create_config_saslauthd() {
local SASLAUTHD_LDAP_SERVER=${SASLAUTHD_LDAP_SERVER:=${LDAP_SERVER_HOST}}
local SASLAUTHD_LDAP_BIND_DN=${SASLAUTHD_LDAP_BIND_DN:=${LDAP_BIND_DN}}
local SASLAUTHD_LDAP_PASSWORD=${SASLAUTHD_LDAP_PASSWORD:=${LDAP_BIND_PW}}
local SASLAUTHD_LDAP_SEARCH_BASE=${SASLAUTHD_LDAP_SEARCH_BASE:=${LDAP_SEARCH_BASE}}
# Generates a config from an ENV template while layering several other sources # Generates a config from an ENV template while layering several other sources
# into a single temporary file, used as input into `_cleanse_config` which # into a single temporary file, used as input into `_cleanse_config` which
# prepares the final output config. # prepares the final output config.
function _create_config_saslauthd() {
_cleanse_config ':' <(cat 2>/dev/null \ _cleanse_config ':' <(cat 2>/dev/null \
/etc/dms/ldap/saslauthd.base \ <(_template_with_env 'LDAP_' /etc/dms/ldap/saslauthd.base) \
/tmp/docker-mailserver/ldap/saslauthd.conf \ /tmp/docker-mailserver/ldap/saslauthd.conf \
<(_template_with_env 'SASLAUTHD_' /etc/dms/ldap/saslauthd.tmpl) \ <(_template_with_env 'SASLAUTHD_' /etc/dms/ldap/saslauthd.tmpl) \
) > /etc/saslauthd.conf ) > /etc/saslauthd.conf