Repository navigation
Handle a renamed main domain on cPanel - #91
Conversation
Changing an account's main domain in WHM removed the old zone from the panel and created a new one, and SecondDNS heard about neither: the old zone stayed on the secondary for a domain that no longer exists, the new one was never registered. Same defect as DirectAdmin #78, filed as #87 and left until a cPanel server existed to see it on. WHM fires Whostmgr::Accounts::Modify for this, and a probe on both stages showed the payload carries only the new name and the user: pre domain=my999domain.com user=my123domain post domain=my999domain.com user=my123domain The old name is nowhere in it — which is why cPanel's own ChangeDomains framework captures it at stage pre. The hook does the same: at pre the account on disk is still the old one, so the old main domain comes from userdata and the new one from the payload. WHM fires this event for every account change — quota, package, contact — so the hook queues nothing unless the two names differ. Live: my999domain.com -> my777domain.com, old zone deleted, new one delivered and answering on the secondary within seconds. tests/test_cpanel_rename.sh: both operations and their order, an unchanged domain queueing nothing, a quota-only change carrying no domain, an unknown account, an IDN new name in punycode, and an unusable new name that still removes the old zone and logs the refusal. Mutations: dropping the old-vs-new comparison fails 1, skipping the removal of the old zone fails 5.
|
Ready to merge. Verified: the hook runs at stage pre and assembles the pair the way cPanel's own ChangeDomains does — old name from userdata, new from the payload; an unchanged domain and a domain-less change (quota, package) queue nothing, with the mutation on that condition red; delete then create in queue order; IDN in punycode; an unusable new name still removes the old (consistent with the DirectAdmin hook and with the master, which no longer has it). Registered in install and removed in uninstall, CI green, no attribution trailers, comments within two lines apart from the file header. Closes #87. |
The README said two scripts and four events, two of which cPanel does not fire. It is three scripts and five events now, and the beta banner goes: the integration has been through the full round on a live cPanel 136 server — account create and remove, addon, alias, IDN, rename, and the queue under an unreachable API. Also noted: WHM refuses Unicode in the domain field, so an IDN has to be entered in punycode there — unlike DirectAdmin, which accepts either.
|
Docs updated in this PR too — the cPanel README was describing an integration that never worked. It said "two shell scripts ... 4 events", and two of those four (
The Beta banner removed, and the panel table in the root README now reads 5 events, incl. rename + addon/alias against cPanel/WHM 136 — the version the round was actually run on, rather than the Added a note that WHM refuses Unicode in the domain field, so an IDN must be entered in punycode there. DirectAdmin accepts either, so this is worth saying on the cPanel page specifically. Checked both ways: every event the installer registers appears in the README, and every event the README names is registered. |
|
Verified the docs half both ways on the head: the seven events the installer registers (Accounts::Create/Modify/Remove, Domain::park/unpark, and the two Api2 AddonDomain fallbacks) are all named in the cPanel README and nothing named there is unregistered; no 'beta' left on the cPanel page or in the root table; version stated as the one the circle ran on; the punycode note is cPanel-specific and says so. CI green, no attribution trailers. Ready to merge — with it all four panels are documented as what they are. |
Closes #87.
Changing an account's main domain in WHM removed the old zone from the panel and created a new one — and SecondDNS heard about neither. The old zone stayed on the secondary for a domain that no longer exists; the new one was never registered. Same defect as DirectAdmin #78, filed as #87 and deliberately left until there was a cPanel server to watch it on.
What WHM actually sends
Whostmgr::Accounts::Modify, probed on both stages during a real rename:Only the new name, on both stages. The old one is nowhere in the payload — which is exactly why cPanel's own
Cpanel::Hooks::ChangeDomainscaptures it at stageprebefore the change lands.The hook does the same: at
prethe account on disk is still the old one, so the old main domain comes fromuserdataand the new one from the payload.WHM fires this event for every account change — quota, package, contact address — so the hook queues nothing unless the two names actually differ.
Live
and the secondary answers
SOA ... 2026090604for the new name, nothing for the old one.Tests
tests/test_cpanel_rename.sh, 12 checks: both operations and their order (delete old, then create new), an unchanged domain queueing nothing, a quota-only change with no domain in it, an unknown account, an IDN new name arriving as punycode, and an unusable new name that still removes the old zone and logs the refusal.Mutations: dropping the old-vs-new comparison fails 1 — the hook would fire on every quota change; skipping the removal of the old zone fails 5.
This closes the cPanel round
Five defects found on the live box today, each of which made the integration non-functional: the PowerDNS reload (#89), the payload read from the wrong level,
Accounts::Removecarrying no domain, a subscription to an event cPanel does not have (all #90), and this one.