diff --git a/nftables/config.info b/nftables/config.info index 028d9adfd..bf6c69a9c 100644 --- a/nftables/config.info +++ b/nftables/config.info @@ -1,4 +1,4 @@ -line0=Configurable global options,11 +nft_cmd=Full path to nft command,0 perpage=Number of rules to display per page,3,Default (50) view_condition=Display condition in rules list?,1,1-Yes,0-No view_comment=Display comment in rules list?,1,1-Yes,0-No @@ -6,6 +6,3 @@ before_cmd=Command to run before changing rules,3,None after_cmd=Command to run after changing rules,3,None before_apply_cmd=Command to run before applying configuration,3,None after_apply_cmd=Command to run after applying configuration,3,None -line2=nftables configuration,11 -nft_cmd=Full path to nft command,0 -save_file=File to save/edit nftables rules,3,Use operating system or Webmin default diff --git a/nftables/install_check.pl b/nftables/install_check.pl index 87ae0fd1d..0f2ef1bab 100644 --- a/nftables/install_check.pl +++ b/nftables/install_check.pl @@ -16,8 +16,7 @@ sub is_installed my ($mode) = @_; return 0 if (&check_nftables()); if ($mode) { - my $file = $config{'save_file'} || - "$module_config_directory/rules.conf"; + my $file = nftables_rules_file(); return 1 if (!-s $file); return 2; } diff --git a/nftables/nftables-lib.pl b/nftables/nftables-lib.pl index ce6bbd7ad..e08ae97fc 100644 --- a/nftables/nftables-lib.pl +++ b/nftables/nftables-lib.pl @@ -174,13 +174,19 @@ return undef if (get_nft_command()); return text('index_ecommand', "nft"); } +# nftables_rules_file() +# Returns the Webmin-managed nftables rules file +sub nftables_rules_file +{ +return "$module_config_directory/rules.conf"; +} + # get_nftables_config_files() # Returns files that can be manually edited by this module sub get_nftables_config_files { my @files; -my $file = $config{'save_file'} || "$module_config_directory/rules.conf"; -push(@files, $file) if ($file && $file !~ /\|\s*$/); +push(@files, nftables_rules_file()); foreach my $sysfile ("/etc/nftables.conf", "/etc/sysconfig/nftables.conf") { push(@files, $sysfile) if (-f $sysfile); @@ -225,7 +231,7 @@ sub get_nftables_save { my ($file) = @_; if (!$file) { - $file = $config{'save_file'} || "$module_config_directory/rules.conf"; + $file = nftables_rules_file(); } return ( ) if (!$file); return ( ) if ($file !~ /\|\s*$/ && !-r $file); @@ -1480,7 +1486,7 @@ sub write_configuration { my (@tables) = @_; my $out = dump_nftables_save(@tables); -my $file = $config{'save_file'} || "$module_config_directory/rules.conf"; +my $file = nftables_rules_file(); open_lock_tempfile(my $fh, ">$file"); print_tempfile($fh, $out); @@ -1543,7 +1549,7 @@ return; sub apply_restore { my ($file) = @_; -$file ||= $config{'save_file'} || "$module_config_directory/rules.conf"; +$file ||= nftables_rules_file(); my $cmd = get_nft_command(); return text('index_ecommand', "nft") if (!$cmd);