Skip to content

Commit 9ee33a8

Browse files
scripts: make policyd-spf configurable (docker-mailserver#3246)
1 parent bbe1d2d commit 9ee33a8

6 files changed

Lines changed: 35 additions & 3 deletions

File tree

docs/content/config/environment.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,13 @@ Enables the OpenDMARC service.
110110
- **1** => Enabled
111111
- 0 => Disabled
112112

113+
##### ENABLE_POLICYD_SPF
114+
115+
Enabled `policyd-spf` in Postfix's configuration. You will likely want to set this to `0` in case you're using Rspamd ([`ENABLE_RSPAMD=1`](#enable_rspamd)).
116+
117+
- 0 => Disabled
118+
- **1** => Enabled
119+
113120
##### ENABLE_POP3
114121

115122
- **empty** => POP3 service disabled

mailserver.env

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,14 @@ ENABLE_OPENDKIM=1
105105
# 0 => Disabled
106106
ENABLE_OPENDMARC=1
107107

108+
109+
# Enabled `policyd-spf` in Postfix's configuration. You will likely want to set this
110+
# to `0` in case you're using Rspamd (`ENABLE_RSPAMD=1`).
111+
#
112+
# - 0 => Disabled
113+
# - **1** => Enabled
114+
ENABLE_POLICYD_SPF=1
115+
108116
# 1 => Enables POP3 service
109117
# empty => disables POP3
110118
ENABLE_POP3=

target/postfix/master.cf

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ sender-cleanup unix n - n - 0 cleanup
4848
-o syslog_name=postfix/sender-cleanup
4949
-o header_checks=pcre:/etc/postfix/maps/sender_header_filter.pcre
5050

51-
policyd-spf unix - n n - 0 spawn
52-
user=policyd-spf argv=/usr/bin/policyd-spf
53-
5451
cleanup unix n - n - 0 cleanup
5552
qmgr unix n - n 300 1 qmgr
5653
tlsmgr unix - - n 1000? 1 tlsmgr

target/scripts/start-mailserver.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ function _register_functions
8080

8181
_register_setup_function '_setup_opendkim'
8282
_register_setup_function '_setup_opendmarc' # must come after `_setup_opendkim`
83+
_register_setup_function '_setup_policyd_spf'
8384

8485
_register_setup_function '_setup_security_stack'
8586
_register_setup_function '_setup_spam_to_junk'

target/scripts/startup/setup.d/dmarc_dkim_spf.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,21 @@ function _setup_opendmarc
8484
_log 'debug' 'Disabling OpenDMARC'
8585
fi
8686
}
87+
88+
# Configures the SPF check inside Postfix's configuration via policyd-spf. When
89+
# using Rspamd, you will likely want to turn that off.
90+
function _setup_policyd_spf
91+
{
92+
if [[ ${ENABLE_POLICYD_SPF} -eq 1 ]]
93+
then
94+
_log 'debug' 'Configuring policyd-spf'
95+
cat >>/etc/postfix/master.cf <<EOF
96+
97+
policyd-spf unix - n n - 0 spawn
98+
user=policyd-spf argv=/usr/bin/policyd-spf
99+
EOF
100+
else
101+
_log 'debug' 'Disabling policyd-spf'
102+
sedfile -i -E 's|check_policy_service unix:private/policyd-spf, ||g' /etc/postfix/main.cf
103+
fi
104+
}

target/scripts/startup/variables-stack.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ function __environment_variables_general_setup
7474
VARS[ENABLE_MANAGESIEVE]="${ENABLE_MANAGESIEVE:=0}"
7575
VARS[ENABLE_OPENDKIM]="${ENABLE_OPENDKIM:=1}"
7676
VARS[ENABLE_OPENDMARC]="${ENABLE_OPENDMARC:=1}"
77+
VARS[ENABLE_POLICYD_SPF]="${ENABLE_POLICYD_SPF:=1}"
7778
VARS[ENABLE_POP3]="${ENABLE_POP3:=0}"
7879
VARS[ENABLE_POSTGREY]="${ENABLE_POSTGREY:=0}"
7980
VARS[ENABLE_QUOTAS]="${ENABLE_QUOTAS:=1}"

0 commit comments

Comments
 (0)