Fix #526: fatal: no SASL authentication mechanisms (#556)

* Fix #526: fatal: no SASL authentication mechanisms

When using the container with SMTP_ONLY = 1, then the container fails
on ehlo because there is no valid sasl authentication mechanism
available. This happens because sasl has been enabled within
postfix/main.cf per default but sasl is not configured.

To fix this _setup_postfix_sasl does not depend anymore on
ENABLE_SASLAUTHD and will check in it's logic, whether to enable sasl
or not within postfix/main.cf.

* Fix #526: fatal: no SASL authentication mechanisms

When using the container with SMTP_ONLY = 1, then the container fails
on ehlo because there is no valid sasl authentication mechanism
available. This happens because sasl has been enabled within
postfix/main.cf per default but sasl is not configured.

To fix this _setup_postfix_sasl does not depend anymore on
ENABLE_SASLAUTHD and will check in it's logic, whether to enable sasl
or not within postfix/main.cf.

* Fix test
This commit is contained in:
alinmear 2017-04-26 14:56:33 +02:00 committed by Thomas VIAL
parent 26992bb66f
commit 50ac2bdc07
3 changed files with 33 additions and 2 deletions

View file

@ -90,7 +90,6 @@ function register_functions() {
if [ "$ENABLE_SASLAUTHD" = 1 ];then
_register_setup_function "_setup_saslauthd"
_register_setup_function "_setup_postfix_sasl"
fi
if [ "$ENABLE_POSTGREY" = 1 ];then
@ -107,6 +106,7 @@ function register_functions() {
_register_setup_function "_setup_postfix_hostname"
_register_setup_function "_setup_dovecot_hostname"
_register_setup_function "_setup_postfix_sasl"
_register_setup_function "_setup_postfix_override_configuration"
_register_setup_function "_setup_postfix_sasl_password"
_register_setup_function "_setup_security_stack"
@ -595,11 +595,21 @@ function _setup_postgrey() {
function _setup_postfix_sasl() {
if [[ ${ENABLE_SASLAUTHD} == 1 ]];then
[ ! -f /etc/postfix/sasl/smtpd.conf ] && cat > /etc/postfix/sasl/smtpd.conf << EOF
pwcheck_method: saslauthd
mech_list: plain login
EOF
return 0
fi
# cyrus sasl or dovecot sasl
if [[ ${ENABLE_SASLAUTHD} == 1 ]] || [[ ${SMTP_ONLY} == 0 ]];then
sed -i -e 's|^smtpd_sasl_auth_enable[[:space:]]\+.*|smtpd_sasl_auth_enable = yes|g' /etc/postfix/main.cf
else
sed -i -e 's|^smtpd_sasl_auth_enable[[:space:]]\+.*|smtpd_sasl_auth_enable = no|g' /etc/postfix/main.cf
fi
return 0
}
function _setup_saslauthd() {

View file

@ -0,0 +1,8 @@
HELO mail.localhost
MAIL FROM: test@localhost
RCPT TO: user2@external.tld
DATA
This is a test mail.
.
QUIT

View file

@ -331,6 +331,19 @@ load 'test_helper/bats-assert/load'
assert_output 1
}
@test "checking smtp_only: mail send should work" {
run docker exec mail_smtponly /bin/sh -c "postconf -e smtp_host_lookup=no"
assert_success
run docker exec mail_smtponly /bin/sh -c "/etc/init.d/postfix reload"
assert_success
run docker exec mail_smtponly /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/smtp-only.txt"
assert_success
run docker exec mail_smtponly /bin/sh -c 'grep -cE "to=<user2\@external.tld>.*status\=sent" /var/log/mail/mail.log'
[ "$status" -ge 0 ]
}
#
# accounts
#