Commit 175786b1 authored by Franco Fichtner's avatar Franco Fichtner

syslogd: allow to plug in local sockets for chroot; closes #985

As before, make this a mandatory feature for dhcp chroot in order
to catch problems with the implemenation as early as possible.

(cherry picked from commit 40cfb0da)
parent 5a1d721a
......@@ -843,6 +843,19 @@ function system_syslogd_get_remote_servers($syslogcfg, $facility = "*.*") {
return $remote_servers;
}
function system_syslogd_extra_local($logsocket)
{
$logdir = dirname($logsocket);
if (!is_dir($logdir)) {
/* create if needed to avoid startup error */
mwexecf('/bin/mkdir -p %s', $logdir);
}
/* emit extra args for syslogd invoke */
return exec_safe('-l %s ', $logsocket);
}
function system_syslogd_start()
{
global $config, $g;
......@@ -878,6 +891,7 @@ function system_syslogd_start()
$syslogconfs['filter'] = array("facility" => array('filterlog'), "remote" => "filter");
$syslogconfs['portalauth'] = array("facility" => array('captiveportal'), "remote" => "portalauth");
// XXX should be in plugins.inc
// probe syslog facilities in plugins
foreach (plugin_scan() as $name => $path) {
require_once $path;
......@@ -889,6 +903,9 @@ function system_syslogd_start()
$syslogconfs[$plugin_syslog] = array();
$syslogconfs[$plugin_syslog]['facility'] = array();
$syslogconfs[$plugin_syslog]['remote'] = $plugin_details['remote'];
if (isset($plugin_details['local'])) {
$syslogd_extra .= system_syslogd_extra_local($plugin_details['local']);
}
}
$tmp = array_merge($syslogconfs[$plugin_syslog]['facility'], $plugin_details['facility']);
$syslogconfs[$plugin_syslog]['facility'] = $tmp;
......@@ -957,10 +974,7 @@ EOD;
}
unset($syslogconf);
// Ensure that the log directory exists
if (!is_dir("{$g['dhcpd_chroot_path']}/var/run")) {
exec("/bin/mkdir -p {$g['dhcpd_chroot_path']}/var/run");
}
$syslogd_extra .= system_syslogd_extra_local("{$g['dhcpd_chroot_path']}/var/run/log");
if (!empty($syslogcfg['sourceip'])) {
if ($syslogcfg['ipproto'] == "ipv6") {
......@@ -997,10 +1011,7 @@ EOD;
if (isvalidpid('/var/run/syslog.pid')) {
killbypid('/var/run/syslog.pid', 'HUP');
} else {
mwexecf_bg(
"/usr/local/sbin/syslogd -s -c -c -l %s -P %s {$syslogd_extra}",
array("{$g['dhcpd_chroot_path']}/var/run/log", '/var/run/syslog.pid')
);
mwexecf_bg("/usr/local/sbin/syslogd -s -c -c -P %s {$syslogd_extra}", '/var/run/syslog.pid');
}
if (file_exists("/var/run/booting")) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment