From d45e6b1c225e6453bdd3cfc32f6f86106947e365 Mon Sep 17 00:00:00 2001 From: youtous Date: Thu, 30 Apr 2020 12:05:36 +0200 Subject: [PATCH 1/2] #fix 1478 --- target/start-mailserver.sh | 13 ++++++++----- test/mail_with_ldap.bats | 5 +++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/target/start-mailserver.sh b/target/start-mailserver.sh index b0cb77e4..f5c779f4 100644 --- a/target/start-mailserver.sh +++ b/target/start-mailserver.sh @@ -637,6 +637,9 @@ function _setup_dovecot_quota() { if [ "$ENABLE_LDAP" = 1 ]; then notify 'inf' "Dovecot quota is not implemented with LDAP." + # LDAP => postfix service for dovecot quota not enabled + sed -i "s/check_policy_service inet:localhost:65265//g" /etc/postfix/main.cf + if [ -f /etc/dovecot/conf.d/90-quota.conf ]; then mv /etc/dovecot/conf.d/90-quota.conf /etc/dovecot/conf.d/90-quota.conf.disab sed -i "s/mail_plugins = \$mail_plugins quota/mail_plugins = \$mail_plugins/g" /etc/dovecot/conf.d/10-mail.conf @@ -659,12 +662,12 @@ function _setup_dovecot_quota() { notify 'inf' "'config/docker-mailserver/dovecot-quotas.cf' is not provided. Using default quotas." echo -n >/tmp/docker-mailserver/dovecot-quotas.cf fi - fi - if [ "$SMTP_ONLY" = 1 ]; then - sed -i "s/check_policy_service inet:localhost:65265//g" /etc/postfix/main.cf - else - sed -i "s/reject_unknown_recipient_domain, reject_rbl_client zen.spamhaus.org/reject_unknown_recipient_domain, check_policy_service inet:localhost:65265, reject_rbl_client zen.spamhaus.org/g" /etc/postfix/main.cf + if [ "$SMTP_ONLY" = 1 ]; then + sed -i "s/check_policy_service inet:localhost:65265//g" /etc/postfix/main.cf + else + sed -i "s/reject_unknown_recipient_domain, reject_rbl_client zen.spamhaus.org/reject_unknown_recipient_domain, check_policy_service inet:localhost:65265, reject_rbl_client zen.spamhaus.org/g" /etc/postfix/main.cf + fi fi } diff --git a/test/mail_with_ldap.bats b/test/mail_with_ldap.bats index 10e430fb..a236035c 100644 --- a/test/mail_with_ldap.bats +++ b/test/mail_with_ldap.bats @@ -179,6 +179,11 @@ function teardown_file() { assert_success } +@test "checking postfix: dovecot quota absent in postconf" { + run docker exec mail_with_ldap /bin/bash -c "postconf | grep 'check_policy_service inet:localhost:65265'" + assert_failure +} + @test "checking spoofing: rejects sender forging" { run docker exec mail_with_ldap /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/auth/ldap-smtp-auth-spoofed.txt | grep 'Sender address rejected: not owned by user'" assert_success From 3aeacef1259fefedff96378274c510e8db4c5cbb Mon Sep 17 00:00:00 2001 From: youtous Date: Thu, 30 Apr 2020 16:11:45 +0200 Subject: [PATCH 2/2] remove start-mailserver nested conditions dovecot quota --- target/start-mailserver.sh | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/target/start-mailserver.sh b/target/start-mailserver.sh index f5c779f4..3a08a586 100644 --- a/target/start-mailserver.sh +++ b/target/start-mailserver.sh @@ -634,17 +634,18 @@ function _setup_dovecot() { function _setup_dovecot_quota() { notify 'task' 'Setting up Dovecot quota' - if [ "$ENABLE_LDAP" = 1 ]; then - notify 'inf' "Dovecot quota is not implemented with LDAP." - - # LDAP => postfix service for dovecot quota not enabled - sed -i "s/check_policy_service inet:localhost:65265//g" /etc/postfix/main.cf + if [ "$ENABLE_LDAP" = 1 ] || [ "$SMTP_ONLY" = 1 ]; then + # Dovecot quota is disabled when using LDAP or SMTP_ONLY + # disable dovecot quota in docevot confs if [ -f /etc/dovecot/conf.d/90-quota.conf ]; then mv /etc/dovecot/conf.d/90-quota.conf /etc/dovecot/conf.d/90-quota.conf.disab sed -i "s/mail_plugins = \$mail_plugins quota/mail_plugins = \$mail_plugins/g" /etc/dovecot/conf.d/10-mail.conf sed -i "s/mail_plugins = \$mail_plugins imap_quota/mail_plugins = \$mail_plugins/g" /etc/dovecot/conf.d/20-imap.conf fi + + # disable quota policy check in postfix + sed -i "s/check_policy_service inet:localhost:65265//g" /etc/postfix/main.cf else if [ -f /etc/dovecot/conf.d/90-quota.conf.disab ]; then mv /etc/dovecot/conf.d/90-quota.conf.disab /etc/dovecot/conf.d/90-quota.conf @@ -663,11 +664,8 @@ function _setup_dovecot_quota() { echo -n >/tmp/docker-mailserver/dovecot-quotas.cf fi - if [ "$SMTP_ONLY" = 1 ]; then - sed -i "s/check_policy_service inet:localhost:65265//g" /etc/postfix/main.cf - else - sed -i "s/reject_unknown_recipient_domain, reject_rbl_client zen.spamhaus.org/reject_unknown_recipient_domain, check_policy_service inet:localhost:65265, reject_rbl_client zen.spamhaus.org/g" /etc/postfix/main.cf - fi + # enable quota policy check in postfix + sed -i "s/reject_unknown_recipient_domain, reject_rbl_client zen.spamhaus.org/reject_unknown_recipient_domain, check_policy_service inet:localhost:65265, reject_rbl_client zen.spamhaus.org/g" /etc/postfix/main.cf fi }