From 2769269bd615732e7f9d5e7b89f1d2fda2a2c1af Mon Sep 17 00:00:00 2001 From: Marko Jung Date: Mon, 29 Feb 2016 23:52:10 +0100 Subject: [PATCH 1/3] new SMTP_ONLY environment option to disable all courier daemons --- Makefile | 8 +++++++- start-mailserver.sh | 6 +++++- test/tests.bats | 16 ++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 01d7ffd6..05029946 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,12 @@ run: -v "`pwd`/test":/tmp/test \ -e ENABLE_POP3=1 \ -h mail.my-domain.com -t $(NAME) + docker run -d --name mail_smtponly \ + -v "`pwd`/postfix":/tmp/postfix \ + -v "`pwd`/spamassassin":/tmp/spamassassin \ + -v "`pwd`/test":/tmp/test \ + -e SMTP_ONLY=1 \ + -h mail.my-domain.com -t $(NAME) # Wait for containers to fully start sleep 60 @@ -47,4 +53,4 @@ clean: # Get default files back git checkout postfix/accounts.cf postfix/virtual # Remove running test containers - docker rm -f mail mail_pop3 \ No newline at end of file + docker rm -f mail mail_pop3 mail_smtponly diff --git a/start-mailserver.sh b/start-mailserver.sh index 43eb12a6..e8668a36 100644 --- a/start-mailserver.sh +++ b/start-mailserver.sh @@ -229,11 +229,15 @@ echo "Starting daemons" cron /etc/init.d/rsyslog start /etc/init.d/saslauthd start + +if [ "$SMTP_ONLY" != 1 ]; then + /etc/init.d/courier-authdaemon start /etc/init.d/courier-imap start /etc/init.d/courier-imap-ssl start -if [ "$ENABLE_POP3" = 1 ]; then +fi +if [ "$ENABLE_POP3" = 1 -a "$SMTP_ONLY" != 1 ]; then echo "Starting POP3 services" /etc/init.d/courier-pop start /etc/init.d/courier-pop-ssl start diff --git a/test/tests.bats b/test/tests.bats index 7eeed0ce..be681fb1 100644 --- a/test/tests.bats +++ b/test/tests.bats @@ -47,10 +47,26 @@ [ "$status" -eq 0 ] } +@test "checking process: courierpop3d (disabled using SMTP_ONLY)" { + run docker exec mail_smtponly /bin/bash -c "ps aux --forest | grep -v grep | grep '/usr/lib/courier/courier/courierpop3d'" + [ "$status" -eq 1 ] +} + + # # imap # +@test "checking process: courier imaplogin (enabled in default configuration)" { + run docker exec mail /bin/bash -c "ps aux --forest | grep -v grep | grep '/usr/lib/courier/courier/imaplogin'" + [ "$status" -eq 0 ] +} + +@test "checking process: courier imaplogin (disabled using SMTP_ONLY)" { + run docker exec mail_smtponly /bin/bash -c "ps aux --forest | grep -v grep | grep '/usr/lib/courier/courier/imaplogin'" + [ "$status" -eq 1 ] +} + @test "checking imap: server is ready with STARTTLS" { run docker exec mail /bin/bash -c "nc -w 1 0.0.0.0 143 | grep '* OK' | grep 'STARTTLS' | grep 'Courier-IMAP ready'" [ "$status" -eq 0 ] From ca35e0e313843a765d3167af99014608cb6cd1dd Mon Sep 17 00:00:00 2001 From: Marko Jung Date: Tue, 1 Mar 2016 00:21:23 +0100 Subject: [PATCH 2/3] on special request also some documentation --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 7b841fca..43021837 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,8 @@ Example: * *6.31* (default) => add 'spam detected' headers at that level * SA_KILL * *6.31* (default) => triggers spam evasive actions) +* SMTP_ONLY + * do not launch any courier daemons (imap, pop3) Please read [how the container starts](https://github.com/tomav/docker-mailserver/blob/master/start-mailserver.sh) to understand what's expected. From cbf72bdb538d452f59d167bec6e6fab47b814619 Mon Sep 17 00:00:00 2001 From: Marko J Date: Tue, 1 Mar 2016 01:04:31 +0000 Subject: [PATCH 3/3] Better documentation for SMTP_ONLY environment variable --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 43021837..0cd895f9 100644 --- a/README.md +++ b/README.md @@ -88,14 +88,15 @@ Example: * ENABLE_POP3 * *empty* (default) => POP3 service disabled * 1 => Enables POP3 service +* SMTP_ONLY + * *empty* (default) => courier daemons might start + * *1 => do not launch any courier daemons (imap, pop3) * SA_TAG * *2.0* (default) => add spam info headers if at, or above that level * SA_TAG2 * *6.31* (default) => add 'spam detected' headers at that level * SA_KILL * *6.31* (default) => triggers spam evasive actions) -* SMTP_ONLY - * do not launch any courier daemons (imap, pop3) Please read [how the container starts](https://github.com/tomav/docker-mailserver/blob/master/start-mailserver.sh) to understand what's expected.