Changeset 454 for trunk


Ignore:
Timestamp:
01/16/13 16:43:19 (12 years ago)
Author:
Kris Deugau
Message:

/trunk

Tweak addOrUpdateRec for some subtle bugs. See #43.

  • handle static IP CIDRs correctly (strip the mask length)
  • make sure to check all template, composite, and bare PTR records
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dns-rpc.cgi

    r453 r454  
    443443    my $zone = new NetAddr::IP $zonelist->[0]->{revnet};
    444444    if ($zone->contains($args{cidr})) {
     445      # We need to strip the CIDR mask on IPv4 /32 assignments, or we just add a new record all the time.
     446      my $filt = ($args{cidr}->{isv6} || $args{cidr}->masklen != 32 ? "$args{cidr}" : $args{cidr}->addr);
    445447      my $reclist = DNSDB::getDomRecs($dbh, defrec => 'n', revrec => 'y',
    446         id => $zonelist->[0]->{rdns_id}, filter => "$args{cidr}");
     448        id => $zonelist->[0]->{rdns_id}, filter => $filt);
    447449      if (scalar(@$reclist) == 0) {
    448450        # Aren't Magic Numbers Fun?  See pseudotype list in dnsadmin.
     
    452454      } else {
    453455        foreach my $rec (@$reclist) {
    454           next unless $rec->{type} == 65282 || $rec->{type} == 65283 || $rec->{type} == 65284;
     456          # pure PTR plus composite types
     457          next unless $rec->{type} == 12 || $rec->{type} == 65280 || $rec->{type} == 65281
     458                || $rec->{type} == 65282 || $rec->{type} == 65283 || $rec->{type} == 65284;
     459          next unless $rec->{val} eq $filt;     # make sure we really update the record we want to update.
    455460          updateRec(defrec =>'n', revrec => 'y', id => $rec->{record_id},
    456461            parent_id => $zonelist->[0]->{rdns_id}, %args);
     
    473478      } else {
    474479        foreach my $rec (@$reclist) {
     480          # only the composite and/or template types;  pure PTR or nontemplate composite
     481          # types are nominally impossible here.
    475482          next unless $rec->{type} == 65282 || $rec->{type} == 65283 || $rec->{type} == 65284;
    476483          updateRec(defrec =>'n', revrec => 'y', id => $rec->{record_id},
Note: See TracChangeset for help on using the changeset viewer.