diff --git a/shorewall/check.cgi b/shorewall/check.cgi index b9e180f77..98e067d1b 100755 --- a/shorewall/check.cgi +++ b/shorewall/check.cgi @@ -9,13 +9,13 @@ require './shorewall-lib.pl'; &ui_print_header(undef, $text{'check_title'}, ""); print "$text{'check_cmd'}
\n"; -print "
";
+print "
";
 open(STATUS, "$config{'shorewall'} check 2>&1 |");
 while() {
 	print &html_escape($_);
 	}
 close(STATUS);
-print "
\n"; +print "
\n"; if ($?) { print "$text{'check_failed'}

\n"; } diff --git a/shorewall/dump.cgi b/shorewall/dump.cgi index f3f687259..598873190 100755 --- a/shorewall/dump.cgi +++ b/shorewall/dump.cgi @@ -5,13 +5,13 @@ require './shorewall-lib.pl'; &ui_print_header(undef, $text{'dump_title'}, ""); -print "

";
+print "
";
 open(DUMP, "$config{'shorewall'} dump 2>&1 |");
 while() {
 	print &html_escape($_);
 	}
 close(DUMP);
-print "
\n"; +print "
\n"; &ui_print_footer("", $text{'index_return'}); diff --git a/shorewall/edit.cgi b/shorewall/edit.cgi index aa7fea0f9..23bac0cd9 100755 --- a/shorewall/edit.cgi +++ b/shorewall/edit.cgi @@ -7,14 +7,14 @@ require './shorewall-lib.pl'; &get_clean_table_name(\%in); &can_access($in{'table'}) || &error($text{'list_ecannot'}); if ($in{'new'}) { - &ui_print_header(undef, $text{$in{'tableclean'}."_create"}, ""); + # Show where the new entry will be inserted, if not at the end if ($in{'before'} ne '') { $msg = &text('edit_before', $in{'before'}+1); } elsif ($in{'after'} ne '') { $msg = &text('edit_after', $in{'after'}+1); } - print "
$msg
\n" if ($msg); + &ui_print_header($msg, $text{$in{'tableclean'}."_create"}, ""); } else { &ui_print_header(undef, $text{$in{'tableclean'}."_edit"}, ""); diff --git a/shorewall/shorewall-lib.pl b/shorewall/shorewall-lib.pl index 47030720e..d8bc7e3d4 100755 --- a/shorewall/shorewall-lib.pl +++ b/shorewall/shorewall-lib.pl @@ -428,7 +428,16 @@ if ($other) { elsif (!$found) { push(@opts, [ $value, $value ]); } -my $sel = &ui_select($name, $value, \@opts); +my $selv = $value; +if ($other && !$found) { + # Value is not in the list, so select the Other.. option + $selv = ''; + } +elsif ($value eq '' && @opts) { + # New entry, so select the first option + $selv = $opts[0]->[0]; + } +my $sel = &ui_select($name, $selv, \@opts); return wantarray ? ($sel, $found) : $sel; } @@ -764,7 +773,7 @@ $zf = &zone_field("dest", $_[1], 0); print &ui_table_row($text{'policy_1'}, $zf); print &ui_table_row($text{'policy_2'}, - &ui_select("policy", uc($_[2]), \@policy_list, 1, 0, 1)); + &ui_select("policy", uc($_[2]), \@policy_list, 1, 0, $_[2] ? 1 : 0)); &foreign_require("syslog"); print &ui_table_row($text{'policy_3'}, @@ -838,145 +847,106 @@ our @rules_protos = ( 'all', 'related', 'tcp', 'udp', 'icmp' ); sub rules_form { -local $found; -local @ztable = &read_table_file("zones", \&zones_parser); - -local ($action, $log) = split(/:/, $_[0]); -local $macroarg; +my ($action, $log) = split(/:/, $_[0]); +my $macroarg; if ($action =~ /^(.*)\/(.*)$/) { $action = $1; $macroarg = $2; } -# Rule action -print " $text{'rules_0'}\n"; -print "\n"; - -# Logging level -print "$text{'rules_log'} \n"; +# Rule action and logging level +my @aopts = ( (sort { $a cmp $b } @rules_actions), + "-------- Actions --------", + &list_standard_actions(), + (&version_atleast(3) ? ( "-------- Macros --------", + &list_standard_macros() ) : ( ) ) ); +&foreign_require("syslog"); +print &ui_table_row($text{'rules_0'}, + &ui_select("action", $action, \@aopts, 1, 0, $action ? 1 : 0)." ". + "$text{'rules_log'} ". + &ui_select("log", $log, + [ [ '', "<$text{'rules_nolog'}>" ], + [ 'ULOG', "<$text{'policy_ulog'}>" ], + &syslog::list_priorities() ], 1, 0, $log ? 1 : 0), + 3); +# Macro parameter if (&version_atleast(3)) { - print " $text{'rules_macro'}\n"; - print "\n"; - print &ui_select("macro", $macroarg, - [ [ "", "<$text{'rules_none2'}>" ], - map { [ $_ ] } (sort { $a cmp $b } @rules_actions) ], - 1, 0, $macroarg); - print " \n"; + print &ui_table_row($text{'rules_macro'}, + &ui_select("macro", $macroarg, + [ [ "", "<$text{'rules_none2'}>" ], + map { [ $_ ] } (sort { $a cmp $b } @rules_actions) ], + 1, 0, $macroarg ? 1 : 0), + 3); } # Source zone and hosts -local ($zone, $host) = split(/:/, $_[1], 2); -print " $text{'rules_1z'}\n"; -print "\n"; +my ($zone, $host) = split(/:/, $_[1], 2); my ($zf, $found) = &zone_field("source", $zone, 1); -print $zf; -printf "\n", - $found ? "" : $zone; - -print "
$text{'rules_inzone'}\n"; -printf " %s\n", - $host ? "checked" : "", $text{'rules_addr'}; -printf " \n", - join(" ", split(/,/, $host)); +print &ui_table_row($text{'rules_1z'}, + $zf." ". + &ui_textbox("sother", $found ? "" : $zone, 10)."
\n". + &ui_checkbox("sinzone_def", 1, $text{'rules_addr'}, $host ? 1 : 0)." ". + &ui_textbox("sinzone", join(" ", split(/,/, $host)), 50), + 3); +# Destination zone and hosts ($zone, $host) = split(/:/, $_[2], 2); -print " $text{'rules_2z'}\n"; -print "\n"; ($zf, $found) = &zone_field("dest", $zone, 1); -print $zf; -printf "\n", - $found ? "" : $zone; +print &ui_table_row($text{'rules_2z'}, + $zf." ". + &ui_textbox("dother", $found ? "" : $zone, 10)."
\n". + &ui_checkbox("dinzone_def", 1, $text{'rules_addr'}, $host ? 1 : 0)." ". + &ui_textbox("dinzone", join(" ", split(/,/, $host)), 50)."
\n". + $text{'rules_dnat_dest'}, + 3); -print "
$text{'rules_inzone'}\n"; -printf " %s\n", - $host ? "checked" : "", $text{'rules_addr'}; -printf "\n", - join(" ", split(/,/, $host)); -print "
$text{'rules_dnat_dest'} \n"; - -print " $text{'rules_3'}\n"; -print "\n"; -printf " \n", - $found ? "" : $_[3]; +push(@popts, [ '', $text{'list_other'} ]); +print &ui_table_row($text{'rules_3'}, + &ui_select("proto", $found ? ($_[3] || 'all') : '', \@popts)." ". + &ui_textbox("pother", $found ? "" : $_[3], 5), + 3); -print " $text{'rules_4'} \n"; -printf " %s\n", - $_[5] eq '' || $_[5] eq '-' ? "checked" : "", $text{'list_any'}; -printf " %s\n", - $_[5] eq '' || $_[5] eq '-' ? "" : "checked", $text{'rules_ranges'}; -printf " \n", - $_[5] eq '' || $_[5] eq '-' ? "" : join(" ", split(/,/, $_[5])); +# Source and destination ports +print &ui_table_row($text{'rules_4'}, + &ui_opt_textbox("sport", + $_[5] eq '-' ? '' : join(" ", split(/,/, $_[5])), + 30, $text{'list_any'}, $text{'rules_ranges'}), + 3); -print " $text{'rules_5'} \n"; -printf " %s\n", - $_[4] eq '' || $_[4] eq '-' ? "checked" : "", $text{'list_any'}; -printf " %s\n", - $_[4] eq '' || $_[4] eq '-' ? "" : "checked", $text{'rules_ranges'}; -printf "\n", - $_[4] eq '' || $_[4] eq '-' ? "" : join(" ", split(/,/, $_[4])); -print "
$text{'rules_dnat_port'} \n"; +print &ui_table_row($text{'rules_5'}, + &ui_opt_textbox("dport", + $_[4] eq '-' ? '' : join(" ", split(/,/, $_[4])), + 30, $text{'list_any'}, $text{'rules_ranges'})."
\n". + $text{'rules_dnat_port'}, + 3); -print " $text{'rules_dnat'} \n"; -printf " %s\n", - $_[6] eq '' || $_[6] eq '-' ? "checked" : "", $text{'list_none'}; -printf "\n", - $_[6] eq '' || $_[6] eq '-' ? "" : "checked"; -printf " \n", - $_[6] eq '' || $_[6] eq '-' ? "" : $_[6]; +# Original destination for DNAT or REDIRECT +print &ui_table_row($text{'rules_dnat'}, + &ui_opt_textbox("dnat", $_[6] eq '-' ? '' : $_[6], 30, + $text{'list_none'}), + 3); +# Rate limit and user set if (&version_atleast(1, 4, 7)) { - print " $text{'rules_rate'} \n"; - printf " %s\n", - $_[7] eq "-" || !$_[7] ? "checked" : "", $text{'rules_norate'}; - printf "\n", - $_[7] eq "-" || !$_[7] ? "" : "checked"; - printf " \n", - $_[7] eq "-" ? "" : $_[7]; + print &ui_table_row($text{'rules_rate'}, + &ui_opt_textbox("rate", $_[7] eq '-' ? '' : $_[7], 15, + $text{'rules_norate'}), + 3); - print " $text{'rules_set'} \n"; - printf " %s\n", - $_[8] eq "-" || !$_[8] ? "checked" : "", $text{'rules_noset'}; - printf "\n", - $_[8] eq "-" || !$_[8] ? "" : "checked"; - printf " \n", - $_[8] eq "-" ? "" : $_[8]; + print &ui_table_row($text{'rules_set'}, + &ui_opt_textbox("set", $_[8] eq '-' ? '' : $_[8], 15, + $text{'rules_noset'}), + 3); } } @@ -1086,14 +1056,14 @@ print &ui_table_row($text{'tos_1z'}, 3); my @opts; -my $found = !$_[2]; +$found = !$_[2]; foreach my $p (@tos_protos) { push(@opts, [ $p, uc($p) ]); $found++ if ($p eq $_[2]); } push(@opts, [ '', $text{'list_other'} ]); print &ui_table_row($text{'tos_2'}, - &ui_select("proto", $found ? $_[2] : '', \@opts)." ". + &ui_select("proto", $found ? ($_[2] || $tos_protos[0]) : '', \@opts)." ". &ui_textbox("pother", $found ? "" : $_[2], 5)); print &ui_table_row($text{'tos_3'}, @@ -1616,7 +1586,7 @@ foreach my $o (@providers_opts) { delete($opts{$o}); } foreach my $o (keys %opts) { - $ofield .= &ui_hidden("opts", $o),"\n"; + $ofield .= &ui_hidden("opts", $o)."\n"; } print &ui_table_row($text{'providers_opts'}, $ofield); diff --git a/shorewall/status.cgi b/shorewall/status.cgi index c024e2538..bf4d31bbd 100755 --- a/shorewall/status.cgi +++ b/shorewall/status.cgi @@ -4,12 +4,12 @@ require './shorewall-lib.pl'; &ui_print_header(undef, $text{'status_title'}, ""); -print "
";
+print "
";
 open(STATUS, "$config{'shorewall'} status 2>&1 |");
 while() {
 	print &html_escape($_);
 	}
 close(STATUS);
-print "
\n"; +print "
\n"; &ui_print_footer("", $text{'index_return'});