]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
rules.pl: Check if an ipset db file exists before call to restore it.
authorStefan Schantl <stefan.schantl@ipfire.org>
Mon, 14 Feb 2022 18:42:54 +0000 (19:42 +0100)
committerPeter Müller <peter.mueller@ipfire.org>
Tue, 15 Feb 2022 18:07:26 +0000 (18:07 +0000)
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
Reviewed-by: Peter Müller <peter.mueller@ipfire.org>
Reviewed-by: Michael Tremer <michael.tremer@ipfire.org>
config/firewall/rules.pl

index 29990ee672ae87ad42fe8de806469d93c052cc94..162781f7ac71a3d67a32898d348f7ca378430008 100644 (file)
@@ -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");
+       }
 }