Changeset 573
- Timestamp:
- 12/31/13 15:14:55 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r572 r573 4701 4701 } elsif ($type eq 'NS') { 4702 4702 # hmm. should we warn here if subdomain NS'es are left alone? 4703 next if ($args{rwns} && ($rr->name eq $zone));4704 4703 if ($rev eq 'y') { 4705 4704 # revzones have records more or less reversed from forward zones. 4706 4705 my ($tmpcode,$tmpmsg) = _zone2cidr($host); 4707 4706 die "Error converting NS record: $tmpmsg\n" if $tmpcode eq 'FAIL'; # hmm. may not make sense... 4707 next if ($args{rwns} && ($tmpmsg eq "$cidr")); 4708 4708 $val = "$tmpmsg"; 4709 4709 $host = $rr->nsdname; … … 4715 4715 #} 4716 4716 } else { 4717 next if ($args{rwns} && ($rr->name eq $zone)); 4717 4718 $val = $rr->nsdname; 4718 4719 } … … 4868 4869 if ($args{rwsoa}) { 4869 4870 $soaflag = 1; 4870 my $sthgetsoa = $dbh->prepare("SELECT host,val,ttl FROM default_records WHERE group_id=? AND type=?"); 4871 my $sthputsoa = $dbh->prepare("INSERT INTO records (domain_id,host,type,val,ttl) VALUES (?,?,?,?,?)"); 4871 my $sthgetsoa = $dbh->prepare("SELECT host,val,ttl FROM "._rectable('y', $rev)." WHERE group_id=? AND type=?"); 4872 my $sthputsoa = $dbh->prepare("INSERT INTO records (". 4873 ($rev eq 'n' ? 'domain_id' : 'rdns_id').",host,type,val,ttl) VALUES (?,?,?,?,?)"); 4872 4874 $sthgetsoa->execute($group,$reverse_typemap{SOA}); 4873 4875 while (my ($host,$val,$ttl) = $sthgetsoa->fetchrow_array()) { 4874 $host =~ s/DOMAIN/$zone/g; 4875 $val =~ s/DOMAIN/$zone/g; 4876 if ($rev eq 'n') { 4877 $host =~ s/DOMAIN/$zone/g; 4878 $val =~ s/DOMAIN/$zone/g; # arguably useless 4879 } else { 4880 $host =~ s/ADMINDOMAIN/$self->{domain}/g; 4881 } 4876 4882 $sthputsoa->execute($zone_id,$host,$reverse_typemap{SOA},$val,$ttl); 4877 4883 } 4878 4884 } 4879 4885 4880 # Overwrite NS records4886 # Add standard NS records. The old one(s) should have been skipped by this point. 4881 4887 if ($args{rwns}) { 4882 4888 $nsflag = 1; 4883 my $sthgetns = $dbh->prepare("SELECT host,val,ttl FROM default_records WHERE group_id=? AND type=?"); 4884 my $sthputns = $dbh->prepare("INSERT INTO records (domain_id,host,type,val,ttl) VALUES (?,?,?,?,?)"); 4889 my $sthgetns = $dbh->prepare("SELECT host,val,ttl FROM "._rectable('y',$rev)." WHERE group_id=? AND type=?"); 4890 my $sthputns = $dbh->prepare("INSERT INTO records (". 4891 ($rev eq 'n' ? 'domain_id' : 'rdns_id').",host,type,val,ttl) VALUES (?,?,?,?,?)"); 4885 4892 $sthgetns->execute($group,$reverse_typemap{NS}); 4886 4893 while (my ($host,$val,$ttl) = $sthgetns->fetchrow_array()) { 4887 $host =~ s/DOMAIN/$zone/g; 4888 $val =~ s/DOMAIN/$zone/g; 4894 if ($rev eq 'n') { 4895 $host =~ s/DOMAIN/$zone/g; 4896 $val =~ s/DOMAIN/$zone/g; #hmm. 4897 } else { 4898 $host =~ s/ADMINDOMAIN/$self->{domain}/g; #hmm. 4899 $val =~ s/ZONE/$cidr/g; 4900 } 4889 4901 $sthputns->execute($zone_id,$host,$reverse_typemap{NS},$val,$ttl); 4890 4902 } … … 5078 5090 $soasth->execute($revid); 5079 5091 my (@zsoa) = $soasth->fetchrow_array(); 5080 _printrec_tiny($zonefilehandle, 'y',\%recflags,$revzone,5092 _printrec_tiny($zonefilehandle, $zsoa[7], 'y',\%recflags,$revzone, 5081 5093 $zsoa[0],$zsoa[1],$zsoa[2],$zsoa[3],$zsoa[4],$zsoa[5],$zsoa[6],$zsoa[8],''); 5082 5094 5083 5095 $recsth->execute($revid); 5084 while (my ($host,$type,$val,$dist,$weight,$port,$ttl,$recid,$loc,$stamp,$expires,$stampactive) = $recsth->fetchrow_array) { 5096 while (my ($host, $type, $val, $dist, $weight, $port, $ttl, $recid, $loc, $stamp, $expires, $stampactive) 5097 = $recsth->fetchrow_array) { 5085 5098 next if $recflags{$recid}; 5086 5099 … … 5095 5108 # } 5096 5109 5097 _printrec_tiny($zonefilehandle, 'y', \%recflags, $revzone,5110 _printrec_tiny($zonefilehandle, $recid, 'y', \%recflags, $revzone, 5098 5111 $host, $type, $val, $dist, $weight, $port, $ttl, $loc, $stamp, $expires, $stampactive); 5099 5112 … … 5179 5192 } 5180 5193 5181 _printrec_tiny($zonefilehandle, 'n', \%recflags,5194 _printrec_tiny($zonefilehandle, $recid, 'n', \%recflags, 5182 5195 $dom, $host, $type, $val, $dist, $weight, $port, $ttl, $loc, $stamp, $expires, $stampactive); 5183 5196 … … 5228 5241 # Utility sub for __export_tiny above 5229 5242 sub _printrec_tiny { 5230 my ($datafile,$revrec,$recflags,$zone,$host,$type,$val,$dist,$weight,$port,$ttl,$loc,$stamp,$expires,$stampactive) = @_; 5243 my ($datafile, $recid, $revrec, $recflags, $zone, $host, $type, $val, $dist, $weight, $port, $ttl, 5244 $loc, $stamp, $expires, $stampactive) = @_; 5231 5245 5232 5246 $loc = '' if !$loc; # de-nullify - just in case
Note:
See TracChangeset
for help on using the changeset viewer.