Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions image_root/scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ do_postconf() {
fi
if [[ "${has_key}" == "1" ]] && [[ "${has_commented_key}" == "1" ]]; then
# The key appears in the comment as well as outside the comment.
# Delete the key which is outside of the comment
sed -i -e "/^${key}\s*=/ { :a; N; /^\s/ba; N; d }" /etc/postfix/main.cf
# Delete the key which is outside of the comment (with its continuation lines)
postconf -X "${key}"
elif [[ "${has_key}" == "1" ]]; then
# Comment out the key with postconf
postconf -# "${key}" > /dev/null
Expand Down
16 changes: 15 additions & 1 deletion unit-tests/000_test-multi-comment.bats
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,18 @@ fi

result=$(grep -E "^demo" /etc/postfix/sasl_passwd | wc -l)
[ "$result" == "1" ]
}
}

@test "deleting a key that is also commented out removes only that key" {
do_postconf -e "smtpd_client_restrictions=permit"
do_postconf -# smtpd_client_restrictions
printf 'smtpd_client_restrictions = permit_mynetworks,\n reject_unlisted_sender\n' >> /etc/postfix/main.cf
do_postconf -e "mynetworks=127.0.0.0/8"
do_postconf -e "myorigin=example.org"
expected="$(postconf -n | grep -v '^smtpd_client_restrictions =')"

do_postconf -# smtpd_client_restrictions

postfix check
[ "$(postconf -n)" == "${expected}" ]
}
Loading