Files
webmin/nftables/move_rule.cgi
Ilia Ross 7f2b4b00aa Fix to scope direct-mode changes to selected tables
Fix nftables direct-mode operations so create, edit, delete, and move actions apply only the selected table instead of rewriting or applying the full ruleset. This avoids copying firewalld-owned rules, or any other externally managed rules, into Webmin’s save file and prevents operations from failing against externally managed tables. Also remove previously added unsafe full-ruleset flush action and keep Apply Configuration out of direct mode (will be further reworked).
2026-05-02 17:08:35 +02:00

41 lines
990 B
Perl
Executable File

#!/usr/bin/perl
# move_rule.cgi
# Move a rule up or down within a chain
require './nftables-lib.pl'; ## no critic
use strict;
use warnings;
our (%in, %text);
ReadParse();
error_setup($text{'move_err'});
my @tables = get_nftables_save();
my $table = $tables[$in{'table'}];
$table || error($text{'move_notable'});
my $chain = $in{'chain'};
$chain || error($text{'move_nochain'});
my $dir = $in{'dir'};
$dir = '' if (!defined($dir));
my $idx = $in{'idx'};
$idx =~ /^\d+$/ || error($text{'move_norule'});
my $rv = move_rule_in_chain($table, $chain, $idx, $dir);
if (!defined($rv)) {
error($text{'move_norule'});
}
if ($rv) {
my $err = save_table_configuration($table, @tables);
error(text('move_failed', $err)) if ($err);
webmin_log("move", "rule", undef,
{ 'table' => $table->{'name'},
'family' => $table->{'family'},
'chain' => $chain,
'dir' => $dir });
}
redirect("index.cgi?table=$in{'table'}");