Fix issue with concatenating $dmarc_milter and $dkim_milter in main.cf (#3380)

* Fix issue with concatenating $dmarc_milter and $dkim_milter in main.cf 

Upon each start the  `smtpd_milters` and `non_smtpd_milters` would be extended with the following:
```
smtpd_milters =   $dmarc_milter $dkim_milter
non_smtpd_milters = $dkim_milter
```
In my case they became long enough that mail delivery stopped. I think this was because of the extra headers that are added by these steps. (which in turn would cause the mail to be dropped)

* fix sed to work when the variables are there and when they are not.

---------

Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
This commit is contained in:
wligtenberg 2023-06-20 21:44:54 +02:00 committed by GitHub
parent 2b400a9269
commit 68c6f247a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -17,8 +17,8 @@ function _setup_opendkim() {
postconf 'dkim_milter = inet:localhost:8891'
# shellcheck disable=SC2016
sed -i -E \
-e 's|^(smtpd_milters =.*)|\1 \$dkim_milter|g' \
-e 's|^(non_smtpd_milters =.*)|\1 \$dkim_milter|g' \
-e '/\$dkim_milter/! s|^(smtpd_milters =.*)|\1 \$dkim_milter|g' \
-e '/\$dkim_milter/! s|^(non_smtpd_milters =.*)|\1 \$dkim_milter|g' \
/etc/postfix/main.cf
# check if any keys are available
@ -64,7 +64,7 @@ function _setup_opendmarc() {
postconf 'dmarc_milter = inet:localhost:8893'
# Make sure to append the OpenDMARC milter _after_ the OpenDKIM milter!
# shellcheck disable=SC2016
sed -i -E 's|^(smtpd_milters =.*)|\1 \$dmarc_milter|g' /etc/postfix/main.cf
sed -i -E '/\$dmarc_milter/! s|^(smtpd_milters =.*)|\1 \$dmarc_milter|g' /etc/postfix/main.cf
sed -i \
-e "s|^AuthservID.*$|AuthservID ${HOSTNAME}|g" \