added plausibility checks for milter insertion#3111
Closed
georglauterbach wants to merge 3 commits intomasterfrom
Closed
added plausibility checks for milter insertion#3111georglauterbach wants to merge 3 commits intomasterfrom
georglauterbach wants to merge 3 commits intomasterfrom
Conversation
polarathene
requested changes
Feb 24, 2023
Comment on lines
+41
to
+47
| if grep -q -E '^smtpd_milters.*=.*rspamd_milter' /etc/postfix/main.cf | ||
| then | ||
| _log 'warn' "'smtpd_milters' already contains Rspamd milter, it will not be added twice - likely an inconsistency (did you run docker compose down properly?)" | ||
| else | ||
| # shellcheck disable=SC2016 | ||
| sed -i -E 's|^(smtpd_milters =.*)|\1 \$rspamd_milter|g' /etc/postfix/main.cf | ||
| fi |
Member
There was a problem hiding this comment.
A warning like that doesn't seem necessary to communicate?
Ignore, postconf is a smarter approach
The DB helper has a method that could be re-used for checking duplicates I think?:
docker-mailserver/target/scripts/helpers/database/db.sh
Lines 130 to 140 in 199e3c7
but we could also do this:
# Method to update settings while avoiding adding duplicates
function _maincf_append_value_to_key_if_missing()
{
local KEY=$1
local VALUE_TO_APPEND=$2
# Extract value of key from main.cf:
local VALUE=$(sed -nE "s/^${KEY} = (.*)/\1/p" /etc/postfix/main.cf)
if ! grep -q -F "${VALUE_TO_APPEND}" <<< "${VALUE}"
then
postconf "${KEY} = ${VALUE} ${VALUE_TO_APPEND}"
fi
}
# ....
_maincf_append_value_to_key_if_missing 'smtpd_milters' '$rspamd_milter'
_maincf_append_value_to_key_if_missing 'smtpd_milters' '$dmarc_milter'
_maincf_append_value_to_key_if_missing 'smtpd_milters' '$dkim_milter'
_maincf_append_value_to_key_if_missing 'non_smtpd_milters' '$dkim_milter'Names of things could perhaps be better, but simple enough to re-use:
- Give it a key and a value to append
- If there's a match for that key, then append the value via
postconf😎 (it'll ensure consistent white-space formatting between key and values)
Member
Author
|
I've actually committed to going a different (a bit more invasive approach). The insert-and-check functionality is not needed then. I will provide a new PR for this in a short while. |
8 tasks
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Makes the insertion of milters more robust.
Fixes #3109
Type of change
Checklist:
docs/)