Commit 5a091c26 authored by Franco Fichtner's avatar Franco Fichtner

dhcpd: try to contain usage of global dhcpd_chroot_path

parent ab85b60e
......@@ -372,6 +372,20 @@ function services_radvd_configure($blacklist = array())
return 0;
}
function services_dhcpd_leasesfile()
{
global $g;
return "{$g['dhcpd_chroot_path']}/var/db/dhcpd.leases";
}
function services_dhcpdv6_leasesfile()
{
global $g;
return "{$g['dhcpd_chroot_path']}/var/db/dhcpd6.leases";
}
function services_dhcpd_configure($family = "all", $blacklist = array())
{
global $config, $g;
......
......@@ -35,16 +35,20 @@ require_once("unbound.inc");
require_once("pfsense-utils.inc");
require_once("interfaces.inc");
/* This function will remove entries from dhcpd.leases that would otherwise
/*
* This function will remove entries from dhcpd.leases that would otherwise
* overlap with static DHCP reservations. If we don't clean these out,
* then DHCP will print a warning in the logs about a duplicate lease
*/
function dhcp_clean_leases() {
global $g, $config;
$leasesfile = "{$g['dhcpd_chroot_path']}/var/db/dhcpd.leases";
function dhcp_clean_leases()
{
global $config;
$leasesfile = services_dhcpd_leasesfile();
if (!file_exists($leasesfile)) {
return;
}
/* Build list of static MACs */
$staticmacs = array();
foreach($config['interfaces'] as $ifname => $ifarr) {
......
......@@ -42,15 +42,14 @@ require_once("services.inc");
*/
function reconfigure_dhcpd()
{
killbypid("{$g['dhcpd_chroot_path']}/var/run/dhcpdv6.pid");
/* dnsmasq_configure calls dhcpd_configure */
/* no need to restart dhcpd twice */
/* services_dnsmasq_configure calls services_dhcpd_configure */
if (isset($config['dnsmasq']['enable']) && isset($config['dnsmasq']['regdhcpstatic'])) {
$retvaldns = services_dnsmasq_configure();
if ($retvaldns == 0) {
clear_subsystem_dirty('hosts');
clear_subsystem_dirty('staticmaps');
}
/* services_unbound_configure calls services_dhcpd_configure */
} elseif (isset($config['unbound']['enable']) && isset($config['unbound']['regdhcpstatic'])) {
$retvaldns = services_unbound_configure();
if ($retvaldns == 0) {
......
......@@ -75,7 +75,7 @@ function remove_duplicate($array, $field)
return $new;
}
$leasesfile = "{$g['dhcpd_chroot_path']}/var/db/dhcpd.leases";
$leasesfile = services_dhcpd_leasesfile();
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$awk = "/usr/bin/awk";
......
......@@ -98,8 +98,7 @@ function parse_duid($duid_string) {
return array($iaid, $duid);
}
$leasesfile = "{$g['dhcpd_chroot_path']}/var/db/dhcpd6.leases";
$leasesfile = services_dhcpdv6_leasesfile();
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$awk = "/usr/bin/awk";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment