diff options
author | jim-p <jimp@pfsense.org> | 2017-05-15 16:54:54 -0400 |
---|---|---|
committer | jim-p <jimp@pfsense.org> | 2017-05-15 16:54:54 -0400 |
commit | 3a0df77eebf27d027d512a61dcbf80adefd630c4 (patch) | |
tree | 5a72544fa4a644131ac2730fb7af0e7b4ad9ba0b /src | |
parent | 38a47119a5c25b4aaaeb25109a84698217f7d5a7 (diff) | |
download | pfsense-3a0df77eebf27d027d512a61dcbf80adefd630c4.zip pfsense-3a0df77eebf27d027d512a61dcbf80adefd630c4.tar.gz |
Refine some syslogd restarts, add a way to send it a HUP to reload w/o a full restart. Part of ticket #7256
Diffstat (limited to 'src')
-rw-r--r-- | src/etc/inc/pkg-utils.inc | 12 | ||||
-rw-r--r-- | src/etc/inc/system.inc | 42 |
2 files changed, 36 insertions, 18 deletions
diff --git a/src/etc/inc/pkg-utils.inc b/src/etc/inc/pkg-utils.inc index 0842ab9..a7e51f5 100644 --- a/src/etc/inc/pkg-utils.inc +++ b/src/etc/inc/pkg-utils.inc @@ -873,11 +873,6 @@ function install_package_xml($package_name) { return false; } - /* set up package logging streams */ - if ($pkg_info['logging']) { - system_syslogd_start(); - } - update_status(gettext("Writing configuration... ")); write_config($changedesc); log_error(sprintf(gettext("Successfully installed package: %s."), $pkg_info['name'])); @@ -886,6 +881,11 @@ function install_package_xml($package_name) { update_status($pkg_info['after_install_info']); } + /* set up package logging streams */ + if ($pkg_info['logging']) { + system_syslogd_start(true); + } + return true; } @@ -1015,7 +1015,7 @@ function delete_package_xml($package_name, $when = "post-deinstall") { /* remove package entry from /etc/syslog.conf if needed */ /* this must be done after removing the entries from config.xml */ if ($need_syslog_restart) { - system_syslogd_start(); + system_syslogd_start(true); } } } diff --git a/src/etc/inc/system.inc b/src/etc/inc/system.inc index 1fe07fb..b0c00d7 100644 --- a/src/etc/inc/system.inc +++ b/src/etc/inc/system.inc @@ -931,8 +931,12 @@ function system_syslogd_get_remote_servers($syslogcfg, $facility = "*.*") { function clear_log_file($logfile = "/var/log/system.log", $restart_syslogd = true) { global $config, $g; + if ($restart_syslogd) { - exec("/usr/bin/killall syslogd"); + /* syslogd does not react well to clog rewriting the file while it is running. */ + if (isvalidpid("{$g['varrun_path']}/syslog.pid")) { + sigkillbypid("{$g['varrun_path']}/syslog.pid", "KILL"); + } } if (isset($config['system']['disablesyslogclog'])) { unlink($logfile); @@ -953,7 +957,12 @@ function clear_log_file($logfile = "/var/log/system.log", $restart_syslogd = tru function clear_all_log_files($restart = false) { global $g; - exec("/usr/bin/killall syslogd"); + if ($restart) { + /* syslogd does not react well to clog rewriting the file while it is running. */ + if (isvalidpid("{$g['varrun_path']}/syslog.pid")) { + sigkillbypid("{$g['varrun_path']}/syslog.pid", "KILL"); + } + } $log_files = array("system", "filter", "dhcpd", "vpn", "poes", "l2tps", "openvpn", "portalauth", "ipsec", "ppp", "relayd", "wireless", "nginx", "ntpd", "gateways", "resolver", "routing"); foreach ($log_files as $lfile) { @@ -973,7 +982,7 @@ function clear_all_log_files($restart = false) { return; } -function system_syslogd_start() { +function system_syslogd_start($sighup = false) { global $config, $g; if (isset($config['system']['developerspew'])) { $mt = microtime(); @@ -1204,18 +1213,27 @@ EOD; $syslogd_sockets .= " -l {$log_socket}"; } - if (isvalidpid("{$g['varrun_path']}/syslog.pid")) { - sigkillbypid("{$g['varrun_path']}/syslog.pid", "TERM"); - usleep(100000); // syslogd often doesn't respond to a TERM quickly enough for the starting of syslogd below to be successful + /* If HUP was requested, but syslogd is not running, restart it instead. */ + if ($sighup && !isvalidpid("{$g['varrun_path']}/syslog.pid")) { + $sighup = false; } - if (isvalidpid("{$g['varrun_path']}/syslog.pid")) { - // if it still hasn't responded to the TERM, KILL it. - sigkillbypid("{$g['varrun_path']}/syslog.pid", "KILL"); - usleep(100000); - } + if (!$sighup) { + if (isvalidpid("{$g['varrun_path']}/syslog.pid")) { + sigkillbypid("{$g['varrun_path']}/syslog.pid", "TERM"); + usleep(100000); // syslogd often doesn't respond to a TERM quickly enough for the starting of syslogd below to be successful + } + + if (isvalidpid("{$g['varrun_path']}/syslog.pid")) { + // if it still hasn't responded to the TERM, KILL it. + sigkillbypid("{$g['varrun_path']}/syslog.pid", "KILL"); + usleep(100000); + } - $retval = mwexec_bg("/usr/sbin/syslogd -s -c -c {$syslogd_sockets} -P {$g['varrun_path']}/syslog.pid {$syslogd_extra}"); + $retval = mwexec_bg("/usr/sbin/syslogd -s -c -c {$syslogd_sockets} -P {$g['varrun_path']}/syslog.pid {$syslogd_extra}"); + } else { + $retval = sigkillbypid("{$g['varrun_path']}/syslog.pid", "HUP"); + } if (platform_booting()) { echo gettext("done.") . "\n"; |