- Timestamp:
- 06/12/12 17:59:39 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r344 r345 871 871 } 872 872 873 # check domain, if nonexistent coerce down to PTR template874 873 return ('OK','OK'); 875 874 } # done AAAA+PTR template record … … 881 880 882 881 # Delegation record 882 # This is essentially a specialized clone of the NS record, primarily useful 883 # for delegating IPv4 sub-/24 reverse blocks 883 884 sub _validate_65285 { 885 my $dbh = shift; 886 887 my %args = @_; 888 889 # Almost, but not quite, identical to NS record validation. 890 891 # Check that the target of the record is within the parent. 892 # Yes, host<->val are mixed up here; can't see a way to avoid it. :( 893 if ($args{defrec} eq 'n') { 894 # Check if IP/address/zone/"subzone" is within the parent 895 if ($args{revrec} eq 'y') { 896 my $tmpip = NetAddr::IP->new(${$args{val}}); 897 my $pname = revName($dbh,$args{id}); 898 return ('FAIL',"${$args{val}} not within $pname") 899 unless _ipparent($dbh, $args{defrec}, $args{revrec}, $args{val}, $args{id}, \$tmpip); 900 # Normalize 901 ${$args{val}} = "$tmpip"; 902 } else { 903 my $pname = domainName($dbh,$args{id}); 904 ${$args{host}} =~ s/\.*$/\.$pname/ if ${$args{host}} !~ /$pname$/; 905 } 906 } else { 907 return ('FAIL',"Delegation records are not permitted in default record sets"); 908 } 884 909 return ('OK','OK'); 885 910 } … … 1794 1819 $sth->execute($reverse_typemap{AAAA}, $zoneid, 65281); 1795 1820 # We don't have an "A template" or "AAAA template" type, although it might be useful for symmetry. 1796 # $sth->execute(6528 5?, $zoneid, 65283);1797 # $sth->execute(6528 5?, $zoneid, 65284);1821 # $sth->execute(65286?, $zoneid, 65283); 1822 # $sth->execute(65286?, $zoneid, 65284); 1798 1823 $failmsg = "Failure removing reverse records"; 1799 1824 $dbh->do("DELETE FROM records WHERE rdns_id=?", undef, ($zoneid)); … … 3272 3297 push @vallist, 0; 3273 3298 } 3299 } 3300 # fix fat-finger-originated record type changes 3301 if ($$rectype == 65285) { 3302 $fields .= ",rdns_id" if $revrec eq 'n'; 3303 $fields .= ",domain_id" if $revrec eq 'y'; 3304 push @vallist, 0; 3274 3305 } 3275 3306 if ($defrec eq 'n') { … … 4319 4350 4320 4351 if ($revrec eq 'y') { 4352 4353 print "$zone has\t$val NS $host\n"; 4321 4354 $val = NetAddr::IP->new($val); 4322 print $datafile '&'._ZONE($val, 'ZONE', 'r', '.').($val->{isv6} ? '.ip6.arpa' : '.in-addr.arpa'). 4323 "::$host:$ttl:$stamp:$loc\n"; 4355 $zone = NetAddr::IP->new($zone); 4356 #print "$val NS $host\n"; 4357 # handle split-n-multiply SOA for off-octet (8 < mask < 16) or (16 < mask < 24) v4 zones 4358 if (!$val->{isv6} && ($val->masklen < 24) && ($val->masklen % 8 != 0)) { 4359 foreach my $szone ($zone->split($val->masklen + (8 - $val->masklen % 8))) { 4360 my $szone2 = _ZONE($szone, 'ZONE.in-addr.arpa', 'r', '.'); 4361 next if $$recflags{"$szone2-sub"} && $zone != $val; 4362 print " $szone2-sub NS $host\n"; 4363 # && $zone == $val; 4364 print $datafile "\&$szone2"."::$host:$ttl:$stamp:$loc\n"; 4365 $$recflags{"$szone2-sub"}++ if $zone != $val; 4366 } 4367 #print "recflags should have stuff set?\n"; 4368 return; # skips "default" bits just below 4369 } 4370 my $val2 = _ZONE($val, 'ZONE', 'r', '.').($val->{isv6} ? '.ip6.arpa' : '.in-addr.arpa'); 4371 #print "checking recflags for $val\n"; 4372 #return if $$recflags{$val}; 4373 print $datafile '&'.$val2."::$host:$ttl:$stamp:$loc\n"; 4374 $$recflags{"$val2-sub"}++ if $val == $zone; 4375 print "$zone;\t$val2-sub NS $host\n"; 4376 ##NSfixme 4324 4377 } else { 4325 4378 print $datafile "\&$host"."::$val:$ttl:$stamp:$loc\n"; … … 4477 4530 # (eg http://search.cpan.org/dist/AllKnowingDNS/ ) 4478 4531 4532 } elsif ($type == 65285) { # Delegation 4533 # This is intended for reverse zones, but may prove useful in forward zones. 4534 4535 if ($revrec eq 'n') { 4536 # It's an NS record. Recurse and handle. 4537 _printrec_tiny($datafile,$revrec,$recflags,$zone,$host,$reverse_typemap{'NS'}, 4538 $val,$dist,$weight,$port,$ttl,$loc,$stamp); 4539 } else { 4540 # It's a delegation. We may need to actually generate several NS records, and 4541 # for IPv4 we may also need to generate a set of CNAMEs for sub-/24 blocks. 4542 # print "delegation $val to $host\n"; 4543 my $dblock = NetAddr::IP->new($val); 4544 if ($dblock->{isv6}) { 4545 my @subs = $dblock->split($dblock->masklen + (4 - $dblock->masklen % 4) % 4); 4546 foreach (@subs) { 4547 _printrec_tiny($datafile, $revrec, $recflags, $zone, $host, $reverse_typemap{'NS'}, 4548 "$_", $dist, $weight, $port, $ttl, $loc, $stamp); 4549 } 4550 } else { 4551 my @subs = $dblock->split($dblock->masklen + (8 - $dblock->masklen % 8) % 8); 4552 foreach (@subs) { 4553 if ($dblock->masklen <= 24) { 4554 _printrec_tiny($datafile, $revrec, $recflags, $zone, $host, $reverse_typemap{'NS'}, 4555 "$_", $dist, $weight, $port, $ttl, $loc, $stamp); 4556 #print $datafile "$_ NS $host\n"; 4557 ##nsdeleg 4558 } else { 4559 my ($oct) = ($_->addr =~ /(\d+)$/); 4560 #print "$_ CNAME $oct."._ZONE($dblock, 'ZONE.in-addr.arpa', 'r', '.')."\n"; 4561 } 4562 } 4563 } 4564 4565 #print $datafile "C$host:$val:$ttl:$stamp:$loc\n"; 4566 } 4567 4479 4568 } else { 4480 4569 # raw record. we don't know what's in here, so we ASS-U-ME the user has
Note:
See TracChangeset
for help on using the changeset viewer.