jethrocarr / namedmanager

AGPL web-based DNS management interface in PHP
349 stars 125 forks source link

Domain rename leaves junk NS records behind #80

Open thedaveCA opened 5 years ago

thedaveCA commented 5 years ago

Renaming a domain leaves some junk NS records behind that reference the original domain name.

Steps to reproduce:

  1. Create two nameservers (ns1.wonderfulhosting.example, ns2.wonderfulhosting.example)
  2. Create a domain called typodomain.example
  3. Notice the typo and rename to fixeddomain.example

The resulting zone file looks like this:

; Nameservers

fixeddomain.example.    86400 IN NS ns1.wonderfulhosting.example.
fixeddomain.example.    86400 IN NS ns2.wonderfulhosting.example.
typodomain.example      86400 IN NS ns1.wonderfulhosting.example.
typodomain.example      86400 IN NS ns2.wonderfulhosting.example.

This is relatively harmless since the records actually exist at typodomain.example.fixeddomain.example, but it is likely not what the user intended.

thedaveCA commented 5 years ago

One other interesting tidbit, in the database neither fixeddomain.example nor typodomain.example has a trailing dot, so I wonder if we couldn't simplify by replacing the NS records with @ instead? I'm not sure if there would be other side effects so I'm not prepared to make any changes to the code here myself.