From a2bb0173b614a3969af95be5e6f7c480b9daeb71 Mon Sep 17 00:00:00 2001 From: TheBeardedQuack Date: Wed, 20 Dec 2023 13:12:20 +0000 Subject: [PATCH] Made iptables-save logic, match the iptables-restore logic. --- firewall/firewall-lib.pl | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/firewall/firewall-lib.pl b/firewall/firewall-lib.pl index 4e81fca28..c67003f7b 100755 --- a/firewall/firewall-lib.pl +++ b/firewall/firewall-lib.pl @@ -407,13 +407,18 @@ local $out = &backquote_logged("cd / && $rcmd <$ipvx_save 2>&1"); return $? ? "
$out
" : undef; } +sub iptables_save_command +{ +return &has_command("ip${ipvx}tables-legacy-save") || + &has_command("ip${ipvx}tables-save"); +} + # iptables_save() # Saves the active firewall rules, and returns any error sub iptables_save { -local $scmd = &has_command("ip${ipvx}tables-legacy-save") || - "ip${ipvx}tables-save"; -local $out = &backquote_logged("$scmd >$ipvx_save 2>&1"); +local $scmd = &iptables_save_command(); +local $out = &backquote_logged("cd / && $scmd >$ipvx_save 2>&1"); return $? ? "
$out
" : undef; }