Files
webmin/nftables/delete_table.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

54 lines
1.6 KiB
Perl
Executable File

#!/usr/bin/perl
# delete_table.cgi
# Delete an existing nftables table
require './nftables-lib.pl'; ## no critic
use strict;
use warnings;
our (%in, %text);
ReadParse();
error_setup($text{'delete_err'});
my @tables = get_nftables_save();
my $table_idx = $in{'table'};
my $table;
if (defined($in{'table_family'}) && defined($in{'table_name'})) {
for (my $i = 0; $i <= $#tables; $i++) {
if ($tables[$i]->{'family'} eq $in{'table_family'} &&
$tables[$i]->{'name'} eq $in{'table_name'}) {
$table_idx = $i;
$table = $tables[$i];
last;
}
}
$table || error($text{'delete_notable'});
}
else {
$table = $tables[$table_idx];
}
$table || error($text{'delete_notable'});
if ($in{'confirm'}) {
splice(@tables, $table_idx, 1);
my $err = delete_table_configuration($table, @tables);
error(text('delete_failed', $err)) if ($err);
webmin_log("delete", "table", $table->{'name'},
{ 'family' => $table->{'family'} });
redirect("index.cgi");
}
ui_print_header(undef, $text{'delete_title'}, "", "intro", 1, 1);
print ui_form_start("delete_table.cgi");
print ui_hidden("table", $table_idx);
print ui_hidden("table_family", $table->{'family'});
print ui_hidden("table_name", $table->{'name'});
print "<center><b>",
text('delete_confirm',
"<tt>$table->{'family'} $table->{'name'}</tt>"),
"</b><p>\n";
print ui_submit($text{'delete'}, "confirm");
print "</center>\n";
print ui_form_end();
ui_print_footer("index.cgi?table_family=".urlize($table->{'family'}).
"&table_name=".urlize($table->{'name'}), $text{'index_return'});