Changeset 843


Ignore:
Timestamp:
04/29/22 15:45:16 (3 years ago)
Author:
Kris Deugau
Message:

/trunk

Minor accumulated refinements on tiny-import.pl

  • Update include path finder - see #80
  • Clean up extra trailing :'s that sometimes confused the location
  • Better handle "empty" TTL values
  • Slightly improve SOA serial type tagging; only handles the most common case of "let tinydns handle it" UNIX-epoch serials for now
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tiny-import.pl

    r797 r843  
    33##
    44# $Id$
    5 # Copyright 2012-2014,2020 Kris Deugau <kdeugau@deepnet.cx>
     5# Copyright 2012-2014,2020-2022 Kris Deugau <kdeugau@deepnet.cx>
    66#
    77#    This program is free software: you can redistribute it and/or modify
     
    2828use Time::TAI64 qw(:tai);
    2929
    30 # push "the directory the script is in" into @INC
    31 use FindBin;
    32 use lib "$FindBin::RealBin/";
     30# Taint-safe (ish) voodoo to push "the directory the script is in" into @INC.
     31use File::Spec ();
     32use File::Basename ();
     33my $path;
     34BEGIN {
     35    $path = File::Basename::dirname(File::Spec->rel2abs($0));
     36    if ($path =~ /(.*)/) {
     37        $path = $1;
     38    }
     39}
     40use lib $path;
    3341
    3442use DNSDB;
     
    200208    chomp;
    201209    s/\s*$//;
     210    s/:+$//;
    202211    my $recstat = recslurp($_, $filecnt);
    203212    $ok++ if $recstat;
     
    405414      $host =~ s/\.$//;
    406415      $host =~ s/^\\052/*/;
    407       $ttl = -1 if $ttl eq '';
     416      $ttl = -1 if !defined($ttl) || $ttl eq '';
    408417      $stamp = '' if !$stamp;
    409418      $loc = '' if !$loc;
     
    542551      $host =~ s/\.$//;
    543552      $host =~ s/^\\052/*/;
    544       $ttl = -1 if $ttl eq '';
     553      $ttl = -1 if !defined($ttl) || $ttl eq '';
    545554      $stamp = '' if !$stamp;
    546555      $loc = '' if !$loc;
     
    605614      if ($zone =~ /\.arpa$/) {
    606615        ($code,$msg) = DNSDB::_zone2cidr($zone);
    607         $dbh->do("INSERT INTO revzones (revnet,group_id,status,default_location,zserial) VALUES (?,?,1,?,?)",
     616        $dbh->do("INSERT INTO revzones (revnet,group_id,status,default_location,sertype,zserial) VALUES (?,?,1,?,'U',?)",
    608617                undef, ($msg, $importcfg{group}, $loc, $serial));
    609618        my ($rdns) = $dbh->selectrow_array("SELECT currval('revzones_rdns_id_seq')");
     
    614623                $loc, $stamp, $expires, $stampactive);
    615624      } else {
    616         $dbh->do("INSERT INTO domains (domain,group_id,status,default_location,zserial) VALUES (?,?,1,?,?)",
     625        $dbh->do("INSERT INTO domains (domain,group_id,status,default_location,sertype,zserial) VALUES (?,?,1,?,'U',?)",
    617626                undef, ($zone, $importcfg{group}, $loc, $serial));
    618627        my ($domid) = $dbh->selectrow_array("SELECT currval('domains_domain_id_seq')");
Note: See TracChangeset for help on using the changeset viewer.