- Timestamp:
- 09/22/22 17:36:43 (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB/ExportBIND.pm
r867 r868 84 84 # fetch a list of views/locations present in the zone. we need to publish a file for each one. 85 85 # in the event that no locations are present (~~ $viewlist is empty), /%view collapses to nothing in the zone path 86 my (@loclist) = $dnsdb->{dbh}->selectrow_array("SELECT DISTINCT location FROM records WHERE rdns_id = ?", undef, $revid); 86 # my (@loclist) = $dnsdb->{dbh}->selectrow_array("SELECT DISTINCT location FROM records WHERE rdns_id = ?", undef, $revid); 87 my $tmplocs = $dnsdb->{dbh}->selectall_arrayref("SELECT DISTINCT location FROM records WHERE rdns_id = ?", undef, $revid); 88 my @loclist; 89 foreach my $tloc (@{$tmplocs}) { 90 push @loclist, ($tloc->[0] eq '' ? 'common' : $tloc->[0]); 91 } 92 87 93 push @loclist, $defloc unless grep /$defloc/, @loclist; 94 push @loclist, 'common' unless grep /^common$/, @loclist; 88 95 my $zonepath = $dnsdb->{bind_export_reverse_zone_path}; 89 96 my %zonefiles; # to be a hash of file handles. … … 97 104 $zfilepath =~ s,[^\w./-],_,g; 98 105 open $zonefiles{$loc}, ">", $zfilepath; 99 printf {$zonefiles{$loc}} "; %s in view %s exported %s\n", $arpazone, $loc, scalar(localtime) ;100 print "open zonefile for '$loc', '$zfilepath'\n";106 printf {$zonefiles{$loc}} "; %s in view %s exported %s\n", $arpazone, $loc, scalar(localtime) 107 or die "Error writing SOA [$zone, '$loc']: $!\n";; 101 108 } 102 109 … … 105 112 my (@zsoa) = $soasth->fetchrow_array(); 106 113 ##fixme: do we even need @loclist passed in? 107 printrec_bind(\%zonefiles, $zsoa[7], 'y', \%recflags, $revzone,114 printrec_bind(\%zonefiles, \@loclist, $zsoa[7], 'y', \%recflags, $revzone, 108 115 $zsoa[0],$zsoa[1],$zsoa[2],$zsoa[3],$zsoa[4],$zsoa[5],$zsoa[6],$zsoa[8],''); 109 116 … … 139 146 } 140 147 141 printrec_bind( $zonefilehandle, $recid, 'y', \%recflags, $revzone,148 printrec_bind(\%zonefiles, \@loclist, $recid, 'y', \%recflags, $revzone, 142 149 $host, $type, $val, $dist, $weight, $port, $ttl, $loc, $stamp, $expires, $stampactive); 143 150 … … 222 229 223 230 # my ($zonefiles, $recid, $revrec, $loclist, $zone, $host, $type, $val, $distance, $weight, $port, $ttl, 224 my ($zonefiles, $ recid, $revrec, $recflags, $zone, $host, $type, $val, $distance, $weight, $port, $ttl,231 my ($zonefiles, $loclist, $recid, $revrec, $recflags, $zone, $host, $type, $val, $distance, $weight, $port, $ttl, 225 232 $loc, $stamp, $expires, $stampactive) = @_; 233 234 # make sure "global" records get into all the right per-view zone files, without having to do this loop in each record-print location 235 ##fixme: maybe exclude the template types? those may be more expensive to export 236 ## *ponder* may be more efficient to loop in each record print due to substitution and manipulation from stored data to formal 237 ## record for .arpa zones for all records 238 if ($loc eq '') { 239 foreach my $subloc (@{$loclist}) { 240 printrec_bind($zonefiles, $loclist, $recid, $revrec, $recflags, $zone, $host, $type, $val, $distance, $weight, $port, $ttl, 241 $subloc, $stamp, $expires, $stampactive); 242 } 243 } 226 244 227 245 # Just In Case something is lingering in the DB … … 317 335 print {$zonefiles->{$loc}} "$val.".DNSDB::_ZONE($zone, 'ZONE', 'r', '.').'.in-addr.arpa'. 318 336 " $ttl IN PTR $host\n" 319 337 or die $!; 320 338 } else { 321 339 # not going to care about strange results if $val is not an IP value and is resolveable in DNS … … 323 341 print {$zonefiles->{$loc}} DNSDB::_ZONE($val, 'ZONE', 'r', '.').($val->{isv6} ? '.ip6.arpa' : '.in-addr.arpa'). 324 342 " $ttl IN PTR $host\n" 325 343 or die $!; 326 344 327 345 }
Note:
See TracChangeset
for help on using the changeset viewer.