Changeset 328
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r326 r328 383 383 my %args = @_; 384 384 385 # Coerce the hostname to "DOMAIN" for forward default records, "ZONE" for reverse default records, 386 # or the intended parent zone for live records. 387 ##fixme: allow for delegating <subdomain>.DOMAIN? 388 if ($args{revrec} eq 'y') { 389 my $pname = ($args{defrec} eq 'y' ? 'ZONE' : revName($dbh,$args{id})); 390 ${$args{host}} = $pname if ${$args{host}} ne $pname; 385 # Check that the target of the record is within the parent. 386 # Yes, host<->val are mixed up here; can't see a way to avoid it. :( 387 if ($args{defrec} eq 'n') { 388 # Check if IP/address/zone/"subzone" is within the parent 389 if ($args{revrec} eq 'y') { 390 my $tmpip = NetAddr::IP->new(${$args{val}}); 391 my $pname = revName($dbh,$args{id}); 392 return ('FAIL',"${$args{val}} not within $pname") 393 unless _ipparent($dbh, $args{defrec}, $args{revrec}, $args{val}, $args{id}, \$tmpip); 394 # Sub the returned thing for ZONE? This could get stupid if you have typos... 395 ${$args{val}} =~ s/ZONE/$tmpip->address/; 396 } else { 397 my $pname = domainName($dbh,$args{id}); 398 ${$args{host}} = $pname if ${$args{host}} !~ /\.$pname$/; 399 } 391 400 } else { 392 my $pname = ($args{defrec} eq 'y' ? 'DOMAIN' : domainName($dbh,$args{id})); 393 ${$args{host}} = $pname if ${$args{host}} ne $pname; 401 # Default reverse NS records should always refer to the implied parent 402 ${$args{host}} = 'DOMAIN' if $args{revrec} eq 'n'; 403 ${$args{val}} = 'ZONE' if $args{revrec} eq 'y'; 394 404 } 395 405 … … 1766 1776 } 1767 1777 1768 # Substitute $zone for ZONE in the hostname. 1769 $host = _ZONE($zone, $host); 1778 # Substitute $zone for ZONE in the hostname, but only for non-NS records. 1779 # NS records get this substitution on the value instead. 1780 $host = _ZONE($zone, $host) if $type != 2; 1770 1781 1771 1782 # Fill in the forward domain ID if we can find it, otherwise: … … 2948 2959 (id => $id, type => ($revrec eq 'n' ? 'domain' : 'revzone'), revrec => $revrec) ) 2949 2960 if $defrec eq 'n'; 2950 $logdata{entry} = "Added ".($defrec eq 'y' ? 'default record' : 'record')." '$$host $typemap{$$rectype} $$val"; 2961 $logdata{entry} = "Added ".($defrec eq 'y' ? 'default record' : 'record'); 2962 # NS records for revzones get special treatment 2963 if ($revrec eq 'y' && $$rectype == 2) { 2964 $logdata{entry} .= " '$$val $typemap{$$rectype} $$host"; 2965 } else { 2966 $logdata{entry} .= " '$$host $typemap{$$rectype} $$val"; 2967 } 2968 2951 2969 $logdata{entry} .= " [distance $dist]" if $typemap{$$rectype} eq 'MX'; 2952 2970 $logdata{entry} .= " [priority $dist] [weight $weight] [port $port]" … … 3083 3101 (id => $parid, type => ($revrec eq 'n' ? 'domain' : 'revzone'), revrec => $revrec) ) 3084 3102 if $defrec eq 'n'; 3085 $logdata{entry} = "Updated ".($defrec eq 'y' ? 'default record' : 'record')." from\n". 3086 "'$oldrec->{host} $typemap{$oldrec->{type}} $oldrec->{val}"; 3103 $logdata{entry} = "Updated ".($defrec eq 'y' ? 'default record' : 'record')." from\n"; 3104 # NS records for revzones get special treatment 3105 if ($revrec eq 'y' && $$rectype == 2) { 3106 $logdata{entry} .= " '$oldrec->{val} $typemap{$oldrec->{type}} $oldrec->{host}"; 3107 } else { 3108 $logdata{entry} .= " '$oldrec->{host} $typemap{$oldrec->{type}} $oldrec->{val}"; 3109 } 3087 3110 $logdata{entry} .= " [distance $oldrec->{distance}]" if $typemap{$oldrec->{type}} eq 'MX'; 3088 3111 $logdata{entry} .= " [priority $oldrec->{distance}] [weight $oldrec->{weight}] [port $oldrec->{port}]" 3089 3112 if $typemap{$oldrec->{type}} eq 'SRV'; 3090 $logdata{entry} .= "', TTL $oldrec->{ttl}\nto\n'$$host $typemap{$$rectype} $$val"; 3113 $logdata{entry} .= "', TTL $oldrec->{ttl}\nto\n"; 3114 # More NS special 3115 if ($revrec eq 'y' && $$rectype == 2) { 3116 $logdata{entry} .= "'$$val $typemap{$$rectype} $$host"; 3117 } else { 3118 $logdata{entry} .= "'$$host $typemap{$$rectype} $$val"; 3119 } 3091 3120 $logdata{entry} .= " [distance $dist]" if $typemap{$$rectype} eq 'MX'; 3092 3121 $logdata{entry} .= " [priority $dist] [weight $weight] [port $port]" if $typemap{$$rectype} eq 'SRV'; -
trunk/dns.sql
r306 r328 54 54 1 1 hostmaster.ADMINDOMAIN:ns1.ADMINDOMAIN 6 3600:900:1048576:2560 3600 55 55 2 1 unused-%r.ADMINDOMAIN 65283 ZONE 3600 56 3 1 ZONE 2 ns2.example.com7200 \N57 4 1 ZONE 2 ns1.example.com7200 \N56 3 1 ns2.example.com 2 ZONE 7200 \N 57 4 1 ns1.example.com 2 ZONE 7200 \N 58 58 \. 59 59
Note:
See TracChangeset
for help on using the changeset viewer.