diff --git a/Dockerfile b/Dockerfile index 74a9fdf0..74abe533 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ MAINTAINER Thomas VIAL RUN DEBIAN_FRONTEND=noninteractive apt-get update -q --fix-missing && \ apt-get -y upgrade && \ apt-get -y install --no-install-recommends \ - postfix dovecot-core dovecot-imapd dovecot-pop3d dovecot-sieve gamin amavisd-new spamassassin razor pyzor \ + postfix dovecot-core dovecot-imapd dovecot-pop3d dovecot-sieve dovecot-managesieved gamin amavisd-new spamassassin razor pyzor \ clamav clamav-daemon libnet-dns-perl libmail-spf-perl bzip2 file gzip p7zip unzip arj rsyslog \ opendkim opendkim-tools opendmarc curl fail2ban ed iptables && \ curl -sk http://neuro.debian.net/lists/trusty.de-m.libre > /etc/apt/sources.list.d/neurodebian.sources.list && \ @@ -74,6 +74,6 @@ RUN curl -s https://letsencrypt.org/certs/lets-encrypt-x1-cross-signed.pem > /et ADD target/bin/generate-ssl-certificate target/bin/generate-dkim-config target/start-mailserver.sh /usr/local/bin/ RUN chmod +x /usr/local/bin/* -EXPOSE 25 587 143 993 110 995 +EXPOSE 25 587 143 993 110 995 4190 CMD /usr/local/bin/start-mailserver.sh diff --git a/Makefile b/Makefile index f0b50cd5..4c960288 100644 --- a/Makefile +++ b/Makefile @@ -23,6 +23,7 @@ run: -e SA_TAG2=2.0 \ -e SA_KILL=3.0 \ -e SASL_PASSWD=testing \ + -e ENABLE_MANAGE_SIEVE=1 \ -h mail.my-domain.com -t $(NAME) sleep 20 docker run -d --name mail_pop3 \ diff --git a/README.md b/README.md index ad26d14f..54e7239e 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,11 @@ If you enable Fail2Ban, don't forget to add the following lines to your `docker- Otherwise, `iptables` won't be able to ban IPs. +##### ENABLE_MANAGE_SIEVE + + - **empty** => Managesieve service disabled + - 1 => Enables Managesieve on port 4190 + ##### SA_TAG - **2.0** => add spam info headers if at, or above that level diff --git a/target/start-mailserver.sh b/target/start-mailserver.sh index 223ab9d8..4d44c0ae 100644 --- a/target/start-mailserver.sh +++ b/target/start-mailserver.sh @@ -23,6 +23,7 @@ if [ -f /tmp/docker-mailserver/postfix-accounts.cf ]; then cp -a /usr/share/dovecot/protocols.d /etc/dovecot/ # Disable pop3 (it will be eventually enabled later in the script, if requested) mv /etc/dovecot/protocols.d/pop3d.protocol /etc/dovecot/protocols.d/pop3d.protocol.disab + mv /etc/dovecot/protocols.d/managesieved.protocol /etc/dovecot/protocols.d/managesieved.protocol.disab sed -i -e 's/#ssl = yes/ssl = yes/g' /etc/dovecot/conf.d/10-master.conf sed -i -e 's/#port = 993/port = 993/g' /etc/dovecot/conf.d/10-master.conf sed -i -e 's/#port = 995/port = 995/g' /etc/dovecot/conf.d/10-master.conf @@ -234,6 +235,12 @@ echo "Starting daemons" cron /etc/init.d/rsyslog start +# Enable Managesieve service by setting the symlink +# to the configuration file Dovecot will actually find +if [ "$ENABLE_MANAGE_SIEVE" = 1 ]; then + mv /etc/dovecot/protocols.d/managesieved.protocol.disab /etc/dovecot/protocols.d/managesieved.protocol +fi + if [ "$SMTP_ONLY" != 1 ]; then # Here we are starting sasl and imap, not pop3 because it's disabled by default echo " * Starting dovecot services" diff --git a/test/tests.bats b/test/tests.bats index 7f3772d2..0141beec 100644 --- a/test/tests.bats +++ b/test/tests.bats @@ -419,3 +419,13 @@ [ "$status" -eq 0 ] [ "$output" = 1 ] } + +@test "checking manage sieve: server is ready when ENABLE_MANAGE_SIEVE has been set" { + run docker exec mail /bin/bash -c "nc -z 0.0.0.0 4190" + [ "$status" -eq 0 ] +} + +@test "checking manage sieve: disabled per default" { + run docker exec mail_pop3 /bin/bash -c "nc -z 0.0.0.0 4190" + [ "$status" -ne 0 ] +}