From 63cf0f9965ff7c90661baedbb6aff2e9396584fc Mon Sep 17 00:00:00 2001 From: Thomas VIAL Date: Sun, 25 Dec 2016 15:41:02 +0100 Subject: [PATCH] Disables clamav config in amavis when DISABLE_CLAMAV=1. Fixes #378 (#431) --- Makefile | 1 + target/start-mailserver.sh | 13 +++++++++++++ test/tests.bats | 19 +++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/Makefile b/Makefile index 29c4d8d8..a8e7b8a8 100644 --- a/Makefile +++ b/Makefile @@ -123,6 +123,7 @@ fixtures: 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 /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-user.txt" # Wait for mails to be analyzed sleep 10 diff --git a/target/start-mailserver.sh b/target/start-mailserver.sh index 778e4a4a..df24bb1c 100644 --- a/target/start-mailserver.sh +++ b/target/start-mailserver.sh @@ -744,6 +744,19 @@ function _setup_security_stack() { 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 test -e /tmp/docker-mailserver/spamassassin-rules.cf && cp /tmp/docker-mailserver/spamassassin-rules.cf /etc/spamassassin/ + if [ "$DISABLE_CLAMAV" = 1 ]; then + notify 'inf' "Disabling clamav" + cat > /etc/amavis/conf.d/50-user-security <<- EOM +use strict; +@bypass_virus_checks_maps = (); +$undecipherable_subject_tag = undef; +1; + EOM + else + notify 'inf' "Enabling clamav" + echo "" > /etc/amavis/conf.d/50-user-security + fi + if [ "$ENABLE_FAIL2BAN" = 1 ]; then notify 'inf' "Fail2ban enabled" test -e /tmp/docker-mailserver/fail2ban-jail.cf && cp /tmp/docker-mailserver/fail2ban-jail.cf /etc/fail2ban/jail.local diff --git a/test/tests.bats b/test/tests.bats index a0811ee1..1e3879c5 100644 --- a/test/tests.bats +++ b/test/tests.bats @@ -292,6 +292,25 @@ [ "$status" -eq 0 ] } +# +# clamav +# + +@test "checking clamav: should be listed in amavis when enabled" { + run docker exec mail grep -i 'Found secondary av scanner ClamAV-clamscan' /var/log/mail/mail.log + [ "$status" -eq 0 ] +} + +@test "checking clamav: should not be listed in amavis when disabled" { + run docker exec mail_disabled_clamav grep -i 'Found secondary av scanner ClamAV-clamscan' /var/log/mail/mail.log + [ "$status" -eq 1 ] +} + +@test "checking clamav: should not be called when disabled" { + run docker exec mail_disabled_clamav grep -i 'connect to /var/run/clamav/clamd.ctl failed' /var/log/mail/mail.log + [ "$status" -eq 1 ] +} + # # opendkim #