From 68c6f247a608daa3e0799f227cbfd2cf3376ff5b Mon Sep 17 00:00:00 2001 From: wligtenberg Date: Tue, 20 Jun 2023 21:44:54 +0200 Subject: [PATCH] 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> --- target/scripts/startup/setup.d/dmarc_dkim_spf.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/target/scripts/startup/setup.d/dmarc_dkim_spf.sh b/target/scripts/startup/setup.d/dmarc_dkim_spf.sh index 20b88ea5..85c63d96 100644 --- a/target/scripts/startup/setup.d/dmarc_dkim_spf.sh +++ b/target/scripts/startup/setup.d/dmarc_dkim_spf.sh @@ -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" \