Repository navigation
feat(tsig): BIND panels — enable, disable, restore and the installer choice - #98
Conversation
…choice seconddns-tsig enable puts the key on BIND (key file 0640, include, key in allow-transfer of the options block), restarts the queue worker, sets the key on this server's zones and only then drops our IPs from allow-transfer; other entries and comments stay. disable mirrors it; restore puts the key back after the panel rewrote its configuration. Every edit is backed up, checked by named-checkconf and rolled back on rejection. Edits happen only while named is the running DNS server. cPanel and DirectAdmin installers take --tsig=[ALG:]KEY:SECRET or ask on a terminal (IP by default); uninstallers turn TSIG off first. All panels install seconddns_bind.py next to seconddns-tsig.
The cPanel fixture sets directory "/var/named" and includes named.rfc1912.zones, so named-checkconf rejected even the untouched file. CI had no BIND, so the check never ran until the TSIG test brought bind9 to the runner. With a root holding those paths it accepts the installers' edits and still rejects a broken one (talso-notify).
named-checkconf -t needs root and the CI runner is not; rewriting the /var/named prefix in the checked copy gives the same paths without it.
|
CHANGES REQUESTED at 449dd46, three points. Verified: the enable order (key accepted next to our IPs →
Plesk and the PowerDNS panels: as described, separate PRs. |
…key group from named - enable records the allow-transfer entries it removed (removed_entries) and disable puts exactly those back, so an IPv6 entry is not replaced by the first IPv4 address. - A reload that fails after named-checkconf passed restores the backup, reloads again and stops: named-checkconf does not read the key file the way named does, and the next named restart would not load the config. - The key file group is the group of the running named process, not of the options file; enable refuses when it cannot be determined.
|
APPROVED at b7d5c56. All three points closed with rows: (1) Merge into develop. Plesk (key in the |
Step 2 of 3 for #96: cPanel with BIND and DirectAdmin. Plesk and PowerDNS panels follow separately (see below).
How a customer turns it on. The installer either takes
--tsig=[ALG:]KEY:SECRETor asks on a terminal:The secret is read without echo.
--yeswithout--tsig, or no terminal, keeps the IP path; that path is unchanged. On an existing install:seconddns-tsig enable --tsig=….seconddns-tsig enable, in this order so no transfer is ever refused:include, andkey "…"added toallow-transferinoptionsnext to our IPs. Backup,named-checkconf(rollback on rejection),rndc reload.[tsig]stored,seconddns-queuedrestarted (it reads the config once), so new zones are created with the key.masterIp= this server).allow-transfer. Other entries and their comments stay.If a zone could not be switched, our IPs stay and the command says how to finish. Zone-level
allow-transferentries naming our IP (cPanel WHM "Additional zone configuration") overrideoptions: they are counted and the WHM line with the key is printed.disablemirrors it: IP back,[tsig]off and worker restarted, zones unsigned, then the key goes. If a zone keeps the key,[tsig]is put back and the key stays on BIND, so a rerun finishes.restoreputs the key file, include and key entry back when the panel rewrote its configuration; it is silent when nothing is missing.setupis the installer step above.Edits happen only while
namedis the running DNS server: anamed.confleft on a PowerDNS server is not touched.Existing code, every touched line:
cpanel,directadmininstall.sh: one--tsig=*case, one help line, and theseconddns-tsig setupcall before the initial sync (failure only prints a hint).install.sh: one line installingseconddns_bind.pynext to the PR-1 line.uninstall.sh:seconddns-tsig disable --zonesbefore the first removal step, while the config and the tool still exist;seconddns_bind.pyadded to the PR-1 rm line.configure_named_axfrIP step is untouched.Tests:
test_tsig_bind.sh(44 checks, mock API, stand-in checkconf, reload and worker restart):named.conffixture:none, multi-line list with a trailing comment, entries inside comments left alone, idempotent;--tsig, with--yesand without BIND.test_tsig_bind_named.sh(9 checks, a realnamed): from our IP, AXFR without the key is refused, with the key it transfers, with a wrong secret it is refused; the customer's other secondary still transfers by IP; restore; after disable our IP transfers again. Run on Ubuntu 24.04 with BIND 9.18.39: 9/9. CI installsbind9and fails if the test reports itself skipped.test_tsig.sh35,test_queue.sh104,test_named_conf_edit.sh34,test_initial_sync.sh34: unchanged and green.Not verified in a live panel (owner decision, no panel servers): the installer prompt inside a real cPanel/DirectAdmin install, and whether either panel rewrites
named.conf(that case is whatrestoreis for).Found while doing this, not changed here: Plesk includes
allow-transfer { common-allow-transfer; };in every zone, sooptionsdoes not apply to Plesk zones. TSIG on Plesk needs the key in that ACL, kept byrestore. Plesk stays on the IP path until that PR. The same finding may affect the existing IP step on Plesk; to be checked separately.