Revision 48759936
Added by NewEraCracker almost 9 years ago
src/etc/inc/system.inc | ||
---|---|---|
477 | 477 |
function system_dhcpleases_configure() { |
478 | 478 |
global $config, $g; |
479 | 479 |
|
480 |
$pidfile = "{$g['varrun_path']}/dhcpleases.pid"; |
|
481 |
|
|
480 | 482 |
/* Start the monitoring process for dynamic dhcpclients. */ |
481 | 483 |
if ((isset($config['dnsmasq']['enable']) && isset($config['dnsmasq']['regdhcp'])) || |
482 | 484 |
(isset($config['unbound']['enable']) && isset($config['unbound']['regdhcp']))) { |
... | ... | |
494 | 496 |
$unbound_conf = ""; |
495 | 497 |
} |
496 | 498 |
|
497 |
$pidfile = "{$g['varrun_path']}/dhcpleases.pid"; |
|
498 | 499 |
if (isvalidpid($pidfile)) { |
499 | 500 |
/* Make sure dhcpleases is using correct unbound or dnsmasq */ |
500 | 501 |
$_gb = exec("/bin/pgrep -F {$pidfile} -f {$dns_pid}", $output, $retval); |
... | ... | |
512 | 513 |
} |
513 | 514 |
@unlink($pidfile); |
514 | 515 |
mwexec("/usr/local/sbin/dhcpleases -l {$g['dhcpd_chroot_path']}/var/db/dhcpd.leases -d {$config['system']['domain']} -p {$g['varrun_path']}/{$dns_pid} {$unbound_conf} -h {$g['varetc_path']}/hosts"); |
515 |
} else { |
|
516 |
} elseif (isvalidpid($pidfile)) {
|
|
516 | 517 |
sigkillbypid($pidfile, "TERM"); |
517 | 518 |
@unlink($pidfile); |
518 | 519 |
} |
Also available in: Unified diff
system_dhcpleases_configure() - Improve pidfile handling
1) Set the pidfile variable in the correct place.
pidfile variable is required in both 'if' and 'else' blocks.
2) Ensure pidfile is valid before sending term signal
(cherry picked from commit 4509abc380552554cbdf3f42c6783b47112f245a)