mirror of
https://github.com/webmin/webmin.git
synced 2026-05-06 15:20:29 +01:00
Fix to factor out command check
This commit is contained in:
@@ -13,7 +13,7 @@ if (!$partial) {
|
||||
}
|
||||
|
||||
# Check for nft command
|
||||
my $cmd = $config{'nft_cmd'} || has_command("nft");
|
||||
my $cmd = get_nft_command();
|
||||
if (!$cmd) {
|
||||
print text('index_ecommand', "<tt>nft</tt>");
|
||||
if (!$partial) {
|
||||
|
||||
@@ -8,12 +8,21 @@ use warnings;
|
||||
our (%config, $module_config_directory);
|
||||
init_config();
|
||||
|
||||
# get_nft_command()
|
||||
# Returns the configured nft command path, or finds it in PATH
|
||||
sub get_nft_command
|
||||
{
|
||||
my $cmd = $config{'nft_cmd'} || "nft";
|
||||
return has_command($cmd);
|
||||
}
|
||||
|
||||
|
||||
# get_nftables_save([file])
|
||||
# Returns a list of tables and their chains/rules
|
||||
sub get_nftables_save
|
||||
{
|
||||
my ($file) = @_;
|
||||
my $cmd = $config{'nft_cmd'} || has_command("nft");
|
||||
my $cmd = get_nft_command();
|
||||
if (!$file) {
|
||||
if ($config{'direct'}) {
|
||||
$file = "$cmd list ruleset |";
|
||||
@@ -1017,7 +1026,8 @@ sub apply_restore
|
||||
{
|
||||
my ($file) = @_;
|
||||
$file ||= $config{'save_file'} || "$module_config_directory/nftables.conf";
|
||||
my $cmd = $config{'nft_cmd'} || has_command("nft");
|
||||
my $cmd = get_nft_command();
|
||||
return text('index_ecommand', "<tt>nft</tt>") if (!$cmd);
|
||||
my $out = backquote_logged("$cmd -f $file 2>&1");
|
||||
if ($?) {
|
||||
return "<pre>$out</pre>";
|
||||
|
||||
@@ -161,7 +161,7 @@ if ($in{'delete'}) {
|
||||
}
|
||||
|
||||
if ($in{'edit_direct'}) {
|
||||
my $cmd = $config{'nft_cmd'} || has_command("nft");
|
||||
my $cmd = get_nft_command();
|
||||
if ($cmd) {
|
||||
my $tmp = tempname();
|
||||
open_tempfile(my $fh, ">$tmp");
|
||||
|
||||
Reference in New Issue
Block a user