diff --git a/net/net-lib.pl b/net/net-lib.pl index 69d3c1391..372dc3325 100755 --- a/net/net-lib.pl +++ b/net/net-lib.pl @@ -403,5 +403,32 @@ else { } } +# canonicalize_ip6(address) +# Converts an address to its full long form. Ie. 2001:db8:0:f101::20 to +# 2001:0db8:0000:f101:0000:0000:0000:0020 +sub canonicalize_ip6 +{ +my ($addr) = @_; +return $addr if (!&check_ip6address($addr)); +my @w = split(/:/, $addr); +my $idx = &indexof("", @w); +if ($idx >= 0) { + # Expand :: + my $mis = 8 - scalar(@w); + my @nw = @w[0..$idx]; + for(my $i=0; $i<$mis; $i++) { + push(@nw, 0); + } + push(@nw, @w[$idx+1 .. $#w]); + @w = @nw; + } +foreach my $w (@w) { + while(length($w) < 4) { + $w = "0".$w; + } + } +return lc(join(":", @w)); +} + 1; diff --git a/webmin/change_bind.cgi b/webmin/change_bind.cgi index 100d8749c..89feca0cc 100755 --- a/webmin/change_bind.cgi +++ b/webmin/change_bind.cgi @@ -61,13 +61,14 @@ if (@ips && &foreign_installed("net")) { foreach $a (&net::active_interfaces()) { $onsystem{$a->{'address'}} = $a; foreach $ip6 (@{$a->{'address6'}}) { - $onsystem{$ip6} = $a; + $onsystem{&canonicalize_ip6($ip6)} = $a; } } } if (%onsystem) { foreach $ip (@ips) { - $onsystem{$ip} || &error(&text('bind_eonsystem', $ip)); + $onsystem{&canonicalize_ip6($ip)} || + &error(&text('bind_eonsystem', $ip)); } } }