Changeset 775


Ignore:
Timestamp:
07/31/19 15:44:20 (5 years ago)
Author:
Kris Deugau
Message:

/trunk

Add serial numbers on AXFR import. For now we leave non-overwritten SOA
serial entries dangling for overwrite on the next update; this may need
manual intervention later. Most cases should overwrite the SOA for
system/platform consistency. See #24.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r774 r775  
    56565656    my $logparent;
    56575657
     5658    # Snarf the zone serial.  Doing it here lets us log the serial we ultimately
     5659    # import with, and cleanly override or not as per the options
     5660    my $res = Net::DNS::Resolver->new;
     5661    $res->nameservers($ifrom);
     5662    my ($origsoa) = rr($res, $zone, 'SOA');
     5663    my $ser = $origsoa->{serial};
     5664    if ($args{rwsoa}) {
     5665      if (!$args{keepserial}) {
     5666        $ser = scalar(time);
     5667      }
     5668    }
     5669
    56585670    if ($rev eq 'n') {
    5659 ##fixme:  serial
    5660       $dbh->do("INSERT INTO domains (domain,group_id,status) VALUES (?,?,?)", undef,
    5661         ($zone, $group, $args{status}) ) or die $dbh->errstr;
     5671      $dbh->do("INSERT INTO domains (domain,group_id,status,zserial) VALUES (?,?,?,?)", undef,
     5672        ($zone, $group, $args{status}, $ser) ) or die $dbh->errstr;
    56625673      # get domain id so we can do the records
    56635674      ($zone_id) = $dbh->selectrow_array("SELECT currval('domains_domain_id_seq')");
    56645675      $domain_id = $zone_id;
    56655676      $logparent = $self->_log(group_id => $group, domain_id => $domain_id,
    5666                 entry => "[Added ".($args{status} ? 'active' : 'inactive')." domain $zone via AXFR]");
     5677                entry => "[Added ".($args{status} ? 'active' : 'inactive')." domain $zone with serial $ser via AXFR]");
    56675678    } else {
    5668 ##fixme:  serial
    5669       $dbh->do("INSERT INTO revzones (revnet,group_id,status) VALUES (?,?,?)", undef,
    5670         ($cidr,$group,$args{status}) );
     5679      $dbh->do("INSERT INTO revzones (revnet,group_id,status,zserial) VALUES (?,?,?,?)", undef,
     5680        ($cidr,$group,$args{status}, $ser) );
    56715681      # get revzone id so we can do the records
    56725682      ($zone_id) = $dbh->selectrow_array("SELECT currval('revzones_rdns_id_seq')");
    56735683      $rdns_id = $zone_id;
    56745684      $logparent = $self->_log(group_id => $group, rdns_id => $rdns_id,
    5675                 entry => "[Added ".($args{status} ? 'active' : 'inactive')." reverse zone $cidr via AXFR]");
     5685                entry => "[Added ".($args{status} ? 'active' : 'inactive')." reverse zone $cidr with serial $ser via AXFR]");
    56765686    }
    56775687
     
    56815691## caused a commit instead of barfing
    56825692
    5683     my $res = Net::DNS::Resolver->new;
    5684     $res->nameservers($ifrom);
    56855693    $res->axfr_start($zone)
    56865694        or die "Couldn't begin AXFR\n";
Note: See TracChangeset for help on using the changeset viewer.