Merge pull request #1206 from pi-hole/fix/dhcp_static_error

Check for existence and readability of static leases file before trying to access it
This commit is contained in:
DL6ER
2020-04-21 10:07:15 +02:00
committed by GitHub

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;