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()) ...@@ -372,6 +372,20 @@ function services_radvd_configure($blacklist = array())
return 0; 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()) function services_dhcpd_configure($family = "all", $blacklist = array())
{ {
global $config, $g; global $config, $g;
......
...@@ -35,16 +35,20 @@ require_once("unbound.inc"); ...@@ -35,16 +35,20 @@ require_once("unbound.inc");
require_once("pfsense-utils.inc"); require_once("pfsense-utils.inc");
require_once("interfaces.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, * 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 * then DHCP will print a warning in the logs about a duplicate lease
*/ */
function dhcp_clean_leases() { function dhcp_clean_leases()
global $g, $config; {
$leasesfile = "{$g['dhcpd_chroot_path']}/var/db/dhcpd.leases"; global $config;
$leasesfile = services_dhcpd_leasesfile();
if (!file_exists($leasesfile)) { if (!file_exists($leasesfile)) {
return; return;
} }
/* Build list of static MACs */ /* Build list of static MACs */
$staticmacs = array(); $staticmacs = array();
foreach($config['interfaces'] as $ifname => $ifarr) { foreach($config['interfaces'] as $ifname => $ifarr) {
......
...@@ -42,15 +42,14 @@ require_once("services.inc"); ...@@ -42,15 +42,14 @@ require_once("services.inc");
*/ */
function reconfigure_dhcpd() function reconfigure_dhcpd()
{ {
killbypid("{$g['dhcpd_chroot_path']}/var/run/dhcpdv6.pid"); /* services_dnsmasq_configure calls services_dhcpd_configure */
/* dnsmasq_configure calls dhcpd_configure */
/* no need to restart dhcpd twice */
if (isset($config['dnsmasq']['enable']) && isset($config['dnsmasq']['regdhcpstatic'])) { if (isset($config['dnsmasq']['enable']) && isset($config['dnsmasq']['regdhcpstatic'])) {
$retvaldns = services_dnsmasq_configure(); $retvaldns = services_dnsmasq_configure();
if ($retvaldns == 0) { if ($retvaldns == 0) {
clear_subsystem_dirty('hosts'); clear_subsystem_dirty('hosts');
clear_subsystem_dirty('staticmaps'); clear_subsystem_dirty('staticmaps');
} }
/* services_unbound_configure calls services_dhcpd_configure */
} elseif (isset($config['unbound']['enable']) && isset($config['unbound']['regdhcpstatic'])) { } elseif (isset($config['unbound']['enable']) && isset($config['unbound']['regdhcpstatic'])) {
$retvaldns = services_unbound_configure(); $retvaldns = services_unbound_configure();
if ($retvaldns == 0) { if ($retvaldns == 0) {
......
...@@ -75,7 +75,7 @@ function remove_duplicate($array, $field) ...@@ -75,7 +75,7 @@ function remove_duplicate($array, $field)
return $new; return $new;
} }
$leasesfile = "{$g['dhcpd_chroot_path']}/var/db/dhcpd.leases"; $leasesfile = services_dhcpd_leasesfile();
if ($_SERVER['REQUEST_METHOD'] === 'GET') { if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$awk = "/usr/bin/awk"; $awk = "/usr/bin/awk";
......
...@@ -98,8 +98,7 @@ function parse_duid($duid_string) { ...@@ -98,8 +98,7 @@ function parse_duid($duid_string) {
return array($iaid, $duid); return array($iaid, $duid);
} }
$leasesfile = services_dhcpdv6_leasesfile();
$leasesfile = "{$g['dhcpd_chroot_path']}/var/db/dhcpd6.leases";
if ($_SERVER['REQUEST_METHOD'] === 'GET') { if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$awk = "/usr/bin/awk"; $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