1
1
Fork 0
mirror of https://github.com/docker-mailserver/docker-mailserver synced 2024-05-27 23:56:07 +02:00

enhancement for function _setup_postfix_sasl fixing #1796 & more

This commit is contained in:
Georg Lauterbach 2021-02-07 18:11:33 +01:00
parent df3ef4865f
commit c6c7b8522d
No known key found for this signature in database
GPG Key ID: 2FDC58699AF121C6
2 changed files with 40 additions and 39 deletions

View File

@ -34,8 +34,8 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN \ RUN \
apt-get -qq --fix-missing update && \ apt-get -qq --fix-missing update && \
apt-get -y dist-upgrade >/dev/null && \
apt-get -y install apt-utils &>/dev/null && \ apt-get -y install apt-utils &>/dev/null && \
apt-get -y dist-upgrade >/dev/null && \
apt-get -y install postfix >/dev/null && \ apt-get -y install postfix >/dev/null && \
apt-get -y --no-install-recommends install \ apt-get -y --no-install-recommends install \
# A - D # A - D

View File

@ -925,7 +925,7 @@ function _setup_spoof_protection
function _setup_postfix_access_control function _setup_postfix_access_control
{ {
_notify 'inf' "Configuring user access" _notify 'inf' 'Configuring user access'
if [[ -f /tmp/docker-mailserver/postfix-send-access.cf ]] if [[ -f /tmp/docker-mailserver/postfix-send-access.cf ]]
then then
@ -940,29 +940,28 @@ function _setup_postfix_access_control
function _setup_postfix_sasl function _setup_postfix_sasl
{ {
if [[ ${ENABLE_SASLAUTHD} -eq 1 ]] if [[ ${ENABLE_SASLAUTHD} -eq 1 ]] && [[ ! -f /etc/postfix/sasl/smtpd.conf ]]
then then
[[ ! -f /etc/postfix/sasl/smtpd.conf ]] && cat > /etc/postfix/sasl/smtpd.conf << EOF cat > /etc/postfix/sasl/smtpd.conf << EOF
pwcheck_method: saslauthd pwcheck_method: saslauthd
mech_list: plain login mech_list: plain login
EOF EOF
fi fi
# cyrus sasl or dovecot sasl if [[ ${ENABLE_SASLAUTHD} -eq 0 ]] && [[ ${SMTP_ONLY} -eq 1 ]]
if [[ ${ENABLE_SASLAUTHD} -eq 1 ]] || [[ ${SMTP_ONLY} -eq 0 ]]
then then
sed -i -e 's|^smtpd_sasl_auth_enable[[:space:]]\+.*|smtpd_sasl_auth_enable = yes|g' /etc/postfix/main.cf sed -i -E \
else 's+^smtpd_sasl_auth_enable =.*+smtpd_sasl_auth_enable = no+g' \
sed -i -e 's|^smtpd_sasl_auth_enable[[:space:]]\+.*|smtpd_sasl_auth_enable = no|g' /etc/postfix/main.cf /etc/postfix/main.cf
sed -i -E \
's+^ -o smtpd_sasl_auth_enable=.*+ -o smtpd_sasl_auth_enable=no+g' \
/etc/postfix/master.cf
fi fi
return 0
} }
function _setup_saslauthd function _setup_saslauthd
{ {
_notify 'task' "Setting up Saslauthd" _notify 'task' "Setting up SASLAUTHD"
_notify 'inf' "Configuring Cyrus SASL"
# checking env vars and setting defaults # checking env vars and setting defaults
[[ -z ${SASLAUTHD_MECHANISMS:-} ]] && SASLAUTHD_MECHANISMS=pam [[ -z ${SASLAUTHD_MECHANISMS:-} ]] && SASLAUTHD_MECHANISMS=pam
@ -1970,42 +1969,45 @@ function misc
function _misc_save_states function _misc_save_states
{ {
# consolidate all states into a single directory (`/var/mail-state`) to allow persistence using docker volumes # consolidate all states into a single directory (`/var/mail-state`)
statedir=/var/mail-state # to allow persistence using docker volumes
if [[ ${ONE_DIR} -eq 1 ]] && [[ -d ${statedir} ]] local STATEDIR=/var/mail-state
if [[ ${ONE_DIR} -eq 1 ]] && [[ -d ${STATEDIR} ]]
then then
_notify 'inf' "Consolidating all state onto ${statedir}" _notify 'inf' "Consolidating all state onto ${STATEDIR}"
local FILES=( local FILES=(
/var/spool/postfix spool/postfix
/var/lib/postfix lib/postfix
/var/lib/amavis lib/amavis
/var/lib/clamav lib/clamav
/var/lib/spamassassin lib/spamassassin
/var/lib/fail2ban lib/fail2ban
/var/lib/postgrey lib/postgrey
/var/lib/dovecot lib/dovecot
) )
for d in "${FILES[@]}" for FILE in "${FILES[@]}"
do do
dest="${statedir}/$(echo "${d}" | sed -e 's/.var.//; s/\//-/g')" DEST="${STATEDIR}/${FILE//\//-}"
local FILE="/var/${FILE}"
if [[ -d ${dest} ]] if [[ -d ${DEST} ]]
then then
_notify 'inf' " Destination ${dest} exists, linking ${d} to it" _notify 'inf' "Destination ${DEST} exists, linking ${FILE} to it"
rm -rf "${d}" rm -rf "${FILE}"
ln -s "${dest}" "${d}" ln -s "${DEST}" "${FILE}"
elif [[ -d ${d} ]] elif [[ -d ${FILE} ]]
then then
_notify 'inf' " Moving contents of ${d} to ${dest}:" "$(ls "${d}")" _notify 'inf' "Moving contents of ${FILE} to ${DEST}:" "$(ls "${FILE}")"
mv "${d}" "${dest}" mv "${FILE}" "${DEST}"
ln -s "${dest}" "${d}" ln -s "${DEST}" "${FILE}"
else else
_notify 'inf' " Linking ${d} to ${dest}" _notify 'inf' "Linking ${FILE} to ${DEST}"
mkdir -p "${dest}" mkdir -p "${DEST}"
ln -s "${dest}" "${d}" ln -s "${DEST}" "${FILE}"
fi fi
done done
@ -2015,7 +2017,6 @@ function _misc_save_states
chown -R postgrey /var/mail-state/lib-postgrey chown -R postgrey /var/mail-state/lib-postgrey
chown -R debian-spamd /var/mail-state/lib-spamassassin chown -R debian-spamd /var/mail-state/lib-spamassassin
chown -R postfix /var/mail-state/spool-postfix chown -R postfix /var/mail-state/spool-postfix
fi fi
} }