Check for existance and readability of static leases file before trying to access it.

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER
2020-04-07 12:30:51 +02:00
parent 3dc9290d77
commit 0f892c9ffc

View File

@@ -79,16 +79,10 @@ function readStaticLeasesFile($origin_file="/etc/dnsmasq.d/04-pihole-static-dhcp
{
global $dhcp_static_leases;
$dhcp_static_leases = array();
try
{
$dhcpstatic = @fopen($origin_file, 'r');
}
catch(Exception $e)
{
echo "Warning: Failed to read ".$origin_file.", this is not an error";
if(!file_exists($origin_file) || !is_readable($origin_file))
return false;
}
$dhcpstatic = @fopen($origin_file, 'r');
if(!is_resource($dhcpstatic))
return false;