Ignore:
Timestamp:
12/11/13 16:01:18 (10 years ago)
Author:
Kris Deugau
Message:

/branches/stable

Merge reverse DNS work and object conversion from /trunk, part 5

Includes changes through r543 with a few more minor conflicts.

Location:
branches/stable
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/stable

  • branches/stable/tiny-import.pl

    r547 r548  
    33##
    44# $Id$
    5 # Copyright 2012 Kris Deugau <kdeugau@deepnet.cx>
     5# Copyright 2012,2013 Kris Deugau <kdeugau@deepnet.cx>
    66#
    77#    This program is free software: you can redistribute it and/or modify
     
    2525use strict;
    2626use warnings;
    27 
    28 use lib '.';
     27use POSIX;
     28use Time::TAI64 qw(:tai);
     29
     30use lib '.';    ##uselib##
    2931use DNSDB;
    3032
     
    3739        conv    => 0,
    3840        trial   => 0,
     41        legacy  => 0,
    3942        );
    4043# Handle some command-line arguments
    4144while ($ARGV[0] =~ /^-/) {
    4245  my $arg = shift @ARGV;
    43   usage() if $arg !~ /^-[rct]+$/;
     46  usage() if $arg !~ /^-[rclt]+$/;
    4447  # -r  rewrite imported files to comment imported records
    4548  # -c  coerce/downconvert A+PTR = records to PTR
     49  # -l  swallow A+PTR as-is
    4650  # -t  trial mode;  don't commit to DB or actually rewrite flatfile (disables -r)
    4751  $arg =~ s/^-//;
     
    5054    $importcfg{rw} = 1 if $_ eq 'r';
    5155    $importcfg{conv} = 1 if $_ eq 'c';
     56    $importcfg{legacy} = 1 if $_ eq 'l';
    5257    $importcfg{trial} = 1 if $_ eq 't';
    5358  }
     
    6570            Multiple passes may be necessary if SOA and = records are heavily
    6671            intermixed and not clustered together.
     72        -l  (for "legacy")  Force import of A+PTR records as-is.  Mutually exclusive
     73            with -c.  -l takes precedence as -c is lossy.
    6774        -t  Trial run mode;  spits out records that would be left unimported.
    6875            Disables -r if set.
     
    120127  }
    121128
    122   our $recsth = $dbh->prepare("INSERT INTO records (domain_id,rdns_id,host,type,val,distance,weight,port,ttl,location) ".
    123         " VALUES (?,?,?,?,?,?,?,?,?,?)");
     129  our $recsth = $dbh->prepare("INSERT INTO records (domain_id,rdns_id,host,type,val,distance,weight,port,ttl,location,stamp,expires,stampactive) ".
     130        " VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)");
    124131
    125132  my %deleg;
     
    243250  }
    244251
     252  sub calcstamp {
     253    my $stampin = shift;
     254    my $ttl = shift;
     255    my $pzone = shift;
     256    my $revrec = shift;
     257
     258    return ($ttl, 'n', 'n', '1970-01-01 00:00:00 -0') if !$stampin;
     259
     260##fixme  Yes, this fails for records in 2038 sometime.  No, I'm not going to care for a while.
     261    $stampin = "\@$stampin";    # Time::TAI64 needs the leading @.  Feh.
     262    my $u = tai2unix($stampin);
     263    $stampin = strftime("%Y-%m-%d %H:%M:%S %z", localtime($u));
     264    my $expires = 'n';
     265    if ($ttl) {
     266      # TTL can stay put.
     267    } else {
     268      # TTL on import is 0, almost certainly wrong.  Get the parent zone's SOA and use the minttl.
     269      my $soa = $dnsdb->getSOA('n', $revrec, $pzone);
     270      $ttl = $soa->{minttl};
     271      $expires = 'y';
     272    }
     273    return ($ttl, 'y', $expires, $stampin);
     274  }
    245275
    246276  sub recslurp {
     
    263293      $host =~ s/^=//;
    264294      $host =~ s/\.$//;
    265       $ttl = 0 if !$ttl;
     295      $ttl = -1 if $ttl eq '';
    266296      $stamp = '' if !$stamp;
    267297      $loc = '' if !$loc;
     
    269299      my $fparent = $dnsdb->_hostparent($host);
    270300      my ($rparent) = $dbh->selectrow_array("SELECT rdns_id FROM revzones WHERE revnet >> ?", undef, ($ip));
     301
     302      my $stampactive = 'n';
     303      my $expires = 'n';
     304
     305      # can't set a timestamp on an orphaned record.  we'll actually fail import of this record a little later.
     306      if ($fparent || $rparent) {
     307        if ($fparent) {
     308          ($ttl, $stampactive, $expires, $stamp) = calcstamp($stamp, $ttl, $fparent, 'n');
     309        } else {
     310          ($ttl, $stampactive, $expires, $stamp) = calcstamp($stamp, $ttl, $rparent, 'y');
     311        }
     312      }
     313
    271314      if ($fparent && $rparent) {
    272         $recsth->execute($fparent, $rparent, $host, 65280, $ip, 0, 0, 0, $ttl, $loc);
    273       } else {
    274         if ($importcfg{conv}) {
     315        $recsth->execute($fparent, $rparent, $host, 65280, $ip, 0, 0, 0, $ttl, $loc, $stamp, $expires, $stampactive);
     316      } else {
     317        if ($importcfg{legacy}) {
     318          # Just import it already!  Record may still be subject to downconversion on editing.
     319          $fparent = 0 if !$fparent;
     320          $rparent = 0 if !$rparent;
     321          if ($fparent || $rparent) {
     322            $recsth->execute($fparent, $rparent, $host, 65280, $ip, 0, 0, 0, $ttl, $loc, $stamp, $expires, $stampactive);
     323          } else {
     324            # No parents found, cowardly refusing to add a dangling record
     325            push @deferred, $rec unless $nodefer;
     326            $impok = 0;
     327          }
     328        } elsif ($importcfg{conv}) {
    275329          # downconvert A+PTR if forward zone is not found
    276           $recsth->execute(0, $rparent, $host, 12, $ip, 0, 0, 0, $ttl, $loc);
     330          $recsth->execute(0, $rparent, $host, 12, $ip, 0, 0, 0, $ttl, $loc, $stamp, $expires, $stampactive);
    277331          $converted++;
    278332        } else {
     
    290344      $host =~ s/\.$//;
    291345      $host =~ s/^\\052/*/;
    292       $ttl = 0 if !$ttl;
    293       $stamp = '' if !$stamp;
    294       $loc = '' if !$loc;
    295       $loc = '' if $loc =~ /^:+$/;
     346      $ttl = -1 if $ttl eq '';
     347      $stamp = '' if !$stamp;
     348      $loc = '' if !$loc;
     349      $loc = '' if $loc =~ /^:+$/;
     350
     351      my $stampactive = 'n';
     352      my $expires = 'n';
     353
    296354      if ($host =~ /\.arpa$/) {
    297355        ($code,$msg) = DNSDB::_zone2cidr($host);
    298356        my ($rparent) = $dbh->selectrow_array("SELECT rdns_id FROM revzones WHERE revnet >> ?", undef, ($msg));
    299         $recsth->execute(0, $rparent, $targ, 5, $msg->addr, 0, 0, 0, $ttl, $loc);
     357        if ($rparent) {
     358          ($ttl, $stampactive, $expires, $stamp) = calcstamp($stamp, $ttl, $rparent, 'y');
     359          $recsth->execute(0, $rparent, $targ, 5, $msg->addr, 0, 0, 0, $ttl, $loc, $stamp, $expires, $stampactive);
     360        } else {
     361          push @deferred, $rec unless $nodefer;
     362          $impok = 0;
     363          #  print "$tmporig deferred;  can't find parent zone\n";
     364        }
    300365
    301366##fixme:  automagically convert manually maintained sub-/24 delegations
     
    308373        my $fparent = $dnsdb->_hostparent($host);
    309374        if ($fparent) {
    310           $recsth->execute($fparent, 0, $host, 5, $targ, 0, 0, 0, $ttl, $loc);
     375          ($ttl, $stampactive, $expires, $stamp) = calcstamp($stamp, $ttl, $fparent, 'n');
     376          $recsth->execute($fparent, 0, $host, 5, $targ, 0, 0, 0, $ttl, $loc, $stamp, $expires, $stampactive);
    311377        } else {
    312378          push @deferred, $rec unless $nodefer;
     
    324390      $ns =~ s/\.$//;
    325391      $ns = "$ns.ns.$zone" if $ns !~ /\./;
    326       $ttl = 0 if !$ttl;
    327       $stamp = '' if !$stamp;
    328       $loc = '' if !$loc;
    329       $loc = '' if $loc =~ /^:+$/;
     392      $ttl = -1 if $ttl eq '';
     393      $stamp = '' if !$stamp;
     394      $loc = '' if !$loc;
     395      $loc = '' if $loc =~ /^:+$/;
     396
     397      my $stampactive = 'n';
     398      my $expires = 'n';
     399
    330400      if ($zone =~ /\.arpa$/) {
    331401        ($code,$msg) = DNSDB::_zone2cidr($zone);
     
    336406#       if !$rparent;
    337407        if ($rparent) {
    338           $recsth->execute(0, $rparent, $ns, 2, $msg, 0, 0, 0, $ttl, $loc);
     408          ($ttl, $stampactive, $expires, $stamp) = calcstamp($stamp, $ttl, $rparent, 'y');
     409          $recsth->execute(0, $rparent, $ns, 2, $msg, 0, 0, 0, $ttl, $loc, $stamp, $expires, $stampactive);
    339410        } else {
    340411          push @deferred, $rec unless $nodefer;
     
    344415        my $fparent = $dnsdb->_hostparent($zone);
    345416        if ($fparent) {
    346           $recsth->execute($fparent, 0, $zone, 2, $ns, 0, 0, 0, $ttl, $loc);
    347           $recsth->execute($fparent, 0, $ns, 2, $ip, 0, 0, 0, $ttl, $loc) if $ip;
     417          ($ttl, $stampactive, $expires, $stamp) = calcstamp($stamp, $ttl, $fparent, 'n');
     418          $recsth->execute($fparent, 0, $zone, 2, $ns, 0, 0, 0, $ttl, $loc, $stamp, $expires, $stampactive);
     419          $recsth->execute($fparent, 0, $ns, 2, $ip, 0, 0, 0, $ttl, $loc, $stamp, $expires, $stampactive) if $ip;
    348420        } else {
    349421          push @deferred, $rec unless $nodefer;
     
    358430      $rip =~ s/^\^//;
    359431      $rip =~ s/\.$//;
    360       $ttl = 0 if !$ttl;
    361       $stamp = '' if !$stamp;
    362       $loc = '' if !$loc;
    363       $loc = '' if $loc =~ /^:+$/;
     432      $ttl = -1 if $ttl eq '';
     433      $stamp = '' if !$stamp;
     434      $loc = '' if !$loc;
     435      $loc = '' if $loc =~ /^:+$/;
     436
     437      my $stampactive = 'n';
     438      my $expires = 'n';
     439
    364440      my $rparent;
    365441      if (my ($i, $z) = ($rip =~ /^(\d+)\.(\d+-(?:\d+\.){4}in-addr.arpa)$/) ) {
     
    376452      }
    377453      if ($rparent) {
    378         $recsth->execute(0, $rparent, $host, 12, $msg->addr, 0, 0, 0, $ttl, $loc);
     454        ($ttl, $stampactive, $expires, $stamp) = calcstamp($stamp, $ttl, $rparent, 'y');
     455        $recsth->execute(0, $rparent, $host, 12, $msg->addr, 0, 0, 0, $ttl, $loc, $stamp, $expires, $stampactive);
    379456      } else {
    380457        push @deferred, $rec unless $nodefer;
     
    389466      $host =~ s/\.$//;
    390467      $host =~ s/^\\052/*/;
    391       $ttl = 0 if !$ttl;
    392       $stamp = '' if !$stamp;
    393       $loc = '' if !$loc;
    394       $loc = '' if $loc =~ /^:+$/;
     468      $ttl = -1 if $ttl eq '';
     469      $stamp = '' if !$stamp;
     470      $loc = '' if !$loc;
     471      $loc = '' if $loc =~ /^:+$/;
     472
     473      my $stampactive = 'n';
     474      my $expires = 'n';
    395475
    396476      my $domid = $dnsdb->_hostparent($host);
    397477      if ($domid) {
    398         $recsth->execute($domid, 0, $host, 1, $ip, 0, 0, 0, $ttl, $loc);
     478        ($ttl, $stampactive, $expires, $stamp) = calcstamp($stamp, $ttl, $domid, 'n');
     479        $recsth->execute($domid, 0, $host, 1, $ip, 0, 0, 0, $ttl, $loc, $stamp, $expires, $stampactive);
    399480      } else {
    400481        push @deferred, $rec unless $nodefer;
     
    410491      $master =~ s/\.$//;
    411492      $contact =~ s/\.$//;
    412       $ttl = 0 if !$ttl;
    413       $stamp = '' if !$stamp;
    414       $loc = '' if !$loc;
    415       $loc = '' if $loc =~ /^:+$/;
     493      $ttl = -1 if $ttl eq '';
     494      $stamp = '' if !$stamp;
     495      $loc = '' if !$loc;
     496      $loc = '' if $loc =~ /^:+$/;
     497
     498      my $stampactive = 'n';
     499      my $expires = 'n';
     500
     501##fixme er... what do we do with an SOA with a timestamp?  O_o
     502# fail for now, since there's no clean way I can see to handle this (yet)
     503# maybe (ab)use the -l flag to import as-is?
     504      if ($stamp) {
     505        push @deferred, $rec unless $nodefer;
     506        return 0;
     507      }
     508
     509##fixme: need more magic on TTL, so we can decide whether to use the minttl or newttl
     510#      my $newttl;
     511#      ($newttl, $stampactive, $expires, $stamp) = calcstamp($stamp, $minttl, 0, 'n');
     512#      $ttl = $newttl if !$ttl;
     513
    416514      if ($zone =~ /\.arpa$/) {
    417515        ($code,$msg) = DNSDB::_zone2cidr($zone);
     
    419517                undef, ($msg, $loc));
    420518        my ($rdns) = $dbh->selectrow_array("SELECT currval('revzones_rdns_id_seq')");
    421         $recsth->execute(0, $rdns, "$contact:$master", 6, "$refresh:$retry:$expire:$minttl", 0, 0, 0, $ttl, $loc);
     519        my $newttl;
     520        ($newttl, $stampactive, $expires, $stamp) = calcstamp($stamp, $minttl, 0, 'y');
     521        $ttl = $newttl if !$ttl;
     522        $recsth->execute(0, $rdns, "$contact:$master", 6, "$refresh:$retry:$expire:$minttl", 0, 0, 0, $ttl,
     523                $loc, $stamp, $expires, $stampactive);
    422524      } else {
    423525        $dbh->do("INSERT INTO domains (domain,group_id,status,default_location) VALUES (?,1,1,?)",
    424526                undef, ($zone, $loc));
    425527        my ($domid) = $dbh->selectrow_array("SELECT currval('domains_domain_id_seq')");
    426         $recsth->execute($domid, 0, "$contact:$master", 6, "$refresh:$retry:$expire:$minttl", 0, 0, 0, $ttl, $loc);
     528        my $newttl;
     529        ($newttl, $stampactive, $expires, $stamp) = calcstamp($stamp, $minttl, 0, 'n');
     530        $ttl = $newttl if !$ttl;
     531        $recsth->execute($domid, 0, "$contact:$master", 6, "$refresh:$retry:$expire:$minttl", 0, 0, 0, $ttl,
     532                $loc, $stamp, $expires, $stampactive);
    427533      }
    428534
     
    436542      $host =~ s/\.$//;
    437543      $host = "$host.mx.$zone" if $host !~ /\./;
    438       $ttl = 0 if !$ttl;
    439       $stamp = '' if !$stamp;
    440       $loc = '' if !$loc;
    441       $loc = '' if $loc =~ /^:+$/;
     544      $ttl = -1 if $ttl eq '';
     545      $stamp = '' if !$stamp;
     546      $loc = '' if !$loc;
     547      $loc = '' if $loc =~ /^:+$/;
     548
     549      my $stampactive = 'n';
     550      my $expires = 'n';
    442551
    443552# note we don't check for reverse domains here, because MX records don't make any sense in reverse zones.
     
    447556      my $domid = $dnsdb->_hostparent($zone);
    448557      if ($domid) {
    449         $recsth->execute($domid, 0, $zone, 15, $host, $dist, 0, 0, $ttl, $loc);
    450         $recsth->execute($domid, 0, $host, 1, $ip, 0, 0, 0, $ttl, $loc) if $ip;
     558        ($ttl, $stampactive, $expires, $stamp) = calcstamp($stamp, $ttl, $domid, 'n');
     559        $recsth->execute($domid, 0, $zone, 15, $host, $dist, 0, 0, $ttl, $loc, $stamp, $expires, $stampactive);
     560        $recsth->execute($domid, 0, $host, 1, $ip, 0, 0, 0, $ttl, $loc, $stamp, $expires, $stampactive) if $ip;
    451561      } else {
    452562        push @deferred, $rec unless $nodefer;
     
    461571      $fqdn =~ s/^\\052/*/;
    462572      _deoctal(\$rdata);
    463       $ttl = 0 if !$ttl;
    464       $stamp = '' if !$stamp;
    465       $loc = '' if !$loc;
    466       $loc = '' if $loc =~ /^:+$/;
     573      $ttl = -1 if $ttl eq '';
     574      $stamp = '' if !$stamp;
     575      $loc = '' if !$loc;
     576      $loc = '' if $loc =~ /^:+$/;
     577
     578      my $stampactive = 'n';
     579      my $expires = 'n';
    467580
    468581      if ($fqdn =~ /\.arpa$/) {
    469582        ($code,$msg) = DNSDB::_zone2cidr($fqdn);
    470583        my ($rparent) = $dbh->selectrow_array("SELECT rdns_id FROM revzones WHERE revnet >> ?", undef, ($msg));
    471         $recsth->execute(0, $rparent, $rdata, 16, "$msg", 0, 0, 0, $ttl, $loc);
     584        ($ttl, $stampactive, $expires, $stamp) = calcstamp($stamp, $ttl, $rparent, 'y');
     585        $recsth->execute(0, $rparent, $rdata, 16, "$msg", 0, 0, 0, $ttl, $loc, $stamp, $expires, $stampactive);
    472586      } else {
    473587        my $domid = $dnsdb->_hostparent($fqdn);
    474588        if ($domid) {
    475           $recsth->execute($domid, 0, $fqdn, 16, $rdata, 0, 0, 0, $ttl, $loc);
     589          ($ttl, $stampactive, $expires, $stamp) = calcstamp($stamp, $ttl, $domid, 'n');
     590          $recsth->execute($domid, 0, $fqdn, 16, $rdata, 0, 0, 0, $ttl, $loc, $stamp, $expires, $stampactive);
    476591        } else {
    477592          push @deferred, $rec unless $nodefer;
     
    488603      $ns =~ s/\.$//;
    489604      $ns = "$ns.ns.$fqdn" if $ns !~ /\./;
    490       $ttl = 0 if !$ttl;
    491       $stamp = '' if !$stamp;
    492       $loc = '' if !$loc;
    493       $loc = '' if $loc =~ /^:+$/;
     605      $ttl = -1 if $ttl eq '';
     606      $stamp = '' if !$stamp;
     607      $loc = '' if !$loc;
     608      $loc = '' if $loc =~ /^:+$/;
     609
     610      my $stampactive = 'n';
     611      my $expires = 'n';
     612
     613##fixme er... what do we do with an SOA with a timestamp?  O_o
     614# fail for now, since there's no clean way I can see to handle this (yet)
     615# maybe (ab)use the -l flag to import as-is?
     616      if ($stamp) {
     617        push @deferred, $rec unless $nodefer;
     618        return 0;
     619      }
     620
     621##fixme: need more magic on TTL, so we can decide whether to use the minttl or newttl
     622#      my $newttl;
     623#      ($newttl, $stampactive, $expires, $stamp) = calcstamp($stamp, $minttl, 0, 'n');
    494624
    495625      if ($fqdn =~ /\.arpa$/) {
     
    501631                undef, ($msg, $loc));
    502632          ($rdns) = $dbh->selectrow_array("SELECT currval('revzones_rdns_id_seq')");
     633          ($ttl, $stampactive, $expires, $stamp) = calcstamp($stamp, 2560, 0, 'y');
    503634# this would probably make a lot more sense to do hostmaster.$config{admindomain}
    504           $recsth->execute(0, $rdns, "hostmaster.$fqdn:$ns", 6, "16384:2048:1048576:2560", 0, 0, 0, "2560", $loc);
    505         }
    506         $recsth->execute(0, $rdns, $ns, 2, "$msg", 0, 0, 0, $ttl, $loc);
     635# otherwise, it's as per the tinydns defaults that work tolerably well on a small scale
     636# serial -> modtime of data file, ref -> 16384, ret -> 2048, exp -> 1048576, min -> 2560
     637          $recsth->execute(0, $rdns, "hostmaster.$fqdn:$ns", 6, "16384:2048:1048576:2560", 0, 0, 0, "2560",
     638                $loc, $stamp, $expires, $stampactive);
     639        }
     640        ($ttl, $stampactive, $expires, $stamp) = calcstamp($stamp, 2560, $rdns, 'y') if !$stamp;
     641        $recsth->execute(0, $rdns, $ns, 2, "$msg", 0, 0, 0, $ttl, $loc, $stamp, $expires, $stampactive);
    507642##fixme:  (?)  implement full conversion of tinydns . records?
    508643# -> problem:  A record for NS must be added to the appropriate *forward* zone, not the reverse
    509 #$recsth->execute(0, $rdns, $ns, 1, $ip, 0, 0, 0, $ttl)
     644#$recsth->execute(0, $rdns, $ns, 1, $ip, 0, 0, 0, $ttl, $stamp, $expires, $stampactive)
    510645# ...  auto-A-record simply does not make sense in reverse zones.  Functionally
    511646# I think it would work, sort of, but it's a nasty mess and anyone hosting reverse
     
    521656                undef, ($fqdn, $loc));
    522657          ($domid) = $dbh->selectrow_array("SELECT currval('domains_domain_id_seq')");
    523           $recsth->execute($domid, 0, "hostmaster.$fqdn:$ns", 6, "16384:2048:1048576:2560", 0, 0, 0, "2560", $loc);
    524         }
    525         $recsth->execute($domid, 0, $fqdn, 2, $ns, 0, 0, 0, $ttl, $loc);
    526         $recsth->execute($domid, 0, $ns, 1, $ip, 0, 0, 0, $ttl, $loc) if $ip;
     658          ($ttl, $stampactive, $expires, $stamp) = calcstamp($stamp, 2560, 0, 'n');
     659          $recsth->execute($domid, 0, "hostmaster.$fqdn:$ns", 6, "16384:2048:1048576:2560", 0, 0, 0, "2560",
     660                $loc, $stamp, $expires, $stampactive);
     661        }
     662        ($ttl, $stampactive, $expires, $stamp) = calcstamp($stamp, $ttl, $domid, 'n') if !$stamp;
     663        $recsth->execute($domid, 0, $fqdn, 2, $ns, 0, 0, 0, $ttl, $loc, $stamp, $expires, $stampactive);
     664        $recsth->execute($domid, 0, $ns, 1, $ip, 0, 0, 0, $ttl, $loc, $stamp, $expires, $stampactive) if $ip;
    527665      }
    528666
     
    556694      $fqdn =~ s/\.$//;
    557695      $fqdn =~ s/^\\052/*/;
    558       $ttl = 0 if !$ttl;
    559       $stamp = '' if !$stamp;
    560       $loc = '' if !$loc;
    561       $loc = '' if $loc =~ /^:+$/;
     696      $ttl = -1 if $ttl eq '';
     697      $stamp = '' if !$stamp;
     698      $loc = '' if !$loc;
     699      $loc = '' if $loc =~ /^:+$/;
     700
     701      my $stampactive = 'n';
     702      my $expires = 'n';
    562703
    563704      if ($type == 33) {
     
    588729        my $domid = $dnsdb->_hostparent($fqdn);
    589730        if ($domid) {
    590           $recsth->execute($domid, 0, $fqdn, 33, $target, $prio, $weight, $port, $ttl, $loc) if $domid;
     731          ($ttl, $stampactive, $expires, $stamp) = calcstamp($stamp, $ttl, $domid, 'n');
     732          $recsth->execute($domid, 0, $fqdn, 33, $target, $prio, $weight, $port, $ttl, $loc, $stamp, $expires, $stampactive) if $domid;
    591733        } else {
    592734          push @deferred, $rec unless $nodefer;
     
    605747
    606748        my $fparent = $dnsdb->_hostparent($fqdn);
     749
    607750        if ($fparent) {
    608           $recsth->execute($fparent, 0, $fqdn, 28, $val->addr, 0, 0, 0, $ttl, $loc);
     751          ($ttl, $stampactive, $expires, $stamp) = calcstamp($stamp, $ttl, $fparent, 'n');
     752          $recsth->execute($fparent, 0, $fqdn, 28, $val->addr, 0, 0, 0, $ttl, $loc, $stamp, $expires, $stampactive);
    609753        } else {
    610754          push @deferred, $rec unless $nodefer;
     
    620764          my ($rparent) = $dbh->selectrow_array("SELECT rdns_id FROM revzones WHERE revnet >> ?", undef, ($msg));
    621765          if ($rparent) {
    622             $recsth->execute(0, $rparent, $txtstring, 16, "$msg", 0, 0, 0, $ttl, $loc);
     766            ($ttl, $stampactive, $expires, $stamp) = calcstamp($stamp, $ttl, $rparent, 'y');
     767            $recsth->execute(0, $rparent, $txtstring, 16, "$msg", 0, 0, 0, $ttl, $loc, $stamp, $expires, $stampactive);
    623768          } else {
    624769            push @deferred, $rec unless $nodefer;
     
    628773          my $domid = $dnsdb->_hostparent($fqdn);
    629774          if ($domid) {
    630             $recsth->execute($domid, 0, $fqdn, 16, $txtstring, 0, 0, 0, $ttl, $loc);
     775            ($ttl, $stampactive, $expires, $stamp) = calcstamp($stamp, $ttl, $domid, 'n');
     776            $recsth->execute($domid, 0, $fqdn, 16, $txtstring, 0, 0, 0, $ttl, $loc, $stamp, $expires, $stampactive);
    631777          } else {
    632778            push @deferred, $rec unless $nodefer;
     
    648794          my ($rparent) = $dbh->selectrow_array("SELECT rdns_id FROM revzones WHERE revnet >> ?", undef, ($msg));
    649795          if ($rparent) {
    650             $recsth->execute(0, $rparent, "$email $txtrec", 17, "$msg", 0, 0, 0, $ttl, $loc);
     796            ($ttl, $stampactive, $expires, $stamp) = calcstamp($stamp, $ttl, $rparent, 'y');
     797            $recsth->execute(0, $rparent, "$email $txtrec", 17, "$msg", 0, 0, 0, $ttl, $loc, $stamp, $expires, $stampactive );
    651798          } else {
    652799            push @deferred, $rec unless $nodefer;
     
    656803          my $domid = $dnsdb->_hostparent($fqdn);
    657804          if ($domid) {
    658             $recsth->execute($domid, 0, $fqdn, 17, "$email $txtrec", 0, 0, 0, $ttl, $loc);
     805            ($ttl, $stampactive, $expires, $stamp) = calcstamp($stamp, $ttl, $domid, 'n');
     806            $recsth->execute($domid, 0, $fqdn, 17, "$email $txtrec", 0, 0, 0, $ttl, $loc, $stamp, $expires, $stampactive);
    659807          } else {
    660808            push @deferred, $rec unless $nodefer;
     
    672820        my $domid = $dnsdb->_hostparent($fqdn);
    673821        if ($domid) {
    674           $recsth->execute($domid, 0, $fqdn, 44, $sshfp, 0, 0, 0, $ttl, $loc);
     822          ($ttl, $stampactive, $expires, $stamp) = calcstamp($stamp, $ttl, $domid, 'n');
     823          $recsth->execute($domid, 0, $fqdn, 44, $sshfp, 0, 0, 0, $ttl, $loc, $stamp, $expires, $stampactive);
    675824        } else {
    676825          push @deferred, $rec unless $nodefer;
Note: See TracChangeset for help on using the changeset viewer.