diff --git a/Dockerfile b/Dockerfile index 8ac2e2bb..1a0a4a91 100644 --- a/Dockerfile +++ b/Dockerfile @@ -77,7 +77,7 @@ COPY target/postfix/ldap-users.cf target/postfix/ldap-groups.cf target/postfix/l # Enables Spamassassin CRON updates RUN sed -i -r 's/^(CRON)=0/\1=1/g' /etc/default/spamassassin -#Enables Postgrey +# Enables Postgrey COPY target/postgrey/postgrey /etc/default/postgrey COPY target/postgrey/postgrey.init /etc/init.d/postgrey RUN chmod 755 /etc/init.d/postgrey @@ -86,6 +86,7 @@ RUN chown postgrey:postgrey /var/run/postgrey # Enables Amavis RUN sed -i -r 's/#(@| \\%)bypass/\1bypass/g' /etc/amavis/conf.d/15-content_filter_mode +COPY target/amavis/conf.d/60-dms_default_config /etc/amavis/conf.d/ RUN adduser clamav amavis && adduser amavis clamav RUN useradd -u 5000 -d /home/docker -s /bin/bash -p $(echo docker | openssl passwd -1 -stdin) docker RUN (echo "0 4 * * * /usr/local/bin/virus-wiper" ; crontab -l) | crontab - diff --git a/Makefile b/Makefile index cccb1c89..f96fb710 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,7 @@ run: -v "`pwd`/test/onedir":/var/mail-state \ -e ENABLE_CLAMAV=1 \ -e ENABLE_SPAMASSASSIN=1 \ - -e SA_TAG=1.0 \ + -e SA_TAG=-5.0 \ -e SA_TAG2=2.0 \ -e SA_KILL=3.0 \ -e VIRUSMAILS_DELETE_DELAY=7 \ @@ -150,18 +150,19 @@ fixtures: docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-alias-external.txt" docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-alias-local.txt" docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-alias-recipient-delimiter.txt" - docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-user.txt" + docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-user1.txt" + docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-user2.txt" docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-user-and-cc-local-alias.txt" docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-regexp-alias-external.txt" docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-regexp-alias-local.txt" docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-catchall-local.txt" docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/sieve-spam-folder.txt" docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/non-existing-user.txt" - docker exec mail_disabled_clamav_spamassassin /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-user.txt" + docker exec mail_disabled_clamav_spamassassin /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-user1.txt" # postfix virtual transport lmtp - docker exec mail_lmtp_ip /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-user.txt" + docker exec mail_lmtp_ip /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-user1.txt" - docker exec mail_override_hostname /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-user.txt" + docker exec mail_override_hostname /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-user1.txt" # Wait for mails to be analyzed sleep 20 diff --git a/target/amavis/conf.d/60-dms_default_config b/target/amavis/conf.d/60-dms_default_config new file mode 100644 index 00000000..e5b71e2f --- /dev/null +++ b/target/amavis/conf.d/60-dms_default_config @@ -0,0 +1,7 @@ +use strict; + +@local_domains_maps = ( + read_hash('/etc/postfix/vhost') +); + +1; # ensure a defined return diff --git a/target/start-mailserver.sh b/target/start-mailserver.sh index 7d4faaab..6a725874 100644 --- a/target/start-mailserver.sh +++ b/target/start-mailserver.sh @@ -860,7 +860,7 @@ function _setup_security_stack() { notify 'task' "Setting up Security Stack" # recreate auto-generated file - dms_amavis_file="/etc/amavis/conf.d/51-dms_auto_generated" + dms_amavis_file="/etc/amavis/conf.d/61-dms_auto_generated" echo "# WARNING: this file is auto-generated." > $dms_amavis_file echo "use strict;" >> $dms_amavis_file diff --git a/test/email-templates/existing-user.txt b/test/email-templates/existing-user1.txt similarity index 100% rename from test/email-templates/existing-user.txt rename to test/email-templates/existing-user1.txt diff --git a/test/email-templates/existing-user2.txt b/test/email-templates/existing-user2.txt new file mode 100644 index 00000000..eb75c7fe --- /dev/null +++ b/test/email-templates/existing-user2.txt @@ -0,0 +1,12 @@ +HELO mail.external.tld +MAIL FROM: user@external.tld +RCPT TO: user2@otherdomain.tld +DATA +From: Docker Mail Server +To: Existing Local User +Date: Sat, 22 May 2010 07:43:25 -0400 +Subject: Test Message +This is a test mail. + +. +QUIT diff --git a/test/tests.bats b/test/tests.bats index 77369d29..39fd6efa 100644 --- a/test/tests.bats +++ b/test/tests.bats @@ -271,7 +271,7 @@ load 'test_helper/bats-assert/load' @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)' | wc -l" assert_success - assert_output 7 + assert_output 8 } @test "checking smtp: delivers mail to existing alias" { @@ -414,7 +414,7 @@ load 'test_helper/bats-assert/load' } @test "checking spamassassin: docker env variables are set correctly (custom)" { - run docker exec mail /bin/sh -c "grep '\$sa_tag_level_deflt' /etc/amavis/conf.d/20-debian_defaults | grep '= 1.0'" + run docker exec mail /bin/sh -c "grep '\$sa_tag_level_deflt' /etc/amavis/conf.d/20-debian_defaults | grep '= -5.0'" assert_success run docker exec mail /bin/sh -c "grep '\$sa_tag2_level_deflt' /etc/amavis/conf.d/20-debian_defaults | grep '= 2.0'" assert_success @@ -422,6 +422,14 @@ load 'test_helper/bats-assert/load' assert_success } +@test "checking spamassassin: all registered domains should see spam headers" { + run docker exec mail /bin/sh -c "grep -ir 'X-Spam-' /var/mail/localhost.localdomain/user1/new" + assert_success + run docker exec mail /bin/sh -c "grep -ir 'X-Spam-' /var/mail/otherdomain.tld/user2/new" + assert_success +} + + # # clamav #