diff options
author | Ermal <eri@pfsense.org> | 2014-11-10 21:47:14 +0100 |
---|---|---|
committer | Ermal <eri@pfsense.org> | 2014-11-10 21:47:14 +0100 |
commit | d87fcac96b45958bd777c7ac38cc0665dbde6062 (patch) | |
tree | 599a680c39d7db4a859595b17fe65b948def3dc9 /etc/inc/system.inc | |
parent | 24d728bb4feb848b10d42a81df0e0a92dd599764 (diff) | |
download | pfsense-d87fcac96b45958bd777c7ac38cc0665dbde6062.zip pfsense-d87fcac96b45958bd777c7ac38cc0665dbde6062.tar.gz |
Do not require the default sysctl items to be set on the config.xml but rather extract the definitions from the sysctl tree. Also to reduce config.xml size
Diffstat (limited to 'etc/inc/system.inc')
-rw-r--r-- | etc/inc/system.inc | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/etc/inc/system.inc b/etc/inc/system.inc index 273b5a2..87bbdb2 100644 --- a/etc/inc/system.inc +++ b/etc/inc/system.inc @@ -72,13 +72,50 @@ function get_default_sysctl_value($id) { return $sysctls[$id]; } +function get_sysctl_descr($sysctl) { + unset($output); + $_gb = exec("/sbin/sysctl -nd {$sysctl}", $output); + + return $output[0]; +} + +function system_get_sysctls() { + global $config, $sysctls; + + $disp_sysctl = array(); + $disp_cache = array(); + if (is_array($config['sysctl']) && is_array($config['sysctl']['item'])) { + foreach($config['sysctl']['item'] as $id => $tunable) { + if ($tunable['value'] == "default") + $value = get_default_sysctl_value($tunable['tunable']); + else + $value = $tunable['value']; + + $disp_sysctl[$id] = $tunable; + $disp_sysctl[$id]['modified'] = true; + $disp_cache[$tunable['tunable']] = 'set'; + } + } + + foreach ($sysctls as $sysctl => $value) { + if (isset($disp_cache[$sysctl])) + continue; + + $disp_sysctl[$sysctl] = array('tunable' => $sysctl, 'value' => $value, 'descr' => get_sysctl_descr($sysctl)); + + + } + unset($disp_cache); + return $disp_sysctl; +} + function activate_sysctls() { global $config, $g, $sysctls; if ($g['platform'] == 'jail') return; - if (is_array($config['sysctl'])) { + if (is_array($config['sysctl']) && is_array($config['sysctl']['item'])) { foreach($config['sysctl']['item'] as $tunable) { if($tunable['value'] == "default") $value = get_default_sysctl_value($tunable['tunable']); |