From 34bbb9a70e1460248fdcd2c857c7e105fc3c9786 Mon Sep 17 00:00:00 2001 From: Cynthia Date: Wed, 3 Oct 2018 02:24:00 +0200 Subject: [PATCH] Error handling in savesettings.php This is to address https://github.com/pi-hole/pi-hole/issues/2444 Signed-off-by: Cynthia Revstrom --- scripts/pi-hole/php/savesettings.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/pi-hole/php/savesettings.php b/scripts/pi-hole/php/savesettings.php index c1226fd5..f308fd17 100644 --- a/scripts/pi-hole/php/savesettings.php +++ b/scripts/pi-hole/php/savesettings.php @@ -63,7 +63,15 @@ function readStaticLeasesFile() { global $dhcp_static_leases; $dhcp_static_leases = array(); - $dhcpstatic = @fopen('/etc/dnsmasq.d/04-pihole-static-dhcp.conf', 'r'); + try + { + $dhcpstatic = @fopen('/etc/dnsmasq.d/04-pihole-static-dhcp.conf', 'r'); + } + catch(Exception $e) + { + echo "Warning: Failed to read /etc/dnsmasq.d/04-pihole-static-dhcp.conf, this is not an error"; + return false; + } if(!is_resource($dhcpstatic)) return false;