Changeset 573


Ignore:
Timestamp:
12/31/13 15:14:55 (11 years ago)
Author:
Kris Deugau
Message:

/trunk

Squash the missing-SOA-on-AXFR bug; SOA and NS records would not be
copied correctly when the "Rewrite SOA" or "Rewrite NS" options were
checked.

Pass the record ID into _printrec_tiny(), mainly as a debugging aid.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r572 r573  
    47014701      } elsif ($type eq 'NS') {
    47024702# hmm.  should we warn here if subdomain NS'es are left alone?
    4703         next if ($args{rwns} && ($rr->name eq $zone));
    47044703        if ($rev eq 'y') {
    47054704          # revzones have records more or less reversed from forward zones.
    47064705          my ($tmpcode,$tmpmsg) = _zone2cidr($host);
    47074706          die "Error converting NS record: $tmpmsg\n" if $tmpcode eq 'FAIL';    # hmm.  may not make sense...
     4707          next if ($args{rwns} && ($tmpmsg eq "$cidr"));
    47084708          $val = "$tmpmsg";
    47094709          $host = $rr->nsdname;
     
    47154715#}
    47164716        } else {
     4717          next if ($args{rwns} && ($rr->name eq $zone));
    47174718          $val = $rr->nsdname;
    47184719        }
     
    48684869    if ($args{rwsoa}) {
    48694870      $soaflag = 1;
    4870       my $sthgetsoa = $dbh->prepare("SELECT host,val,ttl FROM default_records WHERE group_id=? AND type=?");
    4871       my $sthputsoa = $dbh->prepare("INSERT INTO records (domain_id,host,type,val,ttl) VALUES (?,?,?,?,?)");
     4871      my $sthgetsoa = $dbh->prepare("SELECT host,val,ttl FROM "._rectable('y', $rev)." WHERE group_id=? AND type=?");
     4872      my $sthputsoa = $dbh->prepare("INSERT INTO records (".
     4873        ($rev eq 'n' ? 'domain_id' : 'rdns_id').",host,type,val,ttl) VALUES (?,?,?,?,?)");
    48724874      $sthgetsoa->execute($group,$reverse_typemap{SOA});
    48734875      while (my ($host,$val,$ttl) = $sthgetsoa->fetchrow_array()) {
    4874         $host =~ s/DOMAIN/$zone/g;
    4875         $val =~ s/DOMAIN/$zone/g;
     4876        if ($rev eq 'n') {
     4877          $host =~ s/DOMAIN/$zone/g;
     4878          $val =~ s/DOMAIN/$zone/g;     # arguably useless
     4879        } else {
     4880          $host =~ s/ADMINDOMAIN/$self->{domain}/g;
     4881        }
    48764882        $sthputsoa->execute($zone_id,$host,$reverse_typemap{SOA},$val,$ttl);
    48774883      }
    48784884    }
    48794885
    4880     # Overwrite NS records
     4886    # Add standard NS records.  The old one(s) should have been skipped by this point.
    48814887    if ($args{rwns}) {
    48824888      $nsflag = 1;
    4883       my $sthgetns = $dbh->prepare("SELECT host,val,ttl FROM default_records WHERE group_id=? AND type=?");
    4884       my $sthputns = $dbh->prepare("INSERT INTO records (domain_id,host,type,val,ttl) VALUES (?,?,?,?,?)");
     4889      my $sthgetns = $dbh->prepare("SELECT host,val,ttl FROM "._rectable('y',$rev)." WHERE group_id=? AND type=?");
     4890      my $sthputns = $dbh->prepare("INSERT INTO records (".
     4891        ($rev eq 'n' ? 'domain_id' : 'rdns_id').",host,type,val,ttl) VALUES (?,?,?,?,?)");
    48854892      $sthgetns->execute($group,$reverse_typemap{NS});
    48864893      while (my ($host,$val,$ttl) = $sthgetns->fetchrow_array()) {
    4887         $host =~ s/DOMAIN/$zone/g;
    4888         $val =~ s/DOMAIN/$zone/g;
     4894        if ($rev eq 'n') {
     4895          $host =~ s/DOMAIN/$zone/g;
     4896          $val =~ s/DOMAIN/$zone/g;     #hmm.
     4897        } else {
     4898          $host =~ s/ADMINDOMAIN/$self->{domain}/g;     #hmm.
     4899          $val =~ s/ZONE/$cidr/g;
     4900        }
    48894901        $sthputns->execute($zone_id,$host,$reverse_typemap{NS},$val,$ttl);
    48904902      }
     
    50785090        $soasth->execute($revid);
    50795091        my (@zsoa) = $soasth->fetchrow_array();
    5080         _printrec_tiny($zonefilehandle,'y',\%recflags,$revzone,
     5092        _printrec_tiny($zonefilehandle, $zsoa[7], 'y',\%recflags,$revzone,
    50815093          $zsoa[0],$zsoa[1],$zsoa[2],$zsoa[3],$zsoa[4],$zsoa[5],$zsoa[6],$zsoa[8],'');
    50825094
    50835095        $recsth->execute($revid);
    5084         while (my ($host,$type,$val,$dist,$weight,$port,$ttl,$recid,$loc,$stamp,$expires,$stampactive) = $recsth->fetchrow_array) {
     5096        while (my ($host, $type, $val, $dist, $weight, $port, $ttl, $recid, $loc, $stamp, $expires, $stampactive)
     5097                = $recsth->fetchrow_array) {
    50855098          next if $recflags{$recid};
    50865099
     
    50955108#         }
    50965109
    5097           _printrec_tiny($zonefilehandle, 'y', \%recflags, $revzone,
     5110          _printrec_tiny($zonefilehandle, $recid, 'y', \%recflags, $revzone,
    50985111            $host, $type, $val, $dist, $weight, $port, $ttl, $loc, $stamp, $expires, $stampactive);
    50995112
     
    51795192          }
    51805193
    5181           _printrec_tiny($zonefilehandle, 'n', \%recflags,
     5194          _printrec_tiny($zonefilehandle, $recid, 'n', \%recflags,
    51825195                $dom, $host, $type, $val, $dist, $weight, $port, $ttl, $loc, $stamp, $expires, $stampactive);
    51835196
     
    52285241# Utility sub for __export_tiny above
    52295242sub _printrec_tiny {
    5230   my ($datafile,$revrec,$recflags,$zone,$host,$type,$val,$dist,$weight,$port,$ttl,$loc,$stamp,$expires,$stampactive) = @_;
     5243  my ($datafile, $recid, $revrec, $recflags, $zone, $host, $type, $val, $dist, $weight, $port, $ttl,
     5244        $loc, $stamp, $expires, $stampactive) = @_;
    52315245
    52325246  $loc = '' if !$loc;   # de-nullify - just in case
Note: See TracChangeset for help on using the changeset viewer.