diff --git a/delete_jail.cgi b/delete_jail.cgi index 7005feb..5d98a28 100644 --- a/delete_jail.cgi +++ b/delete_jail.cgi @@ -7,7 +7,7 @@ require './jailkit-lib.pl'; ReadParse(); my $jk_init_ini = get_jk_init_ini(); -my @sections = $jk_init_ini->Sections(); +my @sections = $jk_init_ini->Sections(); my %jail_params; my @d = split(/\0/, $in{'d'}); @@ -20,7 +20,7 @@ if (defined $in{'confirmed'}) { } else { # Does this jail exist? - error( text('error_jail_not_found', "$jail", "
\n")); + error(text('error_jail_not_found', "$jail", "
\n")); } } write_jk_init_ini($jk_init_ini); @@ -33,6 +33,7 @@ else { # Check to be sure we really want these jails gone print ui_form_start("delete_jail.cgi", "post"); foreach my $jail (@d) { + # Re-send all of the d_* items with a confirmed field print ui_hidden("d", $jail); } @@ -45,8 +46,9 @@ else { print "

\n"; print ui_hidden("confirmed", "1"); + #print ui_submit($text{delete_confirm}, "confirm"); - print ui_form_end([ [ "confirm", $text{'delete_confirm'} ] ]); + print ui_form_end([["confirm", $text{'delete_confirm'}]]); print "\n"; ui_print_footer(""); } diff --git a/edit_jail.cgi b/edit_jail.cgi index b6ed5d6..dffb71f 100644 --- a/edit_jail.cgi +++ b/edit_jail.cgi @@ -7,24 +7,26 @@ require './jailkit-lib.pl'; ReadParse(); my $jk_init_ini = get_jk_init_ini(); -my @sections = $jk_init_ini->Sections(); +my @sections = $jk_init_ini->Sections(); my %jail_params; # Make a new section? -if($in{'new'}) { +if ($in{'new'}) { ui_print_header(undef, $text{'index_create_jail'}, '', 'create_jail'); + # Keep new defined so we add a new section on save print ui_hidden("new", $in{'new'}); } else { ui_print_header(undef, $text{'index_edit_jail'}, '', 'edit_jail'); - unless ( $jk_init_ini->SectionExists( $in{'jail'} )) { - error( $text{'edit_jail_not_found'} ); - }; + unless ($jk_init_ini->SectionExists($in{'jail'})) { + error($text{'edit_jail_not_found'}); + } + # Populate the jail hash - my @params = $jk_init_ini->Parameters( $in{'jail'} ); - foreach my $param (@params){ - $jail_params{$param} = $jk_init_ini->val( $in{'jail'}, $param ); + my @params = $jk_init_ini->Parameters($in{'jail'}); + foreach my $param (@params) { + $jail_params{$param} = $jk_init_ini->val($in{'jail'}, $param); } } @@ -32,41 +34,68 @@ print ui_form_start("save_jail.cgi"); print ui_hidden("orig_jail", $in{'jail'}); print ui_ -print ui_hidden_table_start($text{'edit_jail_metadata'}, undef, 1, 'metadata', 1); + print ui_hidden_table_start($text{'edit_jail_metadata'}, undef, 1, + 'metadata', 1); + # name -print ui_table_row( hlink($text{'edit_jail_name'}, 'name'), +print ui_table_row(hlink($text{'edit_jail_name'}, 'name'), ui_textbox('jail', $in{'jail'})); + # comment/description -print ui_table_row( hlink($text{'edit_jail_comment'}, 'comment'), - ui_textbox('comment', $jail_params{'comment'})); +print ui_table_row( + hlink($text{'edit_jail_comment'}, 'comment'), + ui_textbox('comment', $jail_params{'comment'}) +); print ui_hidden_table_end('metadata'); -print ui_hidden_table_start($text{'edit_jail_includes'}, undef, 1, 'includes', 1); +print ui_hidden_table_start($text{'edit_jail_includes'}, undef, 1, 'includes', + 1); + # paths -print ui_table_row( hlink($text{'edit_jail_paths'}, 'paths'), - ui_textarea('paths', $jail_params{'paths'})); -print ui_table_row( hlink($text{'edit_jail_paths_w_owner'}, 'paths_w_owner'), - ui_textarea('paths_w_owner', $jail_params{'paths_w_owner'})); -print ui_table_row( hlink($text{'edit_jail_paths_w_setuid'}, 'paths_w_setuid'), - ui_textarea('paths_w_setuid', $jail_params{'paths_w_setuid'})); -print ui_table_row( hlink($text{'edit_jail_includesections'}, 'includesections'), - ui_textarea('includesections'), $jail_params{'includesections'}); -print ui_table_row( hlink($text{'edit_jail_emptydirs'}, 'emptydirs'), - ui_textarea('emptydirs', $jail_params{'emptydirs'})); -print ui_table_row( hlink($text{'edit_jail_devices'}, 'devices'), - ui_textbox('devices', $jail_params{'devices'})); -print ui_table_row( hlink($text{'edit_jail_need_logsocket'}, 'need_logsocket'), - ui_checkbox('need_logsocket', 1, - undef, $jail_params{'need_logsocket'} ? 1 : 0)); +print ui_table_row( + hlink($text{'edit_jail_paths'}, 'paths'), + ui_textarea('paths', $jail_params{'paths'}) +); +print ui_table_row( + hlink($text{'edit_jail_paths_w_owner'}, 'paths_w_owner'), + ui_textarea('paths_w_owner', $jail_params{'paths_w_owner'}) +); +print ui_table_row( + hlink($text{'edit_jail_paths_w_setuid'}, 'paths_w_setuid'), + ui_textarea('paths_w_setuid', $jail_params{'paths_w_setuid'}) +); +print ui_table_row( + hlink($text{'edit_jail_includesections'}, 'includesections'), + ui_textarea('includesections'), + $jail_params{'includesections'} +); +print ui_table_row( + hlink($text{'edit_jail_emptydirs'}, 'emptydirs'), + ui_textarea('emptydirs', $jail_params{'emptydirs'}) +); +print ui_table_row( + hlink($text{'edit_jail_devices'}, 'devices'), + ui_textbox('devices', $jail_params{'devices'}) +); +print ui_table_row( + hlink($text{'edit_jail_need_logsocket'}, 'need_logsocket'), + ui_checkbox( + 'need_logsocket', 1, undef, $jail_params{'need_logsocket'} ? 1 : 0 + ) +); print ui_hidden_table_end('includes'); print ui_hidden_table_start($text{'edit_jail_ug'}, undef, 1, 'usergroups', 1); -print ui_table_row( hlink($text{'edit_jail_users'}, 'users'), - ui_textarea('users', $jail_params{'users'})); -print ui_table_row( hlink($text{'edit_jail_groups'}, 'groups'), - ui_textarea('groups', $jail_params{'groups'})); +print ui_table_row( + hlink($text{'edit_jail_users'}, 'users'), + ui_textarea('users', $jail_params{'users'}) +); +print ui_table_row( + hlink($text{'edit_jail_groups'}, 'groups'), + ui_textarea('groups', $jail_params{'groups'}) +); print ui_hidden_table_end('usergroups'); -print ui_form_end([ [undef, $text{'save_jail'}] ]); +print ui_form_end([[undef, $text{'save_jail'}]]); &ui_print_footer("index.cgi", $text{'edit_jail_return'}); diff --git a/index.cgi b/index.cgi index d3c2778..f2fa355 100644 --- a/index.cgi +++ b/index.cgi @@ -11,44 +11,34 @@ my $jk_init_ini = get_jk_init_ini(); my @sections = $jk_init_ini->Sections(); -ui_print_header(undef, $text{'index_title'}, "", "index", 1, 1, 0, - undef, undef, undef, undef); +ui_print_header(undef, $text{'index_title'}, "", "index", 1, 1, 0, undef, + undef, undef, undef); my @table; foreach my $jail (@sections) { - push(@table, [ - { 'type' => 'checkbox', 'name' => 'd', 'value' => $jail }, - "".&html_escape($jail)."", - $jk_init_ini->val("$jail", 'comment') - ]); + push( + @table, + [ + {'type' => 'checkbox', 'name' => 'd', 'value' => $jail}, + "" . &html_escape($jail) . "", + $jk_init_ini->val("$jail", 'comment') + ] + ); } my @buttons; -push(@buttons, [ - [ "delete", $text{'index_delete_jail'} ] -]); +push(@buttons, [["delete", $text{'index_delete_jail'}]]); my @actions; -push(@actions, [ - [ "edit_jail.cgi?new=1", $text{'index_create_jail'} ] -]); +push(@actions, [["edit_jail.cgi?new=1", $text{'index_create_jail'}]]); #use Data::Dumper; #print "\n"; print ui_form_columns_table( - 'delete_jail.cgi', - @buttons, - 1, - @actions, - undef, - [ $text{'index_delete'}, $text{'index_jail_id'}, $text{'index_comment'} ], - undef, - \@table, - undef, - 1, - $text{'index_jail_list'}, - $text{'index_no_jails'} + 'delete_jail.cgi', @buttons, 1, @actions, undef, + [$text{'index_delete'}, $text{'index_jail_id'}, $text{'index_comment'}], + undef, \@table, undef, 1, $text{'index_jail_list'}, $text{'index_no_jails'} ); ui_print_footer(""); diff --git a/save_jail.cgi b/save_jail.cgi index 58f9e3f..f6b5eff 100644 --- a/save_jail.cgi +++ b/save_jail.cgi @@ -10,48 +10,60 @@ our %text; require './jailkit-lib.pl'; my $jk_init_ini = get_jk_init_ini(); -my @sections = $jk_init_ini->Sections(); +my @sections = $jk_init_ini->Sections(); my %jail_params; ReadParse(); # If new, create a new section if (defined $in{'new'}) { - if ( $jk_init_ini->SectionExists( $in{'jail'} )) { - error( $text{'error_jail_exists'} ); - } - $jk_init_ini->AddSection( $in{'jail'} ); + if ($jk_init_ini->SectionExists($in{'jail'})) { + error($text{'error_jail_exists'}); + } + $jk_init_ini->AddSection($in{'jail'}); } else { - # Not new, make sure we update the name of the jail, if - # changed - if ( defined($in{'orig_jail'}) && defined($in{'jail'}) && - $in{'orig_jail'} ne $in{'jail'} ) { - $jk_init_ini->DeleteSection($in{'orig_jail'}); - $jk_init_ini->AddSection( $in{'jail'}); - } + # Not new, make sure we update the name of the jail, if + # changed + if ( defined($in{'orig_jail'}) + && defined($in{'jail'}) + && $in{'orig_jail'} ne $in{'jail'}) + { + $jk_init_ini->DeleteSection($in{'orig_jail'}); + $jk_init_ini->AddSection($in{'jail'}); + } } -if (length $in{'comment'}) { $jk_init_ini->newval($in{'jail'}, - 'comment', $in{'comment'}); } -if (length $in{'paths'}) { $jk_init_ini->newval($in{'jail'}, - 'paths', $in{'paths'}); } -if (length $in{'paths_w_owner'}) { $jk_init_ini->newval($in{'jail'}, - 'paths_w_owner', $in{'paths_w_owner'}); } -if (length $in{'paths_w_setuid'}) { $jk_init_ini->newval($in{'jail'}, - 'paths_w_setuid', $in{'paths_w_setuid'}); } -if (length $in{'users'}) { $jk_init_ini->newval($in{'jail'}, - 'users', $in{'users'}); } -if (length $in{'groups'}) { $jk_init_ini->newval($in{'jail'}, - 'groups', $in{'groups'}); } -if (length $in{'need_logsocket'}) { $jk_init_ini->newval($in{'jail'}, - 'need_logsocket', $in{'need_logsocket'}); } -if (length $in{'devices'}) { $jk_init_ini->newval($in{'jail'}, - 'devices', $in{'devices'}); } -if (length $in{'includesections'}) { $jk_init_ini->newval($in{'jail'}, - 'includesections', $in{'includesections'}); } -if (length $in{'emptydirs'}) { $jk_init_ini->newval($in{'jail'}, - 'emptydirs', $in{'emptydirs'}); } +if (length $in{'comment'}) { + $jk_init_ini->newval($in{'jail'}, 'comment', $in{'comment'}); +} +if (length $in{'paths'}) { + $jk_init_ini->newval($in{'jail'}, 'paths', $in{'paths'}); +} +if (length $in{'paths_w_owner'}) { + $jk_init_ini->newval($in{'jail'}, 'paths_w_owner', $in{'paths_w_owner'}); +} +if (length $in{'paths_w_setuid'}) { + $jk_init_ini->newval($in{'jail'}, 'paths_w_setuid', $in{'paths_w_setuid'}); +} +if (length $in{'users'}) { + $jk_init_ini->newval($in{'jail'}, 'users', $in{'users'}); +} +if (length $in{'groups'}) { + $jk_init_ini->newval($in{'jail'}, 'groups', $in{'groups'}); +} +if (length $in{'need_logsocket'}) { + $jk_init_ini->newval($in{'jail'}, 'need_logsocket', $in{'need_logsocket'}); +} +if (length $in{'devices'}) { + $jk_init_ini->newval($in{'jail'}, 'devices', $in{'devices'}); +} +if (length $in{'includesections'}) { + $jk_init_ini->newval($in{'jail'}, 'includesections', $in{'includesections'}); +} +if (length $in{'emptydirs'}) { + $jk_init_ini->newval($in{'jail'}, 'emptydirs', $in{'emptydirs'}); +} # Contributors #if (defined $in{'contributors'}) {