- Timestamp:
- 01/09/26 15:09:27 (34 hours ago)
- File:
-
- 1 edited
-
branches/cname-collision/DNSDB.pm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/cname-collision/DNSDB.pm
r974 r978 635 635 # my $msg = 'OK'; 636 636 637 if (${$args{rectype}} == 5) { 637 # The record type comparison is the only difference between two passes through this chunk of code. 638 # CNAME records require both passes, where other records only need the second one. Downside is 639 # that returning error messages needs to check the loop variable on top of whatever else it references. 640 foreach my $tcompare ('<>', '=') { 641 next if $tcompare eq '<>' && ${$args{rectype}} != 5; 638 642 # First, check for non-CNAME collisions. 639 643 my $sql = "SELECT count(*) FROM "._rectable($args{defrec}, $args{revrec}). 640 " WHERE "._recparent($args{defrec}, $args{revrec})." = ? AND type <>5 AND $hfield = ?";644 " WHERE "._recparent($args{defrec}, $args{revrec})." = ? AND type $tcompare 5 AND $hfield = ?"; 641 645 if ($args{defrec} eq 'n') { 642 646 # Expired records … … 650 654 my @t = $dbh->selectrow_array($sql, undef, @lookupargs); 651 655 if ($t[0] > 0) { 652 $errstr = "One or more non-CNAME records already exist for ".($args{revrec} eq 'y' ? $arpaname : $hcheck). 653 ". CNAME records cannot use the same name as other records."; 656 if ($tcompare eq '<>') { 657 $errstr = "One or more non-CNAME records already exist for ".($args{revrec} eq 'y' ? $arpaname : $hcheck). 658 ". CNAME records cannot use the same name as other records."; 659 } else { 660 $errstr = "There is already a CNAME present for ".($args{revrec} eq 'y' ? $arpaname : $hcheck). 661 ". Only one CNAME may be present for a given name."; 662 } 654 663 return; 655 664 } 656 }657 658 # Second, check for multiple CNAMEs659 my $sql = "SELECT count(*) FROM "._rectable($args{defrec}, $args{revrec}).660 " WHERE "._recparent($args{defrec}, $args{revrec})." = ? AND type = 5 AND $hfield = ?";661 if ($args{defrec} eq 'n') {662 # Expired records663 $sql .= " AND (stampactive = 'f' OR (stampactive = 't' AND (expires = 't' AND stamp >= now())))";664 }665 my @lookupargs = ($args{id}, $hcheck);666 if ($args{update}) {667 $sql .= " AND record_id <> ?";668 push @lookupargs, $args{update};669 }670 my @t = $dbh->selectrow_array($sql, undef, @lookupargs);671 if ($t[0] > 0) {672 $errstr = "There is already a CNAME present for ".($args{revrec} eq 'y' ? $arpaname : $hcheck).673 ". Only one CNAME may be present for a given name.";674 return;675 665 } 676 666
Note:
See TracChangeset
for help on using the changeset viewer.
![[ DNS Administrator ]](/fx/dnsadmin-logo.png)