2023-02-26 10:42:14 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
2023-05-25 23:01:41 +00:00
|
|
|
function _setup_saslauthd() {
|
2023-02-26 10:42:14 +00:00
|
|
|
_log 'debug' 'Setting up SASLAUTHD'
|
|
|
|
|
2023-05-24 07:06:59 +00:00
|
|
|
if [[ ! -f /etc/saslauthd.conf ]]; then
|
2023-02-26 10:42:14 +00:00
|
|
|
_log 'trace' 'Creating /etc/saslauthd.conf'
|
|
|
|
cat > /etc/saslauthd.conf << EOF
|
|
|
|
ldap_servers: ${SASLAUTHD_LDAP_SERVER}
|
|
|
|
|
|
|
|
ldap_auth_method: ${SASLAUTHD_LDAP_AUTH_METHOD}
|
|
|
|
ldap_bind_dn: ${SASLAUTHD_LDAP_BIND_DN}
|
|
|
|
ldap_bind_pw: ${SASLAUTHD_LDAP_PASSWORD}
|
|
|
|
|
|
|
|
ldap_search_base: ${SASLAUTHD_LDAP_SEARCH_BASE}
|
|
|
|
ldap_filter: ${SASLAUTHD_LDAP_FILTER}
|
|
|
|
|
|
|
|
ldap_start_tls: ${SASLAUTHD_LDAP_START_TLS}
|
|
|
|
ldap_tls_check_peer: ${SASLAUTHD_LDAP_TLS_CHECK_PEER}
|
|
|
|
|
|
|
|
${SASLAUTHD_LDAP_TLS_CACERT_FILE}
|
|
|
|
${SASLAUTHD_LDAP_TLS_CACERT_DIR}
|
|
|
|
${SASLAUTHD_LDAP_PASSWORD_ATTR}
|
|
|
|
${SASLAUTHD_LDAP_MECH}
|
|
|
|
|
|
|
|
ldap_referrals: yes
|
|
|
|
log_level: 10
|
|
|
|
EOF
|
|
|
|
fi
|
|
|
|
|
|
|
|
sed -i \
|
|
|
|
-e "/^[^#].*smtpd_sasl_type.*/s/^/#/g" \
|
|
|
|
-e "/^[^#].*smtpd_sasl_path.*/s/^/#/g" \
|
|
|
|
/etc/postfix/master.cf
|
|
|
|
|
|
|
|
sed -i \
|
|
|
|
-e "/smtpd_sasl_path =.*/d" \
|
|
|
|
-e "/smtpd_sasl_type =.*/d" \
|
|
|
|
-e "/dovecot_destination_recipient_limit =.*/d" \
|
|
|
|
/etc/postfix/main.cf
|
|
|
|
|
|
|
|
gpasswd -a postfix sasl >/dev/null
|
|
|
|
}
|
|
|
|
|