diff --git a/bind8/bind8-lib.pl b/bind8/bind8-lib.pl index 851d1f645..3eaa852a5 100644 --- a/bind8/bind8-lib.pl +++ b/bind8/bind8-lib.pl @@ -312,7 +312,7 @@ else { } } -# save_directive(&parent, name|&old, &values, indent, [structonly]) +# save_directive(&parent, name|&olds, &values, indent, [structonly]) # Given a structure containing a directive name, type, values and members # add, update or remove that directive in config structure and data files. # Updating of files assumes that there is no overlap between directives - @@ -328,11 +328,9 @@ for($i=0; $i<@oldv || $i<@newv; $i++) { # a new directive is being added.. put it at the end of # the parent if (!$_[4]) { - local $parent = &get_config_parent($newv[$i]->{'file'} || - $_[0]->{'file'}); - $lref = &read_file_lines( - &make_chroot($newv[$i]->{'file'} || - $_[0]->{'file'})); + local $addfile = $newv[$i]->{'file'} || $_[0]->{'file'}; + local $parent = &get_config_parent($addfile); + $lref = &read_file_lines(&make_chroot($addfile)); @nl = &directive_lines($newv[$i], $_[3]); splice(@$lref, $_[0]->{'eline'}, 0, @nl); $newv[$i]->{'file'} = $_[0]->{'file'}; @@ -2432,5 +2430,45 @@ local $out = &backquote_command( return $? ? split(/\r?\n/, $out) : ( ); } +# delete_records_file(file) +# Given a file (chroot-relative), delete it with locking, and any associated +# journal or log files +sub delete_records_file +{ +local ($file) = @_; +local $zonefile = &make_chroot(&absolute_path($file)); +&lock_file($zonefile); +unlink($zonefile); +local $logfile = $zonefile.".log"; +if (-r $logfile) { + &lock_file($logfile); + unlink($logfile); + } +local $jnlfile = $zonefile.".jnl"; +if (-r $jnlfile) { + &lock_file($jnlfile); + unlink($jnlfile); + } +} + +# move_zone_button(&config, current-view, zone-index) +# If possible, returns a button row for moving this zone to another view +sub move_zone_button +{ +local ($conf, $view, $index) = @_; +local @views = grep { &can_edit_view($_) } &find("view", $conf); +if ($view eq '' && @views || $view ne '' && @views > 1) { + return &ui_buttons_row("move_zone.cgi", + $text{'master_move'}, + $text{'master_movedesc'}, + &ui_hidden("index", $index). + &ui_hidden("view", $view), + &ui_select("newview", undef, + [ map { [ $_->{'index'}, $_->{'value'} ] } + grep { $_->{'index'} ne $view } @views ])); + } +return undef; +} + 1; diff --git a/bind8/delete_view.cgi b/bind8/delete_view.cgi index d5103665f..f45899f54 100755 --- a/bind8/delete_view.cgi +++ b/bind8/delete_view.cgi @@ -4,8 +4,8 @@ require './bind8-lib.pl'; &ReadParse(); -$pconf = &get_config_parent(); -$conf = $pconf->{'members'}; +$parent = &get_config_parent(); +$conf = $parent->{'members'}; $vconf = $conf->[$in{'index'}]; $access{'views'} || &error($text{'view_ecannot'}); @@ -13,34 +13,31 @@ if (!$in{'confirm'}) { # Ask the user if he is sure .. &ui_print_header(undef, $text{'vdelete_title'}, ""); + # Build input for moving zones to another view @zones = &find("zone", $vconf->{'members'}); - print "

",&text(@zones ? 'vdelete_mesg' : 'vdelete_mesg2', - "$vconf->{'value'}"),"

\n"; - print "

\n"; - print "\n"; - print "
\n"; if (@zones) { - print "$text{'vdelete_newview'}\n"; - print " ", - "$text{'vdelete_delete'}\n"; - print " ", - "$text{'vdelete_root'}\n"; + @moveopts = ( [ 0, $text{'vdelete_delete'} ], + [ 1, $text{'vdelete_root'} ] ); @views = &find("view", $conf); if (@views > 1) { - print " ", - "$text{'vdelete_move'}\n"; - print "\n"; + push(@moveopts, [ 2, $text{'vdelete_move'}." ". + &ui_select("newview", undef, + [ map { [ $_->{'index'}, $_->{'value'} ] } + grep { $_->{'index'} != $in{'index'} } + @views ]) ]); } - print "
\n"; + $movefield = "$text{'vdelete_newview'} ". + &ui_radio("mode", 1, \@moveopts); } - print "
\n"; + + # Show confirm form + print &ui_confirmation_form("delete_view.cgi", + &text(@zones ? 'vdelete_mesg' : 'vdelete_mesg2', + "$vconf->{'value'}"), + [ [ 'index', $in{'index'} ] ], + [ [ 'confirm', $text{'view_delete'} ] ], + $movefield); + &ui_print_footer("", $text{'index_return'}); exit; } @@ -48,9 +45,11 @@ if (!$in{'confirm'}) { # deal with the zones in this view @zones = &find("zone", $vconf->{'members'}); if ($in{'mode'} == 1) { - $dest = $pconf; + # Adding to top level + $dest = &get_config_parent(&add_to_file()); } else { + # Adding to some other view $dest = $conf->[$in{'newview'}]; } &lock_file(&make_chroot($dest->{'file'})); @@ -58,24 +57,23 @@ foreach $z (@zones) { local $type = &find_value("type", $z->{'members'}); next if (!$type || $type eq 'hint'); if ($in{'mode'} == 0) { - # Delete the records file - local $file = &find_value("file", $z->{'members'}); - if ($file) { - &lock_file(&make_chroot(&absolute_path($file))); - unlink(&make_chroot(&absolute_path($file))); + # Delete the records file, and perhaps journal + local $f = &find_value("file", $z->{'members'}); + if ($f) { + &delete_records_file($f->{'value'}); } } else { - # Move to another view or the top level + # Move to another view or the top level. + # File may change + delete($z->{'file'}); &save_directive($dest, undef, [ $z ], $in{'mode'} == 2 ? 1 : 0); } } -&flush_file_lines(); # remove the view directive &lock_file(&make_chroot($vconf->{'file'})); -$lref = &read_file_lines(&make_chroot($vconf->{'file'})); -splice(@$lref, $vconf->{'line'}, $vconf->{'eline'} - $vconf->{'line'} + 1); +&save_directive($parent, [ $vconf ], [ ]); &flush_file_lines(); &unlock_all_files(); &webmin_log("delete", "view", $vconf->{'value'}, \%in); diff --git a/bind8/delete_zone.cgi b/bind8/delete_zone.cgi index adbad9fe5..98771919b 100755 --- a/bind8/delete_zone.cgi +++ b/bind8/delete_zone.cgi @@ -5,10 +5,12 @@ require './bind8-lib.pl'; &ReadParse(); $conf = &get_config(); +$parent = &get_config_parent(); if ($in{'view'} ne '') { $view = $conf->[$in{'view'}]; $conf = $view->{'members'}; $viewname = $view->{'values'}->[0]; + $parent = $view; } else { $viewname = undef; @@ -41,7 +43,7 @@ if (!$in{'confirm'} && $config{'confirm_zone'}) { &text('delete_mesg3', $zdesc), [ [ 'index', $in{'index'} ], [ 'view', $in{'view'} ] ], - [ [ 'confirm', $text{'delete'} ] ], + [ [ 'confirm', $text{'master_del'} ] ], ($type eq 'master' ? $text{$rev ? 'delete_fwd' : 'delete_rev'}." ". &ui_yesno_radio("rev", 1)."
" : ""). @@ -106,21 +108,12 @@ elsif ($rev && $in{'rev'} && $type eq 'master') { # delete the records file $f = &find("file", $zconf->{'members'}); if ($f && $type ne 'hint') { - local $zonefile = &make_chroot(&absolute_path($f->{'value'})); - &lock_file($zonefile); - unlink($zonefile); - local $logfile = $zonefile.".log"; - if (!-r $logfile) { $logfile = $zonefile.".jnl"; } - if (-r $logfile) { - &lock_file($logfile); - unlink($logfile); - } + &delete_records_file($f->{'value'}); } # remove the zone directive &lock_file(&make_chroot($zconf->{'file'})); -$lref = &read_file_lines(&make_chroot($zconf->{'file'})); -splice(@$lref, $zconf->{'line'}, $zconf->{'eline'} - $zconf->{'line'} + 1); +&save_directive($parent, [ $zconf ], [ ]); &flush_file_lines(); &unlock_all_files(); &webmin_log("delete", &find("type", $zconf->{'members'})->{'value'}, diff --git a/bind8/edit_delegation.cgi b/bind8/edit_delegation.cgi index 0589498fb..c7363956e 100755 --- a/bind8/edit_delegation.cgi +++ b/bind8/edit_delegation.cgi @@ -23,17 +23,7 @@ if (!$access{'ro'}) { print &ui_buttons_start(); # Move to another view - @views = &find("view", $bconf); - if ($in{'view'} eq '' && @views || $in{'view'} ne '' && @views > 1) { - print &ui_buttons_row("move_zone.cgi", - $text{'master_move'}, - $text{'master_movedesc'}, - &ui_hidden("index", $in{'index'}). - &ui_hidden("view", $in{'view'}), - &ui_select("newview", undef, - map { [ $_->{'index'}, $_->{'view'} ] } - grep { $_->{'index'} ne $in{'view'} } @views)); - } + print &move_zone_button($bconf, $in{'view'}, $in{'index'}); # Delete zone if ($access{'delete'}) { diff --git a/bind8/edit_forward.cgi b/bind8/edit_forward.cgi index aaffd3589..cdf8f2660 100755 --- a/bind8/edit_forward.cgi +++ b/bind8/edit_forward.cgi @@ -44,17 +44,7 @@ else { print &ui_buttons_start(); # Move to another view - @views = &find("view", $bconf); - if ($in{'view'} eq '' && @views || $in{'view'} ne '' && @views > 1) { - print &ui_buttons_row("move_zone.cgi", - $text{'master_move'}, - $text{'master_movedesc'}, - &ui_hidden("index", $in{'index'}). - &ui_hidden("view", $in{'view'}), - &ui_select("newview", undef, - map { [ $_->{'index'}, $_->{'view'} ] } - grep { $_->{'index'} ne $in{'view'} } @views)); - } + print &move_zone_button($bconf, $in{'view'}, $in{'index'}); # Delete zone if ($access{'delete'}) { diff --git a/bind8/edit_master.cgi b/bind8/edit_master.cgi index 88198a15d..2f6989929 100755 --- a/bind8/edit_master.cgi +++ b/bind8/edit_master.cgi @@ -147,16 +147,29 @@ if (!$access{'ro'} && ($access{'delete'} || $apply)) { &ui_hidden("index", $in{'index'}). &ui_hidden("view", $in{'view'}) ); + } - # Show button to check records - if (&supports_check_zone()) { - print &ui_buttons_row( - "check_zone.cgi", $text{'master_checkzone'}, - $text{'master_checkzonemsg'}, - &ui_hidden("index", $in{'index'}). - &ui_hidden("view", $in{'view'}) - ); - } + # Show button to check records + if (&supports_check_zone()) { + print &ui_buttons_row( + "check_zone.cgi", $text{'master_checkzone'}, + $text{'master_checkzonemsg'}, + &ui_hidden("index", $in{'index'}). + &ui_hidden("view", $in{'view'}) + ); + } + + # Move zone button + $conf = &get_config(); + print &move_zone_button($conf, $in{'view'}, $in{'index'}); + + # Convert to slave zone + if ($access{'slave'}) { + print &ui_buttons_row("convert_master.cgi", + $text{'master_convert'}, + $text{'master_convertdesc'}, + &ui_hidden("index", $in{'index'}). + &ui_hidden("view", $in{'view'})); } print &ui_buttons_end(); diff --git a/bind8/edit_options.cgi b/bind8/edit_options.cgi index df001a6f9..080a32650 100755 --- a/bind8/edit_options.cgi +++ b/bind8/edit_options.cgi @@ -39,34 +39,6 @@ print &address_input($text{'master_notify2'}, "also-notify", $zconf); print &ui_table_end(); print &ui_form_end([ [ undef, $text{'save'} ] ]); -# Buttons at end of page -print &ui_hr(); -print &ui_buttons_start(); - -# Move to another view -@views = grep { &can_edit_view($_) } &find("view", $bconf); -if ($in{'view'} eq '' && @views || $in{'view'} ne '' && @views > 1) { - print &ui_buttons_row("move_zone.cgi", - $text{'master_move'}, - $text{'master_movedesc'}, - &ui_hidden("index", $in{'index'}). - &ui_hidden("view", $in{'view'}), - &ui_select("newview", undef, - map { [ $_->{'index'}, $_->{'view'} ] } - grep { $_->{'index'} ne $in{'view'} } @views)); - } - -# Convert to slave zone -if ($access{'slave'}) { - print &ui_buttons_row("convert_master.cgi", - $text{'master_convert'}, - $text{'master_convertdesc'}, - &ui_hidden("index", $in{'index'}). - &ui_hidden("view", $in{'view'})); - } - -print &ui_buttons_end(); - &ui_print_footer("edit_master.cgi?index=$in{'index'}&view=$in{'view'}", $text{'master_return'}); diff --git a/bind8/edit_slave.cgi b/bind8/edit_slave.cgi index 68d1cea02..03e130e4a 100755 --- a/bind8/edit_slave.cgi +++ b/bind8/edit_slave.cgi @@ -98,8 +98,8 @@ if (!$access{'ro'} && ($access{'delete'} || $apply)) { &ui_hidden("view", $in{'view'})); } + # Show button to do an NDC reload if ($apply) { - # Show button to do an NDC reload print &ui_buttons_row("restart_zone.cgi", $text{'slave_apply'}, $text{'slave_applymsg2'}, @@ -107,6 +107,19 @@ if (!$access{'ro'} && ($access{'delete'} || $apply)) { &ui_hidden("view", $in{'view'})); } + # Move to other view + $conf = &get_config(); + print &move_zone_button($conf, $in{'view'}, $in{'index'}); + + # Convert to master zone + if ($access{'master'} && $st[7]) { + print &ui_buttons_row("convert_slave.cgi", + $text{'slave_convert'}, + $text{'slave_convertdesc'}, + &ui_hidden("index", $in{'index'}). + &ui_hidden("view", $in{'view'})); + } + print &ui_buttons_end(); } diff --git a/bind8/edit_soptions.cgi b/bind8/edit_soptions.cgi index 4da73674e..722ac5395 100755 --- a/bind8/edit_soptions.cgi +++ b/bind8/edit_soptions.cgi @@ -58,34 +58,6 @@ print &address_input($text{'slave_notify2'}, "also-notify", $zconf); print &ui_table_end(); print &ui_form_end([ [ undef, $text{'save'} ] ]); -# Buttons at end of page -print &ui_hr(); -print &ui_buttons_start(); - -# Move to a new view -@views = &find("view", $bconf); -if ($in{'view'} eq '' && @views || $in{'view'} ne '' && @views > 1) { - print &ui_buttons_row("move_zone.cgi", - $text{'master_move'}, - $text{'master_movedesc'}, - &ui_hidden("index", $in{'index'}). - &ui_hidden("view", $in{'view'}), - &ui_select("newview", undef, - map { [ $_->{'index'}, $_->{'view'} ] } - grep { $_->{'index'} ne $in{'view'} } @views)); - } - -# Convert to master zone -if ($access{'master'} && -s &make_chroot($file)) { - print &ui_buttons_row("convert_slave.cgi", - $text{'slave_convert'}, - $text{'slave_convertdesc'}, - &ui_hidden("index", $in{'index'}). - &ui_hidden("view", $in{'view'})); - } - -print &ui_buttons_end(); - &ui_print_footer("edit_slave.cgi?index=$in{'index'}&view=$in{'view'}", $text{'master_return'}); diff --git a/bind8/edit_view.cgi b/bind8/edit_view.cgi index f0808d56a..f8756ad4d 100755 --- a/bind8/edit_view.cgi +++ b/bind8/edit_view.cgi @@ -12,40 +12,39 @@ $access{'views'} || &error($text{'view_ecannot'}); &ui_print_header(undef, $text{'view_title'}, ""); -print "
\n"; -print "\n"; -print "\n"; -print "\n"; -print "
$text{'view_opts'}
\n"; +# Form header +print &ui_form_start("save_view.cgi"); +print &ui_hidden("index", $in{'index'}); +print &ui_table_start($text{'view_opts'}, "width=100%", 4); +# View name @v = @{$view->{'values'}}; -print "\n"; -print "\n"; +print &ui_table_row($text{'view_name'}, "$v[0]"); -print "\n"; -printf "\n", - $v[1] ? "$v[1]" : "$text{'default'} (IN)"; +# Class (not editable) +print &ui_table_row($text{'view_class'}, + $v[1] ? "$v[1]" : "$text{'default'} (IN)"); -print "\n"; print &addr_match_input($text{'view_match'}, "match-clients", $vconf); print &choice_input($text{'view_recursion'}, 'recursion', $vconf, $text{'yes'}, 'yes', $text{'no'}, 'no', $text{'default'}, undef); -print "\n"; -print "
$text{'view_name'}$v[0]$text{'view_class'}%s
\n"; +print &ui_table_end(); + if ($access{'ro'}) { - print "
\n"; + print &ui_form_end(); } else { - print "\n"; + print &ui_form_end([ [ undef, $text{'save'} ] ]); - print "\n"; - print "\n"; - print "\n"; - print "
\n"; - print "
\n"; + # Delete button + print &ui_hr(); + print &ui_buttons_start(); + print &ui_buttons_row("delete_view.cgi", + $text{'view_delete'}, $text{'view_deletemsg'}, + &ui_hidden("index", $in{'index'})); + print &ui_buttons_end(); } &ui_print_footer("", $text{'index_return'}); diff --git a/bind8/index.cgi b/bind8/index.cgi index d1a9e21d6..21d25d642 100755 --- a/bind8/index.cgi +++ b/bind8/index.cgi @@ -71,13 +71,14 @@ $chroot = &get_chroot(); if ($need_create) { print &text('index_eempty', "".&make_chroot($config{'named_conf'}).""),"

\n"; - print "

\n"; - print " $text{'index_local'}

\n"; - print " ", - "$text{'index_download'}

\n"; - print " $text{'index_webmin'}

\n"; - print "

", - "
\n"; + + print &ui_form_start("dns_boot.cgi"); + print &ui_radio("real", 1, + [ [ 0, $text{'index_local'}."
" ], + [ 1, $text{'index_download'}."
" ], + [ 2, $text{'index_webmin'}."
" ] ]); + print &ui_form_end([ [ undef, $text{'index_create'} ] ]); + &ui_print_footer("/", $text{"index"}); exit; } diff --git a/bind8/lang/en b/bind8/lang/en index f2c420de9..c590329d3 100644 --- a/bind8/lang/en +++ b/bind8/lang/en @@ -113,7 +113,7 @@ master_edeletecannot=You are not allowed to delete zones master_etaken=This zone already exists master_include=Additional template file master_noinclude=Just use records above -master_convert=Convert to slave zone +master_convert=Convert to Slave Zone master_convertdesc=Turns this master zone into a slave, so that it will receive records from another master server instead of serving them locally. master_whois=Lookup WHOIS Information master_move=Move to view: @@ -178,7 +178,7 @@ slave_efile=Missing records file slave_efile2='$1' is not an allowable records file slave_mins=minutes slave_master_port=port -slave_convert=Convert to master zone +slave_convert=Convert to Master Zone slave_convertdesc=Click this button to convert this slave zone into a master, with all the records that were last transferred from the original master system. slave_manual=View Records File slave_delmsg=Click this button to delete this zone from your DNS server. The source master zone will be un-touched. @@ -748,10 +748,12 @@ view_class=DNS records class view_match=Apply this view to clients view_recursion=Do full recursive lookups for clients? view_ecannot=You are not allowed to edit this view +view_delete=Delete View +view_deletemsg=Click this button to delete the view. You will have a choice of moving zones it contains to another view, or deleting them as well. vcreate_title=Create Client View vcreate_match_all=All clients -vcreate_match_sel=Selected addresses, networks and ACLs +vcreate_match_sel=Listed addresses, networks and ACLs.. vcreate_err=Failed to create view vcreate_ename=Missing or invalid view name vcreate_etaken=View name is already taken diff --git a/bind8/mass_delete.cgi b/bind8/mass_delete.cgi index 11fbb719f..7673cdb8b 100755 --- a/bind8/mass_delete.cgi +++ b/bind8/mass_delete.cgi @@ -66,8 +66,7 @@ else { # delete the records file $f = &find("file", $zconf->{'members'}); if ($f && $type ne 'hint') { - &lock_file(&make_chroot(&absolute_path($f->{'value'}))); - unlink(&make_chroot(&absolute_path($f->{'value'}))); + &delete_records_file($f->{'value'}); } # remove the zone directive diff --git a/bind8/view_form.cgi b/bind8/view_form.cgi index 4a5a541c4..bbbc84ba4 100755 --- a/bind8/view_form.cgi +++ b/bind8/view_form.cgi @@ -10,28 +10,26 @@ $access{'ro'} && &error($text{'vcreate_ecannot'}); &ui_print_header(undef, $text{'vcreate_title'}, ""); -print "
\n"; -print "\n"; -print "\n"; -print "
$text{'view_opts'}
\n"; +# Form header +print &ui_form_start("create_view.cgi"); +print &ui_table_start($text{'view_opts'}, "width=100%", 4); -print "\n"; -print "\n"; +# View name +print &ui_table_row($text{'view_name'}, + &ui_textbox("name", undef, 25)); -print "\n"; -print "\n"; +# Custom class +print &ui_table_row($text{'view_class'}, + &ui_opt_textbox("class", undef, 4, "$text{'default'} (IN)")); -print "\n"; +# Clients to match +print &ui_table_row($text{'view_match'}, + &ui_radio("match_def", 0, [ [ 1, $text{'vcreate_match_all'} ], + [ 0, $text{'vcreate_match_sel'} ] ])."
". + &ui_textarea("match", undef, 5, 40)); -print "
$text{'view_name'}$text{'view_class'} ", - "$text{'default'}\n"; -print "\n"; -print "
$text{'view_match'} \n"; -print " $text{'vcreate_match_all'}\n"; -print " ", - "$text{'vcreate_match_sel'}
\n"; -print "
\n"; -print "
\n"; +print &ui_table_end(); +print &ui_form_end([ [ undef, $text{'create'} ] ]); &ui_print_footer("", $text{'index_return'});