Ignore:
Timestamp:
12/11/25 16:08:08 (24 hours ago)
Author:
Kris Deugau
Message:

/branches/cname-collision

Refine collision sub calling convention/arguments
Add preliminary call in A record validation
See #72.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/cname-collision/DNSDB.pm

    r937 r938  
    614614# Check for name collisions relating to CNAMEs.  Needs to be called from all other validators.
    615615sub _cname_collision {
    616 #  my $self = shift;
    617 #  my $dbh = $self->{dbh};
    618 #
    619 #  my %args = @_;
    620 my ($hcheck,$defrec,$revrec) = @_;
    621 
    622 #  my $hcheck = ($args{revrec} eq 'y' ? ${$args{val}} : ${$args{host}});
     616  my $self = shift;
     617  my $dbh = $self->{dbh};
     618
     619  my %args = @_;
     620#my ($hcheck,$rectype,$zid,$defrec,$revrec) = @_;
     621
     622  my $hcheck = ($args{revrec} eq 'y' ? ${$args{val}} : ${$args{host}});
    623623  my $hfield = ($args{revrec} eq 'y' ? 'val' : 'host');
    624624#my $hcheck = $hname;
     
    626626  # $hcheck should be normalized by the time this sub is called.  Convert to the formal .arpa name for error reporting in reverse zones.
    627627  my $arpaname = '';
    628   if ($revrec eq 'y') {
     628  if ($args{revrec} eq 'y') {
    629629    $arpaname = NetAddr::IP->new($hcheck);
    630630##fixme:  more voodoo if global and/or per-user ARPA display mode flag set this way or that
     
    641641        undef, $args{id}, $hcheck);
    642642    if ($t[0] > 0) {
    643       $errstr = "One or more non-CNAME records already exist for ".($revrec eq 'y' ? $arpaname : $hcheck).
     643      $errstr = "One or more non-CNAME records already exist for ".($args{revrec} eq 'y' ? $arpaname : $hcheck).
    644644        ".  CNAME records cannot use the same name as other records.";
    645645      return;
     
    652652        undef, $args{id}, $hcheck);
    653653  if ($t[0] > 1) {
    654     $errstr = "There is already a CNAME present for ".($revrec eq 'y' ? $arpaname : $hcheck).
     654    $errstr = "There is already a CNAME present for ".($args{revrec} eq 'y' ? $arpaname : $hcheck).
    655655        ".  Only one CNAME may be present for a given name.";
    656656    return;
     
    739739    return ('FAIL',"A record must be a valid IPv4 address")
    740740        unless $args{addr} && !$args{addr}->{isv6};
     741
     742return ('FAIL', $errstr) unless $self->_cname_collision(%args);
     743
    741744    # coerce IP/value to normalized form for storage
    742745    ${$args{val}} = $args{addr}->addr;
Note: See TracChangeset for help on using the changeset viewer.