diff --git a/bind8/CHANGELOG b/bind8/CHANGELOG
index e9c0696b2..3040b8d9e 100644
--- a/bind8/CHANGELOG
+++ b/bind8/CHANGELOG
@@ -88,3 +88,4 @@ Converted all forms to use the Webmin UI library, for a more consistent look and
Moved buttons for deleting, moving and converting zones up to the page shown when you click on a zone name.
Switched to the new root zone file available from Internic.
Restrictions that apply to all zones in a view (such as allowed IPs for transfers and queries) can now be set on the Edit Client View page.
+Made the Find Free IPs page visible, for finding addresses in a master zone that are not currently used.
diff --git a/bind8/bind8-lib.pl b/bind8/bind8-lib.pl
index c907105da..5c4c7600f 100644
--- a/bind8/bind8-lib.pl
+++ b/bind8/bind8-lib.pl
@@ -843,7 +843,8 @@ sub can_edit_reverse
return $access{'reverse'} || &can_edit_zone($_[0]);
}
-# record_input(zoneindex, view, type, file, origin, [num], [record])
+# record_input(zoneindex, view, type, file, origin, [num], [record],
+# [new-name, new-value])
# Display a form for editing or creating a DNS record
sub record_input
{
@@ -855,16 +856,18 @@ print &ui_hidden("view", $_[1]);
print &ui_hidden("file", $_[3]);
print &ui_hidden("origin", $_[4]);
print &ui_hidden("sort", $in{'sort'});
-if (@_ >= 6) {
+if (defined($_[5])) {
print &ui_hidden("num", $_[5]);
%rec = %{$_[6]};
}
else {
print &ui_hidden("new", 1);
+ $rec{'name'} = $_[7] if ($_[7]);
+ $rec{'values'} = [ $_[8] ] if ($_[8]);
}
print &ui_hidden("type", $type);
print &ui_hidden("redirtype", $_[2]);
-print &ui_table_start(&text(@_ >= 6 ? 'edit_edit' : 'edit_add',
+print &ui_table_start(&text(defined($_[5]) ? 'edit_edit' : 'edit_add',
$text{"edit_".$type}));
# Record name field(s)
@@ -903,7 +906,7 @@ else {
}
# Show canonical name too, if not auto-converted
-if ($config{'short_names'} && @_ > 6) {
+if ($config{'short_names'} && defined($_[5])) {
print &ui_table_row($text{'edit_canon'}, "$rec{'canon'}");
}
@@ -923,8 +926,9 @@ print &ui_table_row($text{'edit_ttl'},
if ($type eq "A" || $type eq "AAAA") {
print &ui_table_row($text{'value_A1'},
&ui_textbox("value0", $v[0], 20)." ".
- (@_ < 6 && $type eq "A" ? &free_address_button("value0") : ""), 3);
- if (@_ >= 6) {
+ (!defined($_[5]) && $type eq "A" ?
+ &free_address_button("value0") : ""), 3);
+ if (defined($_[5])) {
print &ui_hidden("oldname", $rec{'name'});
print &ui_hidden("oldvalue0", $v[0]);
}
@@ -977,7 +981,7 @@ elsif ($type eq "PTR") {
# Reverse address
print &ui_table_row($text{'value_PTR1'},
&ui_textbox("value0", $v[0], 30), 3);
- if (@_ >= 6) {
+ if (defined($_[5])) {
print &ui_hidden("oldname", $rec{'name'});
print &ui_hidden("oldvalue0", $v[0]);
}
@@ -1071,7 +1075,7 @@ if ($type eq "A" || $type eq "AAAA") {
&ui_radio("rev", $config{'rev_def'} == 0 ? 1 :
$config{'rev_def'} == 2 ? 2 : 0,
[ [ 1, $text{'yes'} ],
- @_ < 6 ? ( [ 2, $text{'edit_over'} ] ) : ( ),
+ defined($_[5]) ? ( ) : ( [ 2, $text{'edit_over'} ] ),
[ 0, $text{'no'} ] ]));
}
elsif ($type eq "PTR") {
@@ -1084,7 +1088,7 @@ print &ui_table_end();
# End buttons
if (!$access{'ro'}) {
- if (@_ >= 6) {
+ if (defined($_[5])) {
print &ui_form_end([ [ undef, $text{'save'} ],
[ "delete", $text{'delete'} ] ]);
}
diff --git a/bind8/defaultacl b/bind8/defaultacl
index 51621c6f7..395f016a6 100644
--- a/bind8/defaultacl
+++ b/bind8/defaultacl
@@ -20,3 +20,4 @@ gen=1
vlist=*
delegation=1
slaves=1
+findfree=1
diff --git a/bind8/edit_recs.cgi b/bind8/edit_recs.cgi
index e7b76725c..289fe70aa 100755
--- a/bind8/edit_recs.cgi
+++ b/bind8/edit_recs.cgi
@@ -19,7 +19,8 @@ $type = $zone->{'type'};
$file = $zone->{'file'};
$form = 0;
if (!$access{'ro'} && $type eq 'master' && $in{'type'} ne 'ALL') {
- &record_input($in{'index'}, $in{'view'}, $in{'type'}, $file, $dom);
+ &record_input($in{'index'}, $in{'view'}, $in{'type'}, $file, $dom,
+ undef, undef, $in{'newname'}, $in{'newvalue'});
$form++;
$shown_create_form = 1;
}
diff --git a/bind8/find_free.cgi b/bind8/find_free.cgi
index b3e4b806b..9c32e5b3d 100755
--- a/bind8/find_free.cgi
+++ b/bind8/find_free.cgi
@@ -17,23 +17,10 @@ if (!$access{'findfree'}) {&error($text{'findfree_nofind'})};
$desc = &text('findfree_header', &arpa_to_ip($dom));
&ui_print_header($desc, &text('findfree_title'), "");
-my $cf=1;
-if (@in == 2) {
- &find_ips ($in{'index'}, $in{'from'});
-}
-elsif (@in == 3) {
- &find_ips ($in{'index'}, $in{'from'}, $in{'to'});
-}
-elsif (@in == 4) {
- $cf=$in{'cf'};
- &find_ips ($in{'index'}, $in{'from'}, $in{'to'}, $in{'cf'});
-}
-else {
- &find_ips ($in{'index'});
-}
-
-if (@in >= 3) { #we need to do the search!
+&find_ips($in{'index'}, $in{'from'}, $in{'to'}, $in{'cf'});
+if ($in{'from'} && $in{'to'}) {
+ # Do the search
@recs = &read_zone_file($file, $dom);
@recs = grep { ($_->{'type'} eq 'A') || ($_->{'type'} eq 'PTR')} @recs;
my $freeXXXcount=0;
@@ -57,7 +44,7 @@ if (@in >= 3) { #we need to do the search!
# print "evaluating ", $hip, " ", $hname, "...
"; #debug
- if($cf & ($hname=~ /^free.*/) & exists $frecs{$hip}) { # 'freeXXX' hostnames are free IP's!
+ if($in{'cf'} & ($hname=~ /^free.*/) & exists $frecs{$hip}) { # 'freeXXX' hostnames are free IP's!
# update
# print " updating: ",$hip, "...
"; #debug
$frecs{$hip}->{'ttl'}=$recs[$i]->{'ttl'};
@@ -72,23 +59,16 @@ if (@in >= 3) { #we need to do the search!
}
-
+ # Show a message
my @frecs=sort ffree_ip_sort_func values %frecs;
- my $mid = int((@frecs+1)/2);
- print "
Found " . @frecs . " free IP number" . (@frecs==1?"\n":"s\n"); - if ($cf) { - print " ($freeXXXcount ". ($freeXXXcount==1?" is":"are") . - " `freeXXX'" . - " of which $freemaccount ". ($freemaccount==1?" is":"are") . - " `freemac')" ; - print "
\n"; - } - print "| \n"; - &frecs_table(@frecs[0 .. $mid-1]); - print " | \n"; - if ($mid < @frecs) { &frecs_table(@frecs[$mid .. $#frecs]); } - print " |
\n"; - print "
\n"; + print "",&text('findfree_msg', scalar(@frecs)),"\n"; + if ($in{'cf'}) { + print &text('findfree_msg2', $freeXXXcount, $freemaccount),"\n"; + } + print "...
\n"; + + # Show all the IPs + &frecs_table(@frecs); } # if(@recs) } # if(@in >= 3) @@ -139,91 +119,40 @@ for ($byte0=$from[0]; $byte0<=$to[0]; $byte0++) { return %frecs; } # sub build_iprange - - - - - - - - - - - # find_ips (zoneindex, from_ip, to_ip, consider_freeXX_names) # Display a form for searching for free IP nos sub find_ips { -print "
\n"; - -} # end of find_ips - - - - - +print &ui_form_start("find_free.cgi"); +print &ui_hidden("index", $_[0]); +print &ui_hidden("view", $in{'view'}); +print &ui_table_start($text{'findfree_sopt'}, undef, 2); +# Range start +print &ui_table_row($text{'findfree_fromip'}, + &ui_textbox("from", $_[1], 20)); +# Range end +print &ui_table_row($text{'findfree_toip'}, + &ui_textbox("to", $_[2], 20)); +# Handle freeXXX hostnames? +print &ui_table_row($text{'findfree_cf'}, + &ui_yesno_radio("cf", $_[3])); +print &ui_table_end(); +print &ui_form_end([ [ undef, $text{'findfree_search'} ] ]); +} # frecs_table(array_of_freerecords) sub frecs_table { -print "| ", $text{'recs_addr'}," | ", - "$text{'recs_ttl'} | \n", - "$text{'recs_name'} | \n", - "
| $r->{'ip'} | \n", - "",$r->{'ttl'} ? $r->{'ttl'} : $text{'default'}," | \n", - "",$r->{'name'}?$r->{'name'}:' '," | \n", - "