diff --git a/src/etc/inc/system.inc b/src/etc/inc/system.inc index 7cfb8aabc..4b818246b 100644 --- a/src/etc/inc/system.inc +++ b/src/etc/inc/system.inc @@ -146,7 +146,7 @@ function system_resolvconf_generate($verbose = false) { global $config; - $syscfg = $config['system']; + $syscfg = config_read_array('system'); if ($verbose) { echo 'Generating /etc/resolv.conf...'; @@ -157,7 +157,7 @@ function system_resolvconf_generate($verbose = false) $resolvconf = "domain {$syscfg['domain']}\n"; } - if (!isset($config['system']['dnslocalhost']) && (isset($config['dnsmasq']['enable']) || isset($config['unbound']['enable']))) { + if (!isset($syscfg['dnslocalhost']) && (isset($config['dnsmasq']['enable']) || isset($config['unbound']['enable']))) { $resolvconf .= "nameserver 127.0.0.1\n"; } @@ -185,8 +185,8 @@ function system_resolvconf_generate($verbose = false) for ($dnscounter = 1; $dnscounter < 9; $dnscounter++) { /* setup static routes for dns servers */ $dnsgw = "dns{$dnscounter}gw"; - if (isset($config['system'][$dnsgw])) { - $gwname = $config['system'][$dnsgw]; + if (isset($syscfg[$dnsgw])) { + $gwname = $syscfg[$dnsgw]; if (($gwname <> "") && ($gwname <> "none")) { $gatewayip = lookup_gateway_ip_by_name($gwname); if (is_ipaddrv4($gatewayip)) { @@ -333,7 +333,7 @@ function system_hosts_generate($verbose = false) flush(); } - $syscfg = $config['system']; + $syscfg = config_read_array('system'); $hosts = "127.0.0.1\tlocalhost localhost.{$syscfg['domain']}\n"; @@ -365,14 +365,12 @@ function system_hosts_generate($verbose = false) function system_hostname_configure($verbose = false) { - global $config; - if ($verbose) { echo 'Setting hostname: '; flush(); } - $syscfg = $config['system']; + $syscfg = config_read_array('system'); $hostname = "{$syscfg['hostname']}.{$syscfg['domain']}"; @@ -662,8 +660,6 @@ function system_syslogd_extra_local($logsocket) function system_syslogd_start($verbose = false, $restart = false) { - global $config; - if ($verbose) { echo 'Configuring system logging...'; flush(); @@ -671,57 +667,56 @@ function system_syslogd_start($verbose = false, $restart = false) configd_run('template reload OPNsense/Syslog'); - $syslogcfg = $config['syslog']; + $syslogcfg = config_read_array('syslog'); $log_directive = '%'; $syslogd_extra = ''; - if (isset($syslogcfg)) { - $syslogconf = ''; + $syslogconf = ''; - $syslogconfs = array(); + $syslogconfs = array(); - foreach (plugins_syslog() as $plugin_name => $plugin_details) { - $syslogconfs[$plugin_name] = $plugin_details; - } + foreach (plugins_syslog() as $plugin_name => $plugin_details) { + $syslogconfs[$plugin_name] = $plugin_details; + } - /* - * XXX Standard syslog configs overwrite plugins, but we can - * get rid of this behaviour by wrapping this local array using - * the key as a "name" entry in the array... - */ - $syslogconfs['dhcpd'] = array('facility' => array('dhcpd', 'dhcrelay', 'dhclient', 'dhcp6c'), 'local' => '/var/dhcpd/var/run/log', 'remote' => 'dhcp'); - $syslogconfs['filter'] = array('facility' => array('filterlog'), 'remote' => 'filter'); - $syslogconfs['lighttpd'] = array('facility' => array('lighttpd')); - $syslogconfs['configd'] = array('facility' => array('configd.py')); - $syslogconfs['gateways'] = array('facility' => array('apinger', 'dpinger'), 'remote' => 'apinger'); - $syslogconfs['portalauth'] = array('facility' => array('captiveportal'), 'remote' => 'portalauth'); - $syslogconfs['ppps'] = array('facility' => array('ppp')); - $syslogconfs['resolver'] = array('facility' => array('unbound'), 'remote' => 'dns'); - $syslogconfs['routing'] = array('facility' => array('radvd', 'routed', 'rtsold', 'olsrd', 'zebra', 'ospfd', 'bgpd', 'miniupnpd')); - $syslogconfs['wireless'] = array('facility' => array('hostapd'), 'remote' => 'hostapd'); + /* + * XXX Standard syslog configs overwrite plugins, but we can + * get rid of this behaviour by wrapping this local array using + * the key as a "name" entry in the array... + */ + $syslogconfs['dhcpd'] = array('facility' => array('dhcpd', 'dhcrelay', 'dhclient', 'dhcp6c'), 'local' => '/var/dhcpd/var/run/log', 'remote' => 'dhcp'); + $syslogconfs['filter'] = array('facility' => array('filterlog'), 'remote' => 'filter'); + $syslogconfs['lighttpd'] = array('facility' => array('lighttpd')); + $syslogconfs['configd'] = array('facility' => array('configd.py')); + $syslogconfs['gateways'] = array('facility' => array('apinger', 'dpinger'), 'remote' => 'apinger'); + $syslogconfs['portalauth'] = array('facility' => array('captiveportal'), 'remote' => 'portalauth'); + $syslogconfs['ppps'] = array('facility' => array('ppp')); + $syslogconfs['resolver'] = array('facility' => array('unbound'), 'remote' => 'dns'); + $syslogconfs['routing'] = array('facility' => array('radvd', 'routed', 'rtsold', 'olsrd', 'zebra', 'ospfd', 'bgpd', 'miniupnpd')); + $syslogconfs['wireless'] = array('facility' => array('hostapd'), 'remote' => 'hostapd'); - $separatelogfacilities = array(); - foreach ($syslogconfs as $logTopic => $logConfig) { - $syslogconf .= "!".implode(',', $logConfig['facility'])."\n"; - $separatelogfacilities = array_merge($logConfig['facility'], $separatelogfacilities); - if (!isset($syslogcfg['disablelocallogging'])) { - $syslogconf .= "*.* {$log_directive}/var/log/{$logTopic}.log\n"; - } - if (!empty($logConfig['remote']) && !empty($syslogcfg[$logConfig['remote']]) && !empty($syslogcfg['enable'])) { - $syslogconf .= system_syslogd_get_remote_servers($syslogcfg, "*.*"); - } - if (!empty($logConfig['local'])) { - $syslogd_extra .= system_syslogd_extra_local($logConfig['local']); - } - } - - asort($separatelogfacilities); - $facilitylist = implode(',', array_unique($separatelogfacilities)); - $syslogconf .= "!-{$facilitylist}\n"; + $separatelogfacilities = array(); + foreach ($syslogconfs as $logTopic => $logConfig) { + $syslogconf .= "!".implode(',', $logConfig['facility'])."\n"; + $separatelogfacilities = array_merge($logConfig['facility'], $separatelogfacilities); if (!isset($syslogcfg['disablelocallogging'])) { - /* XXX non-system local redirects look unused */ - $syslogconf .= <<