mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2024-01-19 02:48:50 +00:00
update scripts for Amavis & SpamAssassin
This commit is contained in:
parent
b4cc602b0e
commit
93c9c04912
|
@ -30,8 +30,6 @@ COPY target/scripts/helpers/log.sh /usr/local/bin/helpers/log.sh
|
|||
|
||||
RUN /bin/bash /build/packages.sh && rm -r /build
|
||||
|
||||
|
||||
|
||||
# -----------------------------------------------
|
||||
# --- Compile deb packages ----------------------
|
||||
# -----------------------------------------------
|
||||
|
@ -122,7 +120,8 @@ COPY \
|
|||
|
||||
# hadolint ignore=SC2016
|
||||
RUN <<EOF
|
||||
sedfile -i -r 's/^(CRON)=0/\1=1/g' /etc/default/spamassassin
|
||||
# ref: https://github.com/docker-mailserver/docker-mailserver/pull/3403#discussion_r1306282387
|
||||
echo 'CRON=1' >/etc/default/spamassassin
|
||||
sedfile -i -r 's/^\$INIT restart/supervisorctl restart amavis/g' /etc/spamassassin/sa-update-hooks.d/amavisd-new
|
||||
mkdir /etc/spamassassin/kam/
|
||||
curl -sSfLo /etc/spamassassin/kam/kam.sa-channels.mcgrail.com.key https://mcgrail.com/downloads/kam.sa-channels.mcgrail.com.key
|
||||
|
@ -181,7 +180,6 @@ RUN <<EOF
|
|||
ln -sf /var/log/mail/fail2ban.log /var/log/fail2ban.log
|
||||
# disable sshd jail
|
||||
rm /etc/fail2ban/jail.d/defaults-debian.conf
|
||||
mkdir /var/run/fail2ban
|
||||
EOF
|
||||
|
||||
COPY target/opendkim/opendkim.conf /etc/opendkim.conf
|
||||
|
|
|
@ -88,7 +88,7 @@ function _reload_amavis() {
|
|||
if [[ ${CHANGED} =~ ${DMS_DIR}/postfix-accounts.cf ]] || [[ ${CHANGED} =~ ${DMS_DIR}/postfix-virtual.cf ]]; then
|
||||
# /etc/postfix/vhost was updated, amavis must refresh it's config by
|
||||
# reading this file again in case of new domains, otherwise they will be ignored.
|
||||
amavisd-new reload
|
||||
amavisd reload
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
|
@ -79,11 +79,6 @@ function __setup__security__spamassassin() {
|
|||
# shellcheck disable=SC2016
|
||||
sed -i -r 's|^\$sa_kill_level_deflt (.*);|\$sa_kill_level_deflt = '"${SA_KILL}"';|g' /etc/amavis/conf.d/20-debian_defaults
|
||||
|
||||
# fix cron.daily for spamassassin
|
||||
sed -i \
|
||||
's|invoke-rc.d spamassassin reload|/etc/init\.d/spamassassin reload|g' \
|
||||
/etc/cron.daily/spamassassin
|
||||
|
||||
if [[ ${SA_SPAM_SUBJECT} == 'undef' ]]; then
|
||||
# shellcheck disable=SC2016
|
||||
sed -i -r 's|^\$sa_spam_subject_tag (.*);|\$sa_spam_subject_tag = undef;|g' /etc/amavis/conf.d/20-debian_defaults
|
||||
|
|
|
@ -94,7 +94,7 @@ autostart=false
|
|||
autorestart=true
|
||||
stdout_logfile=/var/log/supervisor/%(program_name)s.log
|
||||
stderr_logfile=/var/log/supervisor/%(program_name)s.log
|
||||
command=/usr/sbin/amavisd-new foreground
|
||||
command=/usr/sbin/amavisd foreground
|
||||
|
||||
[program:rspamd]
|
||||
startsecs=0
|
||||
|
|
|
@ -51,10 +51,8 @@ function teardown_file() {
|
|||
export CONTAINER_NAME=${CONTAINER1_NAME}
|
||||
|
||||
# give Amavis just a bit of time to print out its full debug log
|
||||
run _repeat_in_container_until_success_or_timeout 5 "${CONTAINER_NAME}" grep 'ANTI-SPAM-SA' /var/log/mail/mail.log
|
||||
run _repeat_in_container_until_success_or_timeout 20 "${CONTAINER_NAME}" grep 'SpamControl: init_pre_fork on SpamAssassin done' /var/log/mail/mail.log
|
||||
assert_success
|
||||
assert_output --partial 'loaded'
|
||||
refute_output --partial 'NOT loaded'
|
||||
}
|
||||
|
||||
@test '(Amavis enabled) SA ENV should update Amavis config' {
|
||||
|
|
|
@ -29,8 +29,12 @@ function teardown_file() { _default_teardown ; }
|
|||
}
|
||||
|
||||
@test "SA - Amavis integration should not be active" {
|
||||
_run_in_container_bash "grep -i 'ANTI-SPAM-SA code' /var/log/mail/mail.log | grep 'NOT loaded'"
|
||||
# Wait until Amavis has finished initializing:
|
||||
run _repeat_in_container_until_success_or_timeout 20 "${CONTAINER_NAME}" grep 'Deleting db files in /var/lib/amavis/db' /var/log/mail/mail.log
|
||||
assert_success
|
||||
# Amavis module for SA should not be loaded (`SpamControl: scanner SpamAssassin, module Amavis::SpamControl::SpamAssassin`):
|
||||
_run_in_container grep 'scanner SpamAssassin' /var/log/mail/mail.log
|
||||
assert_failure
|
||||
}
|
||||
|
||||
@test "SA - should not have been called" {
|
||||
|
|
Loading…
Reference in a new issue