Changeset 632


Ignore:
Timestamp:
05/14/14 17:15:16 (10 years ago)
Author:
Kris Deugau
Message:

/trunk

Partly close a hole in validation of CNAMEs; a CNAME may not be used for
the root domain/zone (since a CNAME may not have sibling records for the
same FQDN). Checking for siblings is likely going to be trickier.

See #53, sort of.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r631 r632  
    627627      my $revzone = new NetAddr::IP $self->revName($args{id}, 'y');
    628628      return ('FAIL', $errstr) if !$self->_inrev($args{val}, $revzone);
     629      # CNAMEs can not be used for parent nodes;  just leaf nodes with no other record types
     630      # note that this WILL probably miss some edge cases.
     631      if (${$args{val}} =~ /^[\d.\/]+$/) {
     632        # convert IP "hostname" to .arpa
     633        my $tmphn = _ZONE(NetAddr::IP->new(${$args{val}}), 'ZONE', 'r', '.');
     634        my $tmpz = _ZONE($revzone, 'ZONE', 'r', '.');
     635        return ('FAIL', "The bare zone may not be a CNAME") if $tmphn eq $tmpz;
     636      }
    629637    }
    630638
     
    644652    my $pname = ($args{defrec} eq 'y' ? 'DOMAIN' : $self->domainName($args{id}));
    645653    ${$args{host}} =~ s/\.*$/\.$pname/ if ${$args{host}} !~ /$pname$/;
     654
     655    # CNAMEs can not be used for parent nodes;  just leaf nodes with no other record types
     656    # Enforce this for the zone name
     657    return ('FAIL', "The bare zone name may not be a CNAME") if ${$args{host}} eq $pname;
    646658
    647659##enhance:  Look up the passed value to see if it exists.  Ooo, fancy.
Note: See TracChangeset for help on using the changeset viewer.