Ignore:
Timestamp:
01/14/26 13:06:45 (13 days ago)
Author:
Kris Deugau
Message:

/branches/cname-collision

Remove calls to _cname_collision() from individual validator subs in favour
of a followup call direct from addRec() and updateRec(), so that warnings
from the validators can be more cleanly (ie, less copy-pasty) merged from
potential warnings from the CNAME collision check (some timestamp cases will
use this).
See #72

File:
1 edited

Legend:

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

    r980 r981  
    655655    if ($t[0] > 0) {
    656656      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.";
     657        return ('FAIL', "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.");
    659659      } 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.";
     660        return ('FAIL', "There is already a CNAME present for ".($args{revrec} eq 'y' ? $arpaname : $hcheck).
     661                ".  Only one CNAME may be present for a given name.");
    662662      }
    663       return;
    664663    }
    665664  }
     
    673672#       if $t[0] > 1;
    674673#  }
    675   return 1;
     674  return ('OK', 'OK');
    676675
    677676} # _cname_collision()
     
    752751  }
    753752
    754   return ('FAIL', $errstr) unless $self->_cname_collision(%args);
    755 
    756753  return ('OK','OK');
    757754} # done A record
     
    806803    }   
    807804  }
    808 
    809   return ('FAIL', $errstr) unless $self->_cname_collision(%args);
    810805
    811806  return ('OK','OK');
     
    888883    } # $zname !~ .rpz
    889884  } # revzone eq 'n'
    890 
    891   return ('FAIL', $errstr) unless $self->_cname_collision(%args);
    892885
    893886  return ('OK','OK');
     
    10171010  }
    10181011
    1019   return ('FAIL', $errstr) unless $self->_cname_collision(%args);
    1020 
    10211012  return ('WARN',$warnflag) if $warnflag;
    10221013
     
    10741065
    10751066  }
    1076 
    1077   return ('FAIL', $errstr) unless $self->_cname_collision(%args);
    10781067
    10791068  return ('OK','OK');
     
    11071096  }
    11081097
    1109   return ('FAIL', $errstr) unless $self->_cname_collision(%args);
    1110 
    11111098  # Could arguably put a WARN return here on very long (>512) records
    11121099  return ('OK','OK');
     
    11811168    ${$args{val}} = $args{addr}->addr;
    11821169  }
    1183 
    1184   return ('FAIL', $errstr) unless $self->_cname_collision(%args);
    11851170
    11861171  return ('OK','OK');
     
    12651250
    12661251  }
    1267 
    1268   return ('FAIL', $errstr) unless $self->_cname_collision(%args);
    12691252
    12701253  return ('OK','OK');
     
    13711354#  } else {
    13721355#  }
    1373 
    1374   return ('FAIL', $errstr) unless $self->_cname_collision(%args);
    13751356
    13761357  return ($code, $msg);
     
    16561637  }
    16571638
    1658   # poor practice creating template records could result in a live CNAME collision
    1659   return ('FAIL', $errstr) unless $self->_cname_collision(%args);
    1660 
    16611639  return ('OK','OK');
    16621640} # done A+PTR template record
     
    17071685  }
    17081686
    1709   return ('FAIL', $errstr) unless $self->_cname_collision(%args);
    1710 
    17111687  return ('OK','OK');
    17121688} # done delegation record
     
    17601736    push @{$args{vallist}}, $liveips;
    17611737  }
    1762 
    1763   return ('FAIL', $errstr) unless $self->_cname_collision(%args);
    17641738
    17651739  return ('WARN', join("\n", $errstr, $warnmsg) ) if $warnmsg;
     
    49174891  return ($retcode,$retmsg) if $retcode eq 'FAIL';
    49184892
     4893  # Check for CNAME collisions.
     4894##fixme:  should trim the list of arguments, not all of these should be required for CNAME collision checking
     4895  my ($ccode,$cmsg) = _cname_collision($self, defrec => $defrec, revrec => $revrec, id => $id,
     4896        host => $host, rectype => $rectype, val => $val, addr => $addr,
     4897        dist => \$dist, port => \$port, weight => \$weight,
     4898        stamp => \$stamp, expires => \$expires,
     4899        fields => \$fields, vallist => \@vallist);
     4900
     4901  return ($ccode,$cmsg) if $ccode eq 'FAIL';
     4902
     4903  # If both the validator and CNAME collision check return warnings, glue them together
     4904  if ($ccode eq 'WARN') {
     4905    if ($retcode eq 'WARN') {
     4906      $retmsg .= "<br>\n$cmsg";
     4907    } else {
     4908      $retmsg = $cmsg;
     4909    }
     4910    $retcode = 'WARN';
     4911  }
     4912
    49194913  # Set up database fields and bind parameters
    49204914  $fields .= "host,type,val,ttl,"._recparent($defrec,$revrec);
     
    50865080
    50875081  return ($retcode,$retmsg) if $retcode eq 'FAIL';
     5082
     5083  # Check for CNAME collisions.
     5084##fixme:  should trim the list of arguments, not all of these should be required for CNAME collision checking
     5085  my ($ccode,$cmsg) = _cname_collision($self, defrec => $defrec, revrec => $revrec,
     5086        id => ($defrec eq 'y' ? $oldrec->{group_id} : ($revrec eq 'n' ? $oldrec->{domain_id} : $oldrec->{rdns_id})),
     5087        host => $host, rectype => $rectype, val => $val, addr => $addr,
     5088        dist => \$dist, port => \$port, weight => \$weight,
     5089        stamp => \$stamp, expires => \$expires,
     5090        fields => \$fields, vallist => \@vallist,
     5091        update => $id);
     5092
     5093  return ($ccode,$cmsg) if $ccode eq 'FAIL';
     5094
     5095  # If both the validator and CNAME collision check return warnings, glue them together
     5096  if ($ccode eq 'WARN') {
     5097    if ($retcode eq 'WARN') {
     5098      $retmsg .= "<br>\n$cmsg";
     5099    } else {
     5100      $retmsg = $cmsg;
     5101    }
     5102    $retcode = 'WARN';
     5103  }
    50885104
    50895105  # Set up database fields and bind parameters.  Note only the optional fields
Note: See TracChangeset for help on using the changeset viewer.