Added the missing newlines, added the support for new parameters, fixed the issue of non-unlinkable daemon pid, ensured that configuration changes are not duplicated, updated some tests and added two new ones
This commit is contained in:
parent
11d4fd9726
commit
f26656d405
|
@ -75,6 +75,8 @@ RUN sed -i -r 's/^(CRON)=0/\1=1/g' /etc/default/spamassassin
|
|||
COPY target/postgrey/postgrey /etc/default/postgrey
|
||||
COPY target/postgrey/postgrey.init /etc/init.d/postgrey
|
||||
RUN chmod 755 /etc/init.d/postgrey
|
||||
RUN mkdir /var/run/postgrey
|
||||
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
|
||||
|
|
5
Makefile
5
Makefile
|
@ -123,8 +123,11 @@ run:
|
|||
-v "`pwd`/test/config":/tmp/docker-mailserver \
|
||||
-v "`pwd`/test":/tmp/docker-mailserver-test \
|
||||
-e ENABLE_POSTGREY=1 \
|
||||
-e POSTGREY_DELAY=15 \
|
||||
-e POSTGREY_MAX_AGE=35 \
|
||||
-e POSTGREY_TEXT="Delayed by postgrey" \
|
||||
-h mail.my-domain.com -t $(NAME)
|
||||
sleep 15
|
||||
sleep 20
|
||||
|
||||
|
||||
fixtures:
|
||||
|
|
|
@ -3,5 +3,3 @@
|
|||
# --max-age=N delete old entries after N days (default: 35)
|
||||
|
||||
POSTGREY_OPTS="--inet=10023"
|
||||
|
||||
#POSTGREY_TEXT="Your customized rejection message here"
|
|
@ -26,7 +26,7 @@ DAEMON_NAME=postgrey
|
|||
DESC="postfix greylisting daemon"
|
||||
DAEMON_USER=postgrey
|
||||
|
||||
PIDFILE=/var/run/$DAEMON_NAME.pid
|
||||
PIDFILE=/var/run/$DAEMON_NAME/$DAEMON_NAME.pid
|
||||
SCRIPTNAME=/etc/init.d/$DAEMON_NAME
|
||||
|
||||
# Gracefully exit if the package has been removed.
|
||||
|
@ -138,4 +138,4 @@ case "$1" in
|
|||
;;
|
||||
esac
|
||||
|
||||
exit $ret
|
||||
exit $ret
|
||||
|
|
|
@ -15,6 +15,9 @@ DEFAULT_VARS["ENABLE_MANAGESIEVE"]="${ENABLE_MANAGESIEVE:="0"}"
|
|||
DEFAULT_VARS["ENABLE_FETCHMAIL"]="${ENABLE_FETCHMAIL:="0"}"
|
||||
DEFAULT_VARS["ENABLE_LDAP"]="${ENABLE_LDAP:="0"}"
|
||||
DEFAULT_VARS["ENABLE_POSTGREY"]="${ENABLE_POSTGREY:="0"}"
|
||||
DEFAULT_VARS["POSTGREY_DELAY"]="${POSTGREY_DELAY:="300"}"
|
||||
DEFAULT_VARS["POSTGREY_MAX_AGE"]="${POSTGREY_MAX_AGE:="35"}"
|
||||
DEFAULT_VARS["POSTGREY_TEXT"]="${POSTGREY_TEXT:="Delayed by postgrey"}"
|
||||
DEFAULT_VARS["ENABLE_SASLAUTHD"]="${ENABLE_SASLAUTHD:="0"}"
|
||||
DEFAULT_VARS["SMTP_ONLY"]="${SMTP_ONLY:="0"}"
|
||||
DEFAULT_VARS["VIRUSMAILS_DELETE_DELAY"]="${VIRUSMAILS_DELETE_DELAY:="7"}"
|
||||
|
@ -147,7 +150,7 @@ function register_functions() {
|
|||
_register_start_daemon "_start_daemons_opendkim"
|
||||
_register_start_daemon "_start_daemons_opendmarc"
|
||||
|
||||
#postfix uses postgray, needs to be started before postfix
|
||||
#postfix uses postgrey, needs to be started before postfix
|
||||
if [ "$ENABLE_POSTGREY" = 1 ]; then
|
||||
_register_start_daemon "_start_daemons_postgrey"
|
||||
fi
|
||||
|
@ -501,9 +504,16 @@ function _setup_ldap() {
|
|||
|
||||
function _setup_postgrey() {
|
||||
notify 'inf' "Configuring postgrey"
|
||||
sed -i -e 's/bl.spamcop.net/bl.spamcop.net, check_policy_service inet:127.0.0.1:10023/' /etc/postfix/main.cf
|
||||
sed -i -e 's/bl.spamcop.net$/bl.spamcop.net, check_policy_service inet:127.0.0.1:10023/' /etc/postfix/main.cf
|
||||
sed -i -e "s/\"--inet=10023\"/\"--inet=10023 --delay=$POSTGREY_DELAY --max-age=$POSTGREY_MAX_AGE\"/" /etc/default/postgrey
|
||||
TEXT_FOUND=`grep -i "POSTGREY_TEXT" /etc/default/postgrey | wc -l`
|
||||
|
||||
if [ $TEXT_FOUND -eq 0 ]; then
|
||||
printf "POSTGREY_TEXT=\"$POSTGREY_TEXT\"\n\n" >> /etc/default/postgrey
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
function _setup_postfix_sasl() {
|
||||
[ ! -f /etc/postfix/sasl/smtpd.conf ] && cat > /etc/postfix/sasl/smtpd.conf << EOF
|
||||
pwcheck_method: saslauthd
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
HELO mail.external.tld
|
||||
MAIL FROM: user@external.tld
|
||||
RCPT TO: user1@localhost.localdomain
|
||||
DATA
|
||||
From: Docker Mail Server <dockermailserver@external.tld>
|
||||
To: Existing Local User <user1@localhost.localdomain>
|
||||
Date: Sat, 22 May 2010 07:43:25 -0400
|
||||
Subject: Postgrey Test Message
|
||||
This is a test mail.
|
||||
|
||||
.
|
||||
QUIT
|
|
@ -88,8 +88,18 @@ load 'test_helper/bats-assert/load'
|
|||
}
|
||||
|
||||
@test "checking postgrey: /etc/postfix/main.cf correctly edited" {
|
||||
run docker exec mail_with_postgrey /bin/bash -c "grep 'bl.spamcop.net, check_policy_service' /etc/postfix/main.cf"
|
||||
run docker exec mail_with_postgrey /bin/bash -c "grep 'bl.spamcop.net, check_policy_service inet:127.0.0.1:10023' /etc/postfix/main.cf | wc -l"
|
||||
assert_success
|
||||
assert_output 1
|
||||
}
|
||||
|
||||
@test "checking postgrey: /etc/default/postgrey correctly edited and has the default values" {
|
||||
run docker exec mail_with_postgrey /bin/bash -c "grep '^POSTGREY_OPTS=\"--inet=10023 --delay=15 --max-age=35\"$' /etc/default/postgrey | wc -l"
|
||||
assert_success
|
||||
assert_output 1
|
||||
run docker exec mail_with_postgrey /bin/bash -c "grep '^POSTGREY_TEXT=\"Delayed by postgrey\"$' /etc/default/postgrey | wc -l"
|
||||
assert_success
|
||||
assert_output 1
|
||||
}
|
||||
|
||||
@test "checking process: postgrey (postgrey server enabled)" {
|
||||
|
@ -97,6 +107,30 @@ load 'test_helper/bats-assert/load'
|
|||
assert_success
|
||||
}
|
||||
|
||||
@test "checking postgrey: there should be a log entry about a new greylisted e-mail user@external.tld in /var/log/mail/mail.log" {
|
||||
#editing the postfix config in order to ensure that postgrey handles the test e-mail. The other spam checks at smtpd_recipient_restrictionswould interfere with it.
|
||||
run docker exec mail_with_postgrey /bin/sh -c "sed -ie 's/permit_sasl_authenticated.*reject_unauth_destination,$//g' /etc/postfix/main.cf"
|
||||
run docker exec mail_with_postgrey /bin/sh -c "sed -ie 's/reject_unauth_pipelining.*reject_unknown_recipient_domain,$//g' /etc/postfix/main.cf"
|
||||
run docker exec mail_with_postgrey /bin/sh -c "sed -ie 's/reject_rbl_client.*inet:127\.0\.0\.1:10023$//g' /etc/postfix/main.cf"
|
||||
run docker exec mail_with_postgrey /bin/sh -c "sed -ie 's/smtpd_recipient_restrictions = /smtpd_recipient_restrictions = check_policy_service inet:127.0.0.1:10023/g' /etc/postfix/main.cf"
|
||||
|
||||
run docker exec mail_with_postgrey /bin/sh -c "/etc/init.d/postfix reload"
|
||||
run docker exec mail_with_postgrey /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/postgrey.txt"
|
||||
sleep 5 #ensure that the information has been written into the log
|
||||
run docker exec mail_with_postgrey /bin/bash -c "grep -i 'action=greylist.*user@external\.tld' /var/log/mail/mail.log | wc -l"
|
||||
assert_success
|
||||
assert_output 1
|
||||
}
|
||||
|
||||
@test "checking postgrey: there should be a log entry about the retried and passed e-mail user@external.tld in /var/log/mail/mail.log" {
|
||||
sleep 20 #wait 20 seconds so that postgrey would accept the message
|
||||
run docker exec mail_with_postgrey /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/postgrey.txt"
|
||||
sleep 8
|
||||
run docker exec mail_with_postgrey /bin/sh -c "grep -i 'action=pass, reason=triplet found.*user@external\.tld' /var/log/mail/mail.log | wc -l"
|
||||
assert_success
|
||||
assert_output 1
|
||||
}
|
||||
|
||||
#
|
||||
# imap
|
||||
#
|
||||
|
|
Loading…
Reference in New Issue