index_cdelete=Delete Chain
index_cclear=Clear All Rules
index_cdeletesel=Delete Selected
+index_cmovesel=Move Selected
index_cadd=Add a new chain named:
index_apply=Apply Configuration
index_applydesc=Click this button to make the firewall configuration listed above active. Any firewall rules currently in effect will be flushed and replaced
log_create_chain=Created chain $1 in table $2
log_modify_chain=Set default action for chain $1 in table $2
log_delsel_chain=Deleted $3 rules from chain $1 in table $2
+log_movesel_chain=Moved $3 rules from chain $1 in table $2
log_apply=Applied configuration
log_unapply=Reverted configuration
log_setup=Set up firewall
policy_ecannot=You are not allowed to change the default policy for this chain
+move_title=Move Rules
+move_count=Rules selected
+move_chain=Current change
+move_dest=Destination chain
+move_ok=Move Now
+move_header=Rule move options
@tables = &get_iptables_save();
$table = $tables[$in{'table'}];
&can_edit_table($table->{'name'}) || &error($text{'etable'});
+@d = split(/\0/, $in{'d'});
if ($in{'add'}) {
# Redirect to the rule page for adding a rule
}
elsif ($in{'delsel'}) {
# Just delete selected rules
- %idxs = map { $_, 1 } split(/\0/, $in{'d'});
+ %idxs = map { $_, 1 } @d;
&lock_file($iptables_save_file);
$table->{'rules'} = [ grep { $_->{'chain'} ne $in{'chain'} ||
!$idxs{$_->{'index'}} }
&unlock_file($iptables_save_file);
&webmin_log("delsel", "chain", undef, { 'chain' => $in{'chain'},
'table' => $table->{'name'},
- 'count' => scalar(keys %idxs)});
+ 'count' => scalar(@d)});
&redirect("index.cgi?table=$in{'table'}");
+ }
+elsif ($in{'movesel'} && $in{'dest'}) {
+ # Move selected rules to new chain
+ %idxs = map { $_, 1 } @d;
+ &lock_file($iptables_save_file);
+
+ # Change the chain on each rule
+ foreach $r (@{$table->{'rules'}}) {
+ if ($r->{'chain'} eq $in{'chain'} && $idxs{$r->{'index'}}) {
+ $r->{'chain'} = $in{'dest'};
+ }
+ }
+ &run_before_command();
+ &save_table($table);
+ &run_after_command();
+ ©_to_cluster();
+ &unlock_file($iptables_save_file);
+ &webmin_log("movesel", "chain", undef, { 'chain' => $in{'chain'},
+ 'table' => $table->{'name'},
+ 'count' => scalar(@d)});
+ &redirect("index.cgi?table=$in{'table'}");
+ }
+elsif ($in{'movesel'}) {
+ # Show rule move form
+ &ui_print_header(undef, $text{'move_title'}, "");
+
+ print &ui_form_start("save_policy.cgi");
+ print &ui_hidden("table", $in{'table'});
+ print &ui_hidden("chain", $in{'chain'});
+ print &ui_hidden("movesel", 1);
+ foreach $d (@d) {
+ print &ui_hidden("d", $d);
+ }
+ print &ui_table_start($text{'move_header'}, undef, 2);
+
+ # Number of rules and source
+ print &ui_table_row($text{'move_count'}, scalar(@d));
+ print &ui_table_row($text{'move_chain'}, $in{'chain'});
+
+ # Destination chain
+ print &ui_table_row($text{'move_dest'},
+ &ui_select("dest", $in{'chain'},
+ [ grep { $_ ne $in{'chain'} }
+ sort by_string_for_iptables
+ (keys %{$table->{'defaults'}}) ]));
+
+ print &ui_table_end();
+ print &ui_form_end([ [ undef, $text{'move_ok'} ] ]);
+
+ &ui_print_footer("index.cgi?table=$in{'table'}", $text{'index_return'});
}
else {
# Change the default for this chain