From 908e95fa74e76b239e4391f6b841e1529f4498d5 Mon Sep 17 00:00:00 2001 From: Christian Raue Date: Thu, 17 Feb 2022 09:31:45 +0100 Subject: [PATCH] consistently make 1 the default value for `SPAMASSASSIN_SPAM_TO_INBOX` (#2361) Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com> Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com> --- docs/content/config/environment.md | 7 ++----- target/scripts/start-mailserver.sh | 3 +-- target/scripts/startup/setup-stack.sh | 5 ----- test/mail_spam_bounced.bats | 25 +------------------------ test/tests.bats | 4 ++++ 5 files changed, 8 insertions(+), 36 deletions(-) diff --git a/docs/content/config/environment.md b/docs/content/config/environment.md index 3696c977..63df4ba9 100644 --- a/docs/content/config/environment.md +++ b/docs/content/config/environment.md @@ -343,13 +343,10 @@ Finally the logrotate interval **may** affect the period for generated reports. - **0** => SpamAssassin is disabled - 1 => SpamAssassin is enabled -**/!\\ Spam delivery:** when SpamAssassin is enabled, messages marked as spam WILL NOT BE DELIVERED. -Use `SPAMASSASSIN_SPAM_TO_INBOX=1` for receiving spam messages. - ##### SPAMASSASSIN_SPAM_TO_INBOX -- **0** => Spam messages will be bounced (_rejected_) without any notification (_dangerous_). -- 1 => Spam messages will be delivered to the inbox and tagged as spam using `SA_SPAM_SUBJECT`. +- **1** => Spam messages will be delivered to the inbox and tagged as spam using `SA_SPAM_SUBJECT`. +- 0 => Spam messages will be bounced (_rejected_) without any notification (_dangerous_). ##### MOVE_SPAM_TO_JUNK diff --git a/target/scripts/start-mailserver.sh b/target/scripts/start-mailserver.sh index c85e7677..4bb020b4 100755 --- a/target/scripts/start-mailserver.sh +++ b/target/scripts/start-mailserver.sh @@ -61,8 +61,7 @@ VARS[SA_SPAM_SUBJECT]=${SA_SPAM_SUBJECT:="***SPAM*** "} VARS[SA_TAG]=${SA_TAG:="2.0"} VARS[SA_TAG2]=${SA_TAG2:="6.31"} VARS[SMTP_ONLY]="${SMTP_ONLY:=0}" -VARS[SPAMASSASSIN_SPAM_TO_INBOX_SET]="${SPAMASSASSIN_SPAM_TO_INBOX:-not set}" -VARS[SPAMASSASSIN_SPAM_TO_INBOX]="${SPAMASSASSIN_SPAM_TO_INBOX:=0}" +VARS[SPAMASSASSIN_SPAM_TO_INBOX]="${SPAMASSASSIN_SPAM_TO_INBOX:=1}" VARS[SPOOF_PROTECTION]="${SPOOF_PROTECTION:=0}" VARS[SRS_SENDER_CLASSES]="${SRS_SENDER_CLASSES:=envelope_sender}" VARS[SSL_TYPE]="${SSL_TYPE:=}" diff --git a/target/scripts/startup/setup-stack.sh b/target/scripts/startup/setup-stack.sh index 58013aa6..6d25c165 100644 --- a/target/scripts/startup/setup-stack.sh +++ b/target/scripts/startup/setup-stack.sh @@ -1367,11 +1367,6 @@ function _setup_security_stack sed -i "s|\$final_spam_destiny.*=.*$|\$final_spam_destiny = D_BOUNCE;|g" /etc/amavis/conf.d/49-docker-mailserver sed -i "s|\$final_bad_header_destiny.*=.*$|\$final_bad_header_destiny = D_BOUNCE;|g" /etc/amavis/conf.d/49-docker-mailserver - - if [[ ${VARS[SPAMASSASSIN_SPAM_TO_INBOX_SET]} == 'not set' ]] - then - _notify 'warn' 'Spam messages WILL NOT BE DELIVERED, you will NOT be notified of ANY message bounced. Please define SPAMASSASSIN_SPAM_TO_INBOX explicitly.' - fi fi fi diff --git a/test/mail_spam_bounced.bats b/test/mail_spam_bounced.bats index d1bbaeb4..dc11bcf6 100644 --- a/test/mail_spam_bounced.bats +++ b/test/mail_spam_bounced.bats @@ -33,6 +33,7 @@ function setup_file() { } @test "checking amavis: spam message is bounced (rejected)" { + # shellcheck disable=SC2034 local TEST_DOCKER_ARGS=( --env ENABLE_SPAMASSASSIN=1 --env SPAMASSASSIN_SPAM_TO_INBOX=0 @@ -40,25 +41,6 @@ function setup_file() { common_container_setup 'TEST_DOCKER_ARGS' - run _should_emit_warning - assert_failure - - _should_bounce_spam -} - -@test "checking amavis: spam message is bounced (rejected), undefined SPAMASSASSIN_SPAM_TO_INBOX should raise a warning" { - # SPAMASSASSIN_SPAM_TO_INBOX=0 is the default. If no explicit ENV value is set, it should log a warning at startup. - - # shellcheck disable=SC2034 - local TEST_DOCKER_ARGS=( - --env ENABLE_SPAMASSASSIN=1 - ) - - common_container_setup 'TEST_DOCKER_ARGS' - - run _should_emit_warning - assert_success - _should_bounce_spam } @@ -66,11 +48,6 @@ function setup_file() { skip 'this test is only there to reliably mark the end for the teardown_file' } -# This warning should only be raised when the env SPAMASSASSIN_SPAM_TO_INBOX has no explicit value set -function _should_emit_warning() { - sh -c "docker logs ${TEST_NAME} | grep 'Spam messages WILL NOT BE DELIVERED'" -} - function _should_bounce_spam() { wait_for_smtp_port_in_container_to_respond "${TEST_NAME}" diff --git a/test/tests.bats b/test/tests.bats index 96cba2e2..87a06ba3 100644 --- a/test/tests.bats +++ b/test/tests.bats @@ -23,7 +23,9 @@ setup_file() { -e ENABLE_MANAGESIEVE=1 \ -e ENABLE_QUOTAS=1 \ -e ENABLE_SPAMASSASSIN=1 \ + -e SPAMASSASSIN_SPAM_TO_INBOX=0 \ -e ENABLE_SRS=1 \ + -e ENABLE_UPDATE_CHECK=0 \ -e PERMIT_DOCKER=host \ -e REPORT_RECIPIENT=user1@localhost.localdomain \ -e REPORT_SENDER=report1@mail.my-domain.com \ @@ -244,6 +246,7 @@ teardown_file() { assert_success } +# TODO add a test covering case SPAMASSASSIN_SPAM_TO_INBOX=1 (default) @test "checking smtp: delivers mail to existing account" { run docker exec mail /bin/sh -c "grep 'postfix/lmtp' /var/log/mail/mail.log | grep 'status=sent' | grep ' Saved)' | sed 's/.* to=