diff --git a/bind8/CHANGELOG b/bind8/CHANGELOG index 5f10df04e..285bbea04 100644 --- a/bind8/CHANGELOG +++ b/bind8/CHANGELOG @@ -75,3 +75,4 @@ Spaces are now allowed in Host Information records. ---- Changes since 1.420 ---- The default TTL for multiple zones can now be changed on the Update Records in Zones page. When adding a cluster slave server, multiple views can be entered to have slave zones created in all of them. +Record names or values entered like ns.foo.com in the domain foo.com automatically have a . added to make them absolute as the user presumably expected, rather than being coverted to ns.foo.com.foo.com. diff --git a/bind8/records-lib.pl b/bind8/records-lib.pl index 10791f4fc..26581948e 100644 --- a/bind8/records-lib.pl +++ b/bind8/records-lib.pl @@ -726,11 +726,19 @@ else { } # convert_to_absolute(short, origin) +# Make a short name like foo a fully qualified name like foo.domain.com. sub convert_to_absolute { local ($name, $origin) = @_; +if ($name eq $origin || + $name =~ /\.\Q$origin\E$/) { + # Name already ends in domain name - add . automatically, so we don't + # re-append the domain name. + $name .= "."; + } local $rv = $name eq "" ? "$origin." : - $name !~ /\.$/ ? "$name.$origin." : $name; + $name eq "@" ? "$origin." : + $name !~ /\.$/ ? "$name.$origin." : $name; $rv =~ s/\.+$/\./; return $rv; } diff --git a/bind8/save_record.cgi b/bind8/save_record.cgi index 2f8c0b356..1383982f4 100755 --- a/bind8/save_record.cgi +++ b/bind8/save_record.cgi @@ -94,7 +94,7 @@ if ($in{'delete'}) { exit; } -# parse inputs +# Create values string based on inputs if (!$in{'ttl_def'}) { $in{'ttl'} =~ /^\d+$/ || &error(&text('edit_ettl', $in{'ttl'})); @@ -106,6 +106,7 @@ for($i=1; defined($in{"value$i"}); $i++) { } $vals =~ s/^\s+//; $vals =~ s/\s+$//; + if ($in{'type'} eq "PTR" && $reverse) { # a reverse address local($ipv4); @@ -182,16 +183,26 @@ else { elsif ($in{'type'} eq "NS") { &valname($vals) || &error(&text('edit_ens', $vals)); + if ($vals =~ /\.\Q$in{'origin'}\E$/) { + # Make absolute + $vals .= "."; + } } elsif ($in{'type'} eq "CNAME") { &valname($vals) || $vals eq '@' || &error(&text('edit_ecname', $vals)); + if ($vals =~ /\.\Q$in{'origin'}\E$/) { + $vals .= "."; + } } elsif ($in{'type'} eq "MX") { &valname($in{'value1'}) || &error(&text('edit_emx', $in{'value1'})); $in{'value0'} =~ /^\d+$/ || &error(&text('edit_epri', $in{'value0'})); + if ($vals =~ /\.\Q$in{'origin'}\E$/) { + $vals .= "."; + } } elsif ($in{'type'} eq "HINFO") { $in{'value0'} =~ /\S/ ||