diff options
author | k-paulius <k.dash.paulius@gmail.com> | 2016-02-10 20:47:15 -0600 |
---|---|---|
committer | k-paulius <k.dash.paulius@gmail.com> | 2016-02-10 20:47:15 -0600 |
commit | ab31acb937792bdedef11fcdbd1d98ad126ebc0b (patch) | |
tree | 5bbb1f988ab8f06231aace180ed7f7ceaf7d7bf3 | |
parent | 4fe66748bcb2d63ba296d5f0ab891ce598db7793 (diff) | |
download | pfsense-ab31acb937792bdedef11fcdbd1d98ad126ebc0b.zip pfsense-ab31acb937792bdedef11fcdbd1d98ad126ebc0b.tar.gz |
Allow packages to request syslogd log socket to be created inside chroot by specifying it in /package/logging/logsocket element. Implements #4898.
Example:
<package>
<logging>
<logsocket>/var/appname/var/run/log</logsocket>
</logging>
</package>
-rw-r--r-- | src/etc/inc/system.inc | 21 | ||||
-rwxr-xr-x | src/usr/local/www/status_pkglogs.php | 4 |
2 files changed, 20 insertions, 5 deletions
diff --git a/src/etc/inc/system.inc b/src/etc/inc/system.inc index 89d38cc..612b4a1 100644 --- a/src/etc/inc/system.inc +++ b/src/etc/inc/system.inc @@ -889,7 +889,7 @@ function system_syslogd_start() { $syslogconf = ""; if ($config['installedpackages']['package']) { foreach ($config['installedpackages']['package'] as $package) { - if ($package['logging']) { + if (isset($package['logging']['facilityname']) && isset($package['logging']['logfilename'])) { array_push($separatelogfacilities, $package['logging']['facilityname']); if (!is_file($g['varlog_path'].'/'.$package['logging']['logfilename'])) { mwexec("{$log_create_directive} {$log_size} {$g['varlog_path']}/{$package['logging']['logfilename']}"); @@ -1059,6 +1059,22 @@ EOD; $syslogd_extra = "-f {$g['varetc_path']}/syslog.conf {$sourceip}"; } + $log_sockets = array(); + $log_sockets[] = "{$g['dhcpd_chroot_path']}/var/run/log"; + + if (isset($config['installedpackages']['package'])) { + foreach ($config['installedpackages']['package'] as $package) { + if (isset($package['logging']['logsocket']) && '' != $package['logging']['logsocket'] && + is_dir(pathinfo($package['logging']['logsocket'], PATHINFO_DIRNAME)) && !in_array($package['logging']['logsocket'], $log_sockets)) { + $log_sockets[] = $package['logging']['logsocket']; + } + } + } + $syslogd_sockets = ""; + foreach ($log_sockets as $log_socket) { + $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 @@ -1070,8 +1086,7 @@ EOD; usleep(100000); } - - $retval = mwexec_bg("/usr/sbin/syslogd -s -c -c -l {$g['dhcpd_chroot_path']}/var/run/log -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}"); if (platform_booting()) { echo gettext("done.") . "\n"; diff --git a/src/usr/local/www/status_pkglogs.php b/src/usr/local/www/status_pkglogs.php index b387fd3..b44dd4d 100755 --- a/src/usr/local/www/status_pkglogs.php +++ b/src/usr/local/www/status_pkglogs.php @@ -82,9 +82,9 @@ $i = 0; $pkgwithlogging = false; $apkg = $_GET['pkg']; if (!$apkg) { // If we aren't looking for a specific package, locate the first package that handles logging. - if ($config['installedpackages']['package'] <> "") { + if (isset($config['installedpackages']['package'])) { foreach ($config['installedpackages']['package'] as $package) { - if (is_array($package['logging'])) { + if (isset($package['logging']['logfilename']) && '' != $package['logging']['logfilename']) { $pkgwithlogging = true; $apkg = $package['name']; $apkgid = $i; |