Skip to content

Drop cPanel's own sync, and keep the server's hostname out of it - #88

Merged
0kaba0 merged 2 commits into
developfrom
fix/cpanel-double-sync
Sep 6, 2026
Merged

0kaba0 merged 2 commits into
developfrom
fix/cpanel-double-sync

Conversation

@0kaba0

@0kaba0 0kaba0 commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator

Both found by installing on the live cPanel box — the first is a correction to #80.

cPanel had its own initial fill, and I missed it

The install ran the fill twice: the reconcile-based one from #80, and cPanel's own, which existed all along under a different name — "Sync existing cPanel accounts". My grep in #80 looked for "Queue existing domains", did not match, and I reported that cPanel had no initial fill at all.

It had one, and a worse one:

  • it POSTs to the API directly, bypassing the queue — an outage during the install loses those zones instead of retrying
  • no canonicalisation, so an IDN goes as whatever the panel happened to store
  • it reads DNS= from /var/cpanel/users, which is the account's main domain only; addon and parked domains never appear

Removed. The reconcile path already covers all of it, through the queue, with canonicalisation.

The server's own hostname was being queued

whmapi1 listzones includes the zone for the machine's own hostname — here server1.seconddns.com. The API refuses it, correctly, because it falls under the service's own domain:

[!] worker: create server1.seconddns.com permanently failed
    (HTTP 400: This domain is not allowed (code: ERR-c5f2a8b3))

So every cPanel install ended with a failed operation in the queue and an alarming line in the log, over a zone that was never the customer's. (The message being readable at all is #78 working — before that it was a bare HTTP 400.)

panel_zones() now drops the zone whose name equals the machine's FQDN, for every panel. Anyone who genuinely wants it can seconddns add it by hand.

Tests

tests/test_hostname_filter.sh: the hostname zone goes, including an uppercase form and a trailing dot; the parent zone (seconddns.com) and a subdomain of the hostname stay; a hostname with no dot drops nothing; an empty panel stays empty rather than erroring. Mutations: removing the filter fails 3, comparing without normalising fails 2.

Live

On the cPanel box after the change, panel_zones() returns only my123domain.com, and seconddns-reconcile reports ok: 1 missing: 0 stale: 0.

Installing on the live cPanel box ran the initial fill twice: #80 added the
reconcile-based one, and cPanel already had its own under a different name —
"Sync existing cPanel accounts", which my grep for "Queue existing domains"
did not match. I reported that cPanel had no initial fill at all. It had one,
and a worse one:

- it POSTs to the API directly, so an outage during install loses the zones
  instead of queueing them
- no canonicalisation, so an IDN goes as whatever the panel stored
- it reads DNS= from /var/cpanel/users, which is the account's main domain
  only — addon and parked domains are not there

Removed; the reconcile path covers all of it.

Second, on the same install: whmapi1 listzones includes the server's own
hostname zone, which the API refuses (it is under the service's domain). Every
cPanel install therefore ended with a failed op in the queue and an alarming
line in the log, on a zone that was never the customer's. panel_zones() now
drops the zone whose name is the machine's FQDN, for every panel.

tests/test_hostname_filter.sh: the hostname zone goes, case and trailing dot
included; the parent zone and a subdomain of it stay; a hostname without a dot
drops nothing; an empty panel stays empty. Mutations: removing the filter fails
3, comparing without normalising fails 2.

Live on the cPanel box: panel_zones() now returns only the customer zone and
reconcile reports ok: 1, missing: 0.
@0kaba0

0kaba0 commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator Author

One item, then ready. Both fixes are right: the old cPanel block bypassed the queue, skipped canonicalisation and saw only the primary domain, so removing it in favour of the shared fill is a strict improvement; the hostname filter compares lowercased, dot-stripped names, refuses to act on a bare short hostname, and is overridable for tests; the rows cover drop / keep order / short name. CI green, no attribution trailers. Blocker, the comment rule: the three-line block above the filter in seconddns_common.py and the three-line test header — two each ('the host's own zone is not a customer zone; add it by hand with seconddns add if wanted' is the invariant).

@0kaba0

0kaba0 commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator Author

Verified: both comments are at two lines, CI green, no attribution trailers. Ready to merge into develop.

@0kaba0
0kaba0 merged commit 07a6cf2 into develop Sep 6, 2026
1 check passed
@0kaba0
0kaba0 deleted the fix/cpanel-double-sync branch September 6, 2026 09:27
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.

1 participant