From d9502ab6e734dd389ab635d5dd58cc06a90a4e87 Mon Sep 17 00:00:00 2001 From: Alexander Elbracht Date: Fri, 2 Mar 2018 22:38:57 +0100 Subject: [PATCH] Implement undef option for SA_SPAM_SUBJECT (#767) * Implement undef option for SA_SPAM_SUBJECT in amavis config * Add test for undef spam subject --- Makefile | 8 ++++++++ target/start-mailserver.sh | 7 ++++++- test/tests.bats | 2 ++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 860730ba..cc8aa3f0 100644 --- a/Makefile +++ b/Makefile @@ -187,6 +187,13 @@ run: -e DMS_DEBUG=0 \ -h mail.my-domain.com -t $(NAME) sleep 20 + docker run -d --name mail_undef_spam_subject \ + -v "`pwd`/test/config":/tmp/docker-mailserver \ + -v "`pwd`/test":/tmp/docker-mailserver-test \ + -e ENABLE_SPAMASSASSIN=1 \ + -e SA_SPAM_SUBJECT="undef" \ + -h mail.my-domain.com -t $(NAME) + sleep 15 generate-accounts-after-run: @@ -246,6 +253,7 @@ clean: mail_with_imap \ mail_lmtp_ip \ mail_with_postgrey \ + mail_undef_spam_subject \ mail_postscreen \ mail_override_hostname diff --git a/target/start-mailserver.sh b/target/start-mailserver.sh index a7ee6209..a463f8df 100644 --- a/target/start-mailserver.sh +++ b/target/start-mailserver.sh @@ -1013,7 +1013,12 @@ function _setup_security_stack() { SA_TAG=${SA_TAG:="2.0"} && sed -i -r 's/^\$sa_tag_level_deflt (.*);/\$sa_tag_level_deflt = '$SA_TAG';/g' /etc/amavis/conf.d/20-debian_defaults SA_TAG2=${SA_TAG2:="6.31"} && sed -i -r 's/^\$sa_tag2_level_deflt (.*);/\$sa_tag2_level_deflt = '$SA_TAG2';/g' /etc/amavis/conf.d/20-debian_defaults SA_KILL=${SA_KILL:="6.31"} && sed -i -r 's/^\$sa_kill_level_deflt (.*);/\$sa_kill_level_deflt = '$SA_KILL';/g' /etc/amavis/conf.d/20-debian_defaults - SA_SPAM_SUBJECT=${SA_SPAM_SUBJECT:="***SPAM*** "} && sed -i -r 's/^\$sa_spam_subject_tag (.*);/\$sa_spam_subject_tag = '"'$SA_SPAM_SUBJECT'"';/g' /etc/amavis/conf.d/20-debian_defaults + SA_SPAM_SUBJECT=${SA_SPAM_SUBJECT:="***SPAM*** "} + if [ "$SA_SPAM_SUBJECT" == "undef" ]; then + sed -i -r 's/^\$sa_spam_subject_tag (.*);/\$sa_spam_subject_tag = undef;/g' /etc/amavis/conf.d/20-debian_defaults + else + sed -i -r 's/^\$sa_spam_subject_tag (.*);/\$sa_spam_subject_tag = '"'$SA_SPAM_SUBJECT'"';/g' /etc/amavis/conf.d/20-debian_defaults + fi test -e /tmp/docker-mailserver/spamassassin-rules.cf && cp /tmp/docker-mailserver/spamassassin-rules.cf /etc/spamassassin/ fi diff --git a/test/tests.bats b/test/tests.bats index 5b129165..a7a1ebf6 100644 --- a/test/tests.bats +++ b/test/tests.bats @@ -474,6 +474,8 @@ load 'test_helper/bats-assert/load' assert_success run docker exec mail /bin/sh -c "grep '\$sa_spam_subject_tag' /etc/amavis/conf.d/20-debian_defaults | grep '= .SPAM: .'" assert_success + run docker exec mail_undef_spam_subject /bin/sh -c "grep '\$sa_spam_subject_tag' /etc/amavis/conf.d/20-debian_defaults | grep '= undef'" + assert_success } @test "checking spamassassin: all registered domains should see spam headers" {