Repository navigation
Edit only the options block of named.conf, and verify the result - #93
Conversation
Switching the cPanel box to BIND and rerunning the installer broke DNS. The
insert was:
sed -i "/^[[:space:]]*};/i\\ also-notify { IP; };"
which writes before *every* closing brace in the file. cPanel ships a
named.conf with three views and a logging block, so also-notify landed inside
logging and inside a log channel:
/etc/named.conf:30: unknown option 'also-notify'
/etc/named.conf:34: unknown option 'also-notify'
named stopped answering, and the installer printed "[+] BIND configured and
reloaded". On a flat named.conf with one block the same code looked correct,
which is why it survived.
Also, cPanel's ACL is quoted — `allow-transfer { "none"; };` — and the code
stripped only an unquoted `none;`, leaving `{ IP; "none"; }`.
- the insert is bounded to the options block, as DirectAdmin already did
- the quoted "none" is removed too, in all three installers
- after editing, named-checkconf decides: a config it rejects is restored from
the backup and reported, instead of reloading and claiming success
Verified against the real cPanel named.conf, kept as a fixture: one
also-notify in options, logging untouched, named-checkconf clean.
tests/test_named_conf_edit.sh asserts, for every installer that edits
named.conf: the insert is bounded to options, a quoted "none" is removed, the
config is verified, a broken one is reported, and the backup is restored.
Lower bound of 3 installers.
|
CHANGES REQUESTED, one item. The fix is right — the insert is bounded to the options block, the quoted "none" is removed, and every BIND path now runs named-checkconf with a rollback before it says anything. The test is not: it greps the installers' source for the sed pattern, so it asserts wording, and the fixture cpanel-named.conf (three views, a logging block — the exact shape that broke) is shipped but never used. That is the same trap as checking a comment instead of the lock. Make it behavioural: copy the fixture, run the installer's edit against it (extract the block or call the function), and assert exactly one allow-transfer and one also-notify, both inside the options block and none inside logging or any view, no leftover "none", and brace balance unchanged; mutation: the old unbounded sed → red. The source-grep rows can stay as the cheap ones. CI green, no attribution trailers, comments within two lines apart from the fixture's own BIND comments. |
The test asserted the shape of a sed command and left the fixture unused — checking the wording instead of the lock, and the fixture was the one thing that reproduced the failure. The edit is now a function, configure_named_axfr, that the test extracts from each installer and applies to a copy of the real cPanel named.conf: exactly one allow-transfer and one also-notify, both inside options, nothing in logging or any view, no leftover "none", braces balanced, and named-checkconf clean where it is available. The greps stay as cheap checks that the reload is gated. Making it callable also made it portable: sed -i and \? are GNU-only, and on BSD the old commands silently produced 'talso-notify' and left the quoted "none" in place. The insert is awk now, bounded to the options block. Mutations: the original unbounded sed writes also-notify 13 times, into logging and into a view — 3 red; not stripping "none" — 1 red; replacing 'if named-checkconf' with 'if true' — 1 red, after the criterion was narrowed from the word appearing anywhere to it gating the branch.
|
Fixed — the test now runs the edit instead of describing it. The edit is a function,
34 checks across the three installers. The greps stay as the cheap half: that the reload is gated and the backup restored. Mutations
The last one needed the criterion narrowed first: my check looked for the word A second defect surfaced while making it callable. Verified once more against the live server's own |
|
Verified: the edit now runs on a copy of the cPanel fixture and the rows assert the property — one directive each, both inside options, logging and views untouched, no "none" beside the address, braces balanced, named-checkconf accepting it where available — with the unbounded-sed mutation producing the thirteen inserts that took DNS down; the check-config row is on the branch, not on the word; the insert is awk and POSIX, which is what surfaced the GNU-only sed. CI green, no attribution trailers, the only long comment run is the fixture's own BIND comments. Ready to merge into develop. |
Switching the cPanel box to BIND and rerunning the installer broke DNS, and the installer said it had succeeded.
What happened
The insert was:
sed -i "/^[[:space:]]*};/i\\ also-notify { $SECONDARY_IP; };"That writes before every closing brace in the file. cPanel ships a
named.confwith aloggingblock and threeviews, soalso-notifylanded insideloggingand inside a log channel:namedstopped answering queries. The installer printed[+] BIND configured and reloaded.On a flat
named.confwith a single block the same code looks correct — which is why it survived until a panel with views was tried.Second problem on the same path: cPanel's ACL is quoted,
allow-transfer { "none"; };, and the code stripped only an unquotednone;, producingallow-transfer { IP; "none"; }.Fix
optionsblock — DirectAdmin already did this, cPanel and Plesk did not"none"is removed as well, in all three installersnamed-checkconfdecides: a config it rejects is restored from the backup and reported, instead of being reloaded under a success messageVerified on the real file
The cPanel
named.conffrom the live server is kept as a fixture. Applying the new commands to it:The old commands on the same file produced three inserts, two of them in
logging, and a filenamedcould not parse.Tests
tests/test_named_conf_edit.sh, 19 checks across the installers that editnamed.conf: the insert is bounded tooptions, a quoted"none"is removed, the config is verified before reload, a broken one is reported rather than announced as success, and the backup is restored. Lower bound of 3 installers so a rename fails here instead of matching nothing.Note
This is the third time this cycle that an installer reported success over a service it had just broken — the CyberPanel PowerDNS restart loop, the DirectAdmin restart without a liveness check (#89), and now this. All three now verify before claiming anything.