dhcp: fix killbyname() usage which kills both services

This commit is contained in:
Franco Fichtner 2019-12-31 11:38:51 +01:00
parent e1f2fb0f3d
commit bbee5f518f
5 changed files with 6 additions and 10 deletions

View File

@ -63,7 +63,6 @@ if (isset($opts['m']) && isset($opts['f'])) {
}
// XXX: should probably add some plugin hook for this.
if ($fname == 'dhcpd' && $mname == 'core') {
killbyname('dhcpd');
plugins_configure('dhcp');
}
}

View File

@ -78,7 +78,6 @@ function clear_all_log_files()
}
system_syslogd_start();
killbyname('dhcpd');
plugins_configure('dhcp');
}

View File

@ -37,11 +37,15 @@ require_once("plugins.inc.d/dhcpd.inc");
* 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
*
* XXX errr: why are we doing this only on this particular page?
*/
function dhcp_clean_leases()
{
global $config;
killbypid('/var/dhcpd/var/run/dhcpd.pid', 'TERM', true);
$leasesfile = dhcpd_dhcpv4_leasesfile();
if (!file_exists($leasesfile)) {
return;
@ -82,8 +86,6 @@ function validate_partial_mac_list($maclist) {
function reconfigure_dhcpd()
{
/* Stop DHCP so we can cleanup leases */
killbyname("dhcpd");
dhcp_clean_leases();
system_hosts_generate();
clear_subsystem_dirty('hosts');

View File

@ -257,9 +257,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
);
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (!empty($_POST['deleteip']) && is_ipaddr($_POST['deleteip'])) {
// delete dhcp lease
/* Stop DHCPD */
killbyname("dhcpd");
killbypid('/var/dhcpd/var/run/dhcpd.pid', 'TERM', true);
$fin = @fopen($leasesfile, "r");
$fout = @fopen($leasesfile.".new", "w");
if ($fin) {

View File

@ -314,9 +314,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
}
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (!empty($_POST['deleteip']) && is_ipaddr($_POST['deleteip'])) {
// delete dhcp lease
/* Stop DHCPD */
killbyname("dhcpd");
killbypid('/var/dhcpd/var/run/dhcpdv6.pid', 'TERM', true);
$fin = @fopen($leasesfile, "r");
$fout = @fopen($leasesfile.".new", "w");
if ($fin) {