From patchwork Mon Feb 14 18:42:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 5159 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4JyCm46bHwz3wsl for ; Mon, 14 Feb 2022 18:43:32 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4JyClr5kgKz5Qq; Mon, 14 Feb 2022 18:43:20 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4JyClr5QG0z2ywH; Mon, 14 Feb 2022 18:43:20 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4JyCln6tMbz32K9 for ; Mon, 14 Feb 2022 18:43:17 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4JyCln4NmdznC; Mon, 14 Feb 2022 18:43:17 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1644864197; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZtLTf6bSu2TizQ36YhvRoPY0++9tExr/Emx1hfa6RBw=; b=hf18BKY/jRGA+2Ujzeaw5gztVA40H7YI3kxijNWCmp901TsP8ktHBDynqbKfWkb6LJaCgZ ZsMYo50yUbjEmMDw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1644864197; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZtLTf6bSu2TizQ36YhvRoPY0++9tExr/Emx1hfa6RBw=; b=b7YWYeAGBKHpZrBbMyPBqeh1x6p7lBC0yPLoJ8pFYuhTdLk8yQN3Bos+6tytUyBm9SKf9C qm/ZSi0MJVN6wGJjF3cqwn/xwxEAQ/HUnJDbWhLSZN0BJd1skUoci3xxp9QuK2UFhBWBef OjZ5VjdhfmmEV4viX3ORrk9R+xWQfE4N5AKcwPpjuL2Ceg5YVuYFksDU1ls3Rdkb0boW62 p46bx3ux46habyHoc3EdIKxa0m3/3nQ7eBtTroAx7bx+zO/qLlsC5LRVDMkOYLAilndXxz DYL0brCUR8wgVGboySl4j1FBJSLIziCRVgF0pU3NLhdB7m3NrNcEZ+4AoHjgFQ== From: Stefan Schantl To: development@lists.ipfire.org Subject: [PATCH 10/12] rules.pl: Check if an ipset db file exists before call to restore it. Date: Mon, 14 Feb 2022 19:42:54 +0100 Message-Id: <20220214184257.2406-10-stefan.schantl@ipfire.org> In-Reply-To: <20220214184257.2406-1-stefan.schantl@ipfire.org> References: <20220214184257.2406-1-stefan.schantl@ipfire.org> MIME-Version: 1.0 X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" Signed-off-by: Stefan Schantl Reviewed-by: Peter Müller Reviewed-by: Michael Tremer --- config/firewall/rules.pl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/config/firewall/rules.pl b/config/firewall/rules.pl index 29990ee67..162781f7a 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"); + } }