diff options
author | Renato Botelho <garga@FreeBSD.org> | 2014-11-14 09:51:27 -0200 |
---|---|---|
committer | Renato Botelho <garga@FreeBSD.org> | 2014-11-14 09:51:27 -0200 |
commit | 4dbcf2fbcea9cfe2166c958d3872e3a7353e3c5c (patch) | |
tree | af62e6f4f6493a27c9f51b5a417e911a784532a3 /etc/inc/system.inc | |
parent | 9612943eaa3c6ef427ea4414f7c32dc2b326dd55 (diff) | |
download | pfsense-4dbcf2fbcea9cfe2166c958d3872e3a7353e3c5c.zip pfsense-4dbcf2fbcea9cfe2166c958d3872e3a7353e3c5c.tar.gz |
Make sure dhcpleases use correct pid file for dnsmasq or unbound. Fixes #4008
Diffstat (limited to 'etc/inc/system.inc')
-rw-r--r-- | etc/inc/system.inc | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/etc/inc/system.inc b/etc/inc/system.inc index 1b4de5e..63d1d90 100644 --- a/etc/inc/system.inc +++ b/etc/inc/system.inc @@ -394,19 +394,29 @@ function system_dhcpleases_configure() { mwexec("/bin/mkdir -p {$g['dhcpd_chroot_path']}/var/db"); if (!file_exists("{$g['dhcpd_chroot_path']}/var/db/dhcpd.leases")) @touch("{$g['dhcpd_chroot_path']}/var/db/dhcpd.leases"); - if (isvalidpid("{$g['varrun_path']}/dhcpleases.pid")) - sigkillbypid("{$g['varrun_path']}/dhcpleases.pid", "HUP"); - else { - /* To ensure we do not start multiple instances of dhcpleases, perform some clean-up first. */ - if (is_process_running("dhcpleases")) - mwexec('/bin/pkill dhcpleases'); - @unlink("{$g['varrun_path']}/dhcpleases.pid"); - if (isset($config['unbound']['enable'])) - $dns_pid = "unbound.pid"; - else - $dns_pid = "dnsmasq.pid"; - mwexec("/usr/local/sbin/dhcpleases -l {$g['dhcpd_chroot_path']}/var/db/dhcpd.leases -d {$config['system']['domain']} -p {$g['varrun_path']}/{$dns_pid} -h {$g['varetc_path']}/hosts"); + + if (isset($config['unbound']['enable'])) + $dns_pid = "unbound.pid"; + else + $dns_pid = "dnsmasq.pid"; + + $pidfile = "{$g['varrun_path']}/dhcpleases.pid"; + if (isvalidpid($pidfile)) { + /* Make sure dhcpleases is using correct unbound or dnsmasq */ + + $_gb = exec("/bin/pgrep -F {$pidfile} -f {$dns_pid}", $output, $retval); + if (intval($retval) == 0) { + sigkillbypid($pidfile, "HUP"); + return; + } else + sigkillbypid($pidfile, "TERM"); } + + /* To ensure we do not start multiple instances of dhcpleases, perform some clean-up first. */ + if (is_process_running("dhcpleases")) + mwexec('/bin/pkill dhcpleases'); + @unlink("{$g['varrun_path']}/dhcpleases.pid"); + mwexec("/usr/local/sbin/dhcpleases -l {$g['dhcpd_chroot_path']}/var/db/dhcpd.leases -d {$config['system']['domain']} -p {$g['varrun_path']}/{$dns_pid} -h {$g['varetc_path']}/hosts"); } else { sigkillbypid("{$g['varrun_path']}/dhcpleases.pid", "TERM"); @unlink("{$g['varrun_path']}/dhcpleases.pid"); |