Fix bugs in new firewall rule editing code

This commit is contained in:
Jamie Cameron 2013-07-10 18:16:40 -07:00
parent aa53122dbd
commit 9e19ff2404
3 changed files with 10 additions and 4 deletions

View File

@ -31,7 +31,7 @@ foreach $f ('table', 'idx', 'new', 'chain', 'before', 'after') {
# Display action section
print &ui_table_start($text{'edit_header1'}, "width=100%", 2);
print &ui_table_row(text{'edit_chain'},
print &ui_table_row($text{'edit_chain'},
$text{"index_chain_".lc($rule->{'chain'})} ||
&text('index_chain', "<tt>$rule->{'chain'}</tt>"));
@ -65,9 +65,11 @@ else {
@jumps = ( undef, 'ACCEPT', 'DROP', 'REJECT', 'QUEUE', 'RETURN', 'LOG' );
}
@grid = ( );
$found = 0;
foreach $j (grep { &can_jump($_) } @jumps) {
push(@grid, &ui_oneradio("jump", $j, $text{"index_jump_".lc($j)},
$rule->{'j'}->[1] eq $j));
$found++ if ($rule->{'j'}->[1] eq $j);
}
push(@grid, &ui_oneradio("jump", "*", $text{'edit_jump_other'}, !$found));
push(@grid, &ui_textbox("other", $found ? "" : $rule->{'j'}->[1], 12));
@ -294,7 +296,7 @@ print &ui_table_row($text{'edit_state'},
"<td>&nbsp;".
&ui_select("state", [ split(/,/, $rule->{'state'}->[1]) ],
[ map { [ $_, $text{"edit_state_".lc($_)} ] }
('NEW', 'ESTABLISHED', 'RELATED', 'INVALID', 'UNTRACKED') ]).
('NEW', 'ESTABLISHED', 'RELATED', 'INVALID', 'UNTRACKED') ], 5, 1).
"</td></tr></table>");
# Type of service
@ -353,7 +355,7 @@ else {
# print_mode(name, &value, [yes-option, no-option], [no-no-option])
sub print_mode
{
local ($name, $value, $yes_opt, $no_opt, $no_no_opt);
local ($name, $value, $yes_opt, $no_opt, $no_no_opt) = @_;
local $m = !$value ? 0 :
$value->[0] eq "!" ? 2 : 1;
return &ui_select($name, $m,
@ -434,6 +436,7 @@ sub protocol_input
{
local ($name, $value) = @_;
local @stdprotos = ( 'tcp', 'udp', 'icmp', undef );
$value ||= "tcp";
local @otherprotos;
open(PROTOS, "/etc/protocols");
while(<PROTOS>) {

View File

@ -32,7 +32,7 @@ index_jump_redirect=Redirect
index_jump_dnat=Destination NAT
index_jump_snat=Source NAT
index_jump_=Do nothing
index_jump=Run chain $1
index_jump=Jump to chain $1
index_radd=Add Rule
index_cdelete=Delete Chain
index_crename=Rename Chain

View File

@ -1391,6 +1391,9 @@ sub ui_buttons_row
{
return &theme_ui_buttons_row(@_) if (defined(&theme_ui_buttons_row));
my ($script, $label, $desc, $hiddens, $after, $before) = @_;
if (ref($hiddens)) {
$hiddens = join("\n", map { &ui_hidden(@$_) } @$hiddens);
}
return "<form action=$script class='ui_buttons_form'>\n".
$hiddens.
"<tr class='ui_buttons_row'> ".