Skip to content

Fix do_postconf -# deleting the two lines after a key - #294

Merged
bokysan merged 2 commits into
bokysan:masterfrom
MrEbbinghaus:fix/do-postconf-delete
Oct 9, 2026
Merged

bokysan merged 2 commits into
bokysan:masterfrom
MrEbbinghaus:fix/do-postconf-delete

Conversation

@MrEbbinghaus

Copy link
Copy Markdown
Contributor

Fixes #168

When a key is in main.cf both as a comment and as an active line, do_postconf -# deletes it with:

sed -i -e "/^${key}\s*=/ { :a; N; /^\s/ba; N; d }" /etc/postfix/main.cf

The loop should collect continuation lines, but /^\s/ tests the start of the pattern space, which is always the key line. So it never loops. The extra N makes it always delete the key line plus the next two lines, whatever they are.

Fix

Use postconf -X "${key}", which removes a parameter together with its continuation lines.

Side note

Two existing tests have a mid-test ! grep … line. Bats ignores the status of negated commands unless they are the last line, so these lines can never fail.

@bokysan

bokysan commented Oct 1, 2026

Copy link
Copy Markdown
Owner

This is indeed a cool find. Thank you!

@MrEbbinghaus

Copy link
Copy Markdown
Contributor Author

Just took 2.5 years. :-)

@bokysan
bokysan merged commit f2fdeea into bokysan:master Oct 9, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Settings not applied consistently

2 participants