summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorErmal <eri@pfsense.org>2013-02-09 21:17:16 +0000
committerErmal <eri@pfsense.org>2013-02-09 21:17:38 +0000
commitb9f29f84af1d22732a91581c1a12c4b7ebad1e6f (patch)
treebd25d064b735e534666c930150064dc8a3d0a76c /etc
parentb61306fb3cb5f7b9d44f45c2e39ecb9a4071ca6f (diff)
downloadpfsense-b9f29f84af1d22732a91581c1a12c4b7ebad1e6f.zip
pfsense-b9f29f84af1d22732a91581c1a12c4b7ebad1e6f.tar.gz
Use mwexec() with signal clearing. Use pid file for killining/tracking ntpd
Diffstat (limited to 'etc')
-rw-r--r--etc/inc/system.inc23
1 files changed, 9 insertions, 14 deletions
diff --git a/etc/inc/system.inc b/etc/inc/system.inc
index 31643e0..ffdcbd6 100644
--- a/etc/inc/system.inc
+++ b/etc/inc/system.inc
@@ -1239,8 +1239,10 @@ function system_ntp_configure($start_ntpd=true) {
$ntpcfg .= "\n\n# Upstream Servers\n";
/* foreach through servers and write out to ntpd.conf */
- foreach (explode(' ', $config['system']['timeservers']) as $ts)
- $ntpcfg .= "server {$ts} iburst maxpoll 9\n";
+ if (is_array($config['system']['timeservers'])) {
+ foreach (explode(' ', $config['system']['timeservers']) as $ts)
+ $ntpcfg .= "server {$ts} iburst maxpoll 9\n";
+ }
$ntpcfg .= "enable monitor\n";
$ntpcfg .= "enable stats\n";
@@ -1270,34 +1272,27 @@ function system_ntp_configure($start_ntpd=true) {
}
/* open configuration for wrting or bail */
- $fd = fopen("{$g['varetc_path']}/ntpd.conf","w");
- if(!$fd) {
+ if (!@file_put_contents("{$g['varetc_path']}/ntpd.conf", $ntpcfg)) {
log_error("Could not open {$g['varetc_path']}/ntpd.conf for writing");
return;
}
- fwrite($fd, $ntpcfg);
-
- /* slurp! */
- fclose($fd);
/* At bootup we just want to write out the config. */
if (!$start_ntpd)
return;
/* if ntpd is running, kill it */
- while(is_process_running("ntpd")) {
- killbyname("ntpd");
+ while (is_validpid("{$g['varrun_path']}/ntpd.pid")) {
+ killbypid("{$g['varrun_path']}/ntpd.pid");
}
+ @unlink("{$g['varrun_path']}/ntpd.pid");
/* if /var/empty does not exist, create it */
if(!is_dir("/var/empty"))
exec("/bin/mkdir -p /var/empty && chmod ug+rw /var/empty/.");
/* start opentpd, set time now and use /var/etc/ntpd.conf */
- $oldset = array();
- pcntl_sigprocmask(SIG_SETMASK, array(), $oldset);
- exec("/usr/local/bin/ntpd -g -c {$g['varetc_path']}/ntpd.conf");
- pcntl_sigprocmask(SIG_SETMASK, $oldset);
+ mwexec("/usr/local/bin/ntpd -g -c {$g['varetc_path']}/ntpd.conf -p {$g['varrun_path']}/ntpd.pid", false, true);
// Note that we are starting up
log_error("NTPD is starting up.");
OpenPOWER on IntegriCloud