From dfb7062fba3bcac4a422f8d473d3fbe001cd1c65 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Fri, 25 Apr 2025 11:52:01 +0200 Subject: [PATCH] wireguard-functions.pl: Don't crash when configuration files don't exist This should never really happen, but since we include this file in pretty much everything Perl, we should not fail. Signed-off-by: Michael Tremer --- config/cfgroot/wireguard-functions.pl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/config/cfgroot/wireguard-functions.pl b/config/cfgroot/wireguard-functions.pl index 79b3bb097..e3bd8ede6 100644 --- a/config/cfgroot/wireguard-functions.pl +++ b/config/cfgroot/wireguard-functions.pl @@ -33,11 +33,17 @@ our $DEFAULT_KEEPALIVE = 25; # Read the global configuration our %settings = (); -&General::readhash("/var/ipfire/wireguard/settings", \%settings); + +if (-e "/var/ipfire/wireguard/settings") { + &General::readhash("/var/ipfire/wireguard/settings", \%settings); +} # Read all peers our %peers = (); -&General::readhasharray("/var/ipfire/wireguard/peers", \%peers); + +if (-e "/var/ipfire/wireguard/peers") { + &General::readhasharray("/var/ipfire/wireguard/peers", \%peers); +} # Set any defaults &General::set_defaults(\%settings, { -- 2.39.5