Changeset 859


Ignore:
Timestamp:
09/15/22 18:02:12 (20 months ago)
Author:
Kris Deugau
Message:

/trunk

BIND export, unwinding dev saves, 11 of many many

  • Move $arpazone declaration up so other bits below the view file-opener block can use it
  • Write a docucomment header to the zone file once opened
  • Fix calling convention for passing zone file handles down to printrec_bind()
  • Make sure SOA primary NS and responsible contact values are dot-terminated
  • On SOA print-to-zonefile error, return an error message that actually means something
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB/ExportBIND.pm

    r858 r859  
    6565    eval {
    6666
     67      my $arpazone = DNSDB::_ZONE($cidr, 'ZONE', 'r', '.').($cidr->{isv6} ? '.ip6.arpa' : '.in-addr.arpa');
     68
    6769      # write fresh records if:
    6870      #  - we are not using the cache
     
    8284        push @loclist, $defloc unless grep /$defloc/, @loclist;
    8385        my $zonepath = $dnsdb->{bind_export_reverse_zone_path};
    84         my %zonefiles;  # to be a list of file handles.
     86        my %zonefiles;  # to be a hash of file handles.
    8587##fixme:  need to open separate zone files for aggregated metazones eg /22 or /14
    8688        foreach my $loc (@loclist) {
     
    8890          $zfilepath =~ s/\%view/$loc/;
    8991          $zfilepath =~ s/\%zone/$revzone/;
    90           my $arpazone = DNSDB::_ZONE($cidr, 'ZONE', 'r', '.').($cidr->{isv6} ? '.ip6.arpa' : '.in-addr.arpa');
    9192          $zfilepath =~ s/\%arpazone/$arpazone/;
    9293          # Just In Case(TM)
    9394          $zfilepath =~ s,[^\w./-],_,g;
    94           #open $zonefiles{$loc}, ">", $zfilepath;
     95          open $zonefiles{$loc}, ">", $zfilepath;
     96          print {$zonefiles{$loc}} "; $arpazone in view $loc\n";
    9597print "open zonefile for '$loc', '$zfilepath'\n";
    9698        }
     
    99101        $soasth->execute($revid);
    100102        my (@zsoa) = $soasth->fetchrow_array();
    101         printrec_bind($zonefilehandle, $zsoa[7], 'y', \@loclist, $revzone,
     103        printrec_bind(\%zonefiles, $zsoa[7], 'y', \@loclist, $revzone,
    102104          $zsoa[0],$zsoa[1],$zsoa[2],$zsoa[3],$zsoa[4],$zsoa[5],$zsoa[6],$zsoa[8],'');
    103105
     
    239241##fixme?:  alternate SOA serial schemes?
    240242    $serial = strftime("%Y%m%d%H", localtime()) if !$serial;
     243    $primary .= "." if $primary !~ /\.$/;
     244    $email .= "." if $email !~ /\.$/;
    241245#    print *{$zonefiles->{$loc}} "Z$zone:$primary:$email:$serial:$refresh:$retry:$expire:$min_ttl:$ttl:$stamp:$loc\n"
    242246#      or die $!;
    243247    print *{$zonefiles->{$loc}} "$zone  $ttl    IN      SOA     $primary        $email  ( $serial $refresh $retry $expire $min_ttl )\n"
    244        or die $!;
     248       or die "couldn't write $zone SOA: $!";
    245249  } # SOA
    246250
Note: See TracChangeset for help on using the changeset viewer.