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; }