From: Stefan Schantl Date: Mon, 14 Feb 2022 18:42:54 +0000 (+0100) Subject: rules.pl: Check if an ipset db file exists before call to restore it. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=50e43059554a6a1c9ca8579b5347a9f98bc99ffb;p=people%2Fms%2Fipfire-2.x.git rules.pl: Check if an ipset db file exists before call to restore it. Signed-off-by: Stefan Schantl Reviewed-by: Peter Müller Reviewed-by: Michael Tremer --- diff --git a/config/firewall/rules.pl b/config/firewall/rules.pl index 29990ee672..162781f7ac 100644 --- a/config/firewall/rules.pl +++ b/config/firewall/rules.pl @@ -927,6 +927,12 @@ sub firewall_is_in_subnet { sub ipset_restore ($) { my ($ccode) = @_; - # Run ipset and restore the list of the given country code. - run("$IPSET restore < $Location::Functions::ipset_db_directory/$ccode.ipset4"); + my $file_prefix = "ipset4"; + my $db_file = "$Location::Functions::ipset_db_directory/$ccode.$file_prefix"; + + # Check if the generated file exists. + if (-f $db_file) { + # Run ipset and restore the list of the given country code. + run("$IPSET restore < $db_file"); + } }