Revision 5b17e64c
Added by Reid Linnemann almost 3 years ago
src/etc/inc/system.inc | ||
---|---|---|
25 | 25 |
* limitations under the License. |
26 | 26 |
*/ |
27 | 27 |
|
28 |
require_once('config.lib.inc'); |
|
28 | 29 |
require_once('syslog.inc'); |
29 | 30 |
|
30 | 31 |
function activate_powerd() { |
31 |
global $config, $g; |
|
32 |
|
|
33 | 32 |
if (is_process_running("powerd")) { |
34 | 33 |
exec("/usr/bin/killall powerd"); |
35 | 34 |
} |
36 |
if (isset($config['system']['powerd_enable'])) {
|
|
35 |
if (config_path_enabled('system', 'powerd_enable')) {
|
|
37 | 36 |
$ac_mode = "hadp"; |
38 |
if (!empty($config['system']['powerd_ac_mode'])) {
|
|
39 |
$ac_mode = $config['system']['powerd_ac_mode'];
|
|
37 |
if (!empty(config_get_path('system/powerd_ac_mode'))) {
|
|
38 |
$ac_mode = config_get_path('system/powerd_ac_mode');
|
|
40 | 39 |
} |
41 | 40 |
|
42 | 41 |
$battery_mode = "hadp"; |
43 |
if (!empty($config['system']['powerd_battery_mode'])) {
|
|
44 |
$battery_mode = $config['system']['powerd_battery_mode'];
|
|
42 |
if (!empty(config_get_path('system/powerd_battery_mode'))) {
|
|
43 |
$battery_mode = config_get_path('system/powerd_battery_mode');
|
|
45 | 44 |
} |
46 | 45 |
|
47 | 46 |
$normal_mode = "hadp"; |
48 |
if (!empty($config['system']['powerd_normal_mode'])) {
|
|
49 |
$normal_mode = $config['system']['powerd_normal_mode'];
|
|
47 |
if (!empty(config_get_path('system/powerd_normal_mode'))) {
|
|
48 |
$normal_mode = config_get_path('system/powerd_normal_mode');
|
|
50 | 49 |
} |
51 | 50 |
|
52 | 51 |
mwexec("/usr/sbin/powerd" . |
... | ... | |
72 | 71 |
} |
73 | 72 |
|
74 | 73 |
function system_get_sysctls() { |
75 |
global $config, $sysctls;
|
|
74 |
global $sysctls; |
|
76 | 75 |
|
77 | 76 |
$disp_sysctl = array(); |
78 | 77 |
$disp_cache = array(); |
79 |
if (is_array($config['sysctl']) && is_array($config['sysctl']['item'])) { |
|
80 |
foreach ($config['sysctl']['item'] as $id => $tunable) { |
|
81 |
if ($tunable['value'] == "default") { |
|
82 |
$value = get_default_sysctl_value($tunable['tunable']); |
|
83 |
} else { |
|
84 |
$value = $tunable['value']; |
|
85 |
} |
|
86 |
|
|
87 |
$disp_sysctl[$id] = $tunable; |
|
88 |
$disp_sysctl[$id]['modified'] = true; |
|
89 |
$disp_cache[$tunable['tunable']] = 'set'; |
|
78 |
foreach (config_get_path('sysctl/item', []) as $id => $tunable) { |
|
79 |
if ($tunable['value'] == "default") { |
|
80 |
$value = get_default_sysctl_value($tunable['tunable']); |
|
81 |
} else { |
|
82 |
$value = $tunable['value']; |
|
90 | 83 |
} |
84 |
|
|
85 |
$disp_sysctl[$id] = $tunable; |
|
86 |
$disp_sysctl[$id]['modified'] = true; |
|
87 |
$disp_cache[$tunable['tunable']] = 'set'; |
|
91 | 88 |
} |
92 | 89 |
|
93 | 90 |
foreach ($sysctls as $sysctl => $value) { |
... | ... | |
102 | 99 |
} |
103 | 100 |
|
104 | 101 |
function activate_sysctls() { |
105 |
global $config, $g, $sysctls, $ipsec_filter_sysctl;
|
|
102 |
global $sysctls, $ipsec_filter_sysctl; |
|
106 | 103 |
|
107 | 104 |
if (!is_array($sysctls)) { |
108 | 105 |
$sysctls = array(); |
109 | 106 |
} |
110 | 107 |
|
111 |
$ipsec_filtermode = empty($config['ipsec']['filtermode']) ? 'enc' : $config['ipsec']['filtermode'];
|
|
108 |
$ipsec_filtermode = config_get_path('ipsec/filtermode', 'enc');
|
|
112 | 109 |
$sysctls = array_merge($sysctls, $ipsec_filter_sysctl[$ipsec_filtermode]); |
113 | 110 |
|
114 |
if (is_array($config['sysctl']) && is_array($config['sysctl']['item'])) { |
|
115 |
foreach ($config['sysctl']['item'] as $tunable) { |
|
116 |
if ($tunable['value'] == "default") { |
|
117 |
$value = get_default_sysctl_value($tunable['tunable']); |
|
118 |
} else { |
|
119 |
$value = $tunable['value']; |
|
120 |
} |
|
121 |
|
|
122 |
$sysctls[$tunable['tunable']] = $value; |
|
111 |
foreach (config_get_path('sysctl/item', []) as $tunable) { |
|
112 |
if ($tunable['value'] == "default") { |
|
113 |
$value = get_default_sysctl_value($tunable['tunable']); |
|
114 |
} else { |
|
115 |
$value = $tunable['value']; |
|
123 | 116 |
} |
117 |
|
|
118 |
$sysctls[$tunable['tunable']] = $value; |
|
124 | 119 |
} |
125 | 120 |
|
126 | 121 |
/* Set net.pf.request_maxcount via sysctl since it is no longer a loader |
127 | 122 |
* tunable. See https://redmine.pfsense.org/issues/10861 |
128 | 123 |
* Set the value dynamically since its default is not static, yet this |
129 | 124 |
* still could be overridden by a user tunable. */ |
130 |
if (isset($config['system']['maximumtableentries'])) { |
|
131 |
$maximumtableentries = $config['system']['maximumtableentries']; |
|
132 |
} else { |
|
133 |
$maximumtableentries = pfsense_default_table_entries_size(); |
|
134 |
} |
|
125 |
$maximumtableentries = config_get_path('system/maximumtableentries', |
|
126 |
pfsense_default_table_entries_size()); |
|
127 |
|
|
135 | 128 |
/* Set the default when there is no tunable or when the tunable is set |
136 | 129 |
* too low. */ |
137 | 130 |
if (empty($sysctls['net.pf.request_maxcount']) || |
... | ... | |
143 | 136 |
} |
144 | 137 |
|
145 | 138 |
function system_resolvconf_generate($dynupdate = false) { |
146 |
global $config, $g;
|
|
139 |
global $g; |
|
147 | 140 |
|
148 |
if (isset($config['system']['developerspew'])) {
|
|
141 |
if (config_path_enabled('system', 'developerspew')) {
|
|
149 | 142 |
$mt = microtime(); |
150 | 143 |
echo "system_resolvconf_generate() being called $mt\n"; |
151 | 144 |
} |
152 | 145 |
|
153 |
$syscfg = $config['system'];
|
|
146 |
$syscfg = config_get_path('system', []);
|
|
154 | 147 |
|
155 | 148 |
foreach(get_dns_nameservers(false, false) as $dns_ns) { |
156 | 149 |
$resolvconf .= "nameserver $dns_ns\n"; |
... | ... | |
174 | 167 |
} |
175 | 168 |
|
176 | 169 |
// Add EDNS support |
177 |
if (isset($config['unbound']['enable']) && isset($config['unbound']['edns'])) {
|
|
170 |
if (config_path_enabled('unbound') && (config_get_path('unbound', 'edns') != null)) {
|
|
178 | 171 |
$resolvconf .= "options edns0\n"; |
179 | 172 |
} |
180 | 173 |
|
... | ... | |
209 | 202 |
// set up or tear down static routes for DNS servers |
210 | 203 |
$dnscounter = 1; |
211 | 204 |
$dnsgw = "dns{$dnscounter}gw"; |
212 |
while (isset($config['system'][$dnsgw])) {
|
|
205 |
while (!empty(config_get_path('system/{$dnsgw}'))) {
|
|
213 | 206 |
/* setup static routes for dns servers */ |
214 |
$gwname = $config['system'][$dnsgw]; |
|
215 |
unset($gatewayip); |
|
207 |
$gwname = config_get_path('system/{$dnsgw}'); unset($gatewayip); |
|
216 | 208 |
unset($inet6); |
217 | 209 |
if ((!empty($gwname)) && ($gwname != "none")) { |
218 | 210 |
$gatewayip = lookup_gateway_ip_by_name($gwname); |
... | ... | |
246 | 238 |
} |
247 | 239 |
|
248 | 240 |
function get_searchdomains() { |
249 |
global $config, $g; |
|
250 |
|
|
251 | 241 |
$master_list = array(); |
252 | 242 |
|
253 | 243 |
// Read in dhclient nameservers |
... | ... | |
284 | 274 |
* $master_list - Array containing DNS servers |
285 | 275 |
******/ |
286 | 276 |
function get_dynamic_nameservers($iface = '') { |
287 |
global $config, $g; |
|
288 | 277 |
$master_list = array(); |
289 | 278 |
|
290 | 279 |
if (!empty($iface)) { |
... | ... | |
312 | 301 |
|
313 | 302 |
/* Create localhost + local interfaces entries for /etc/hosts */ |
314 | 303 |
function system_hosts_local_entries() { |
315 |
global $config; |
|
316 |
|
|
317 |
$syscfg = $config['system']; |
|
304 |
$syscfg = config_get_path('system', []); |
|
318 | 305 |
|
319 | 306 |
$hosts = array(); |
320 | 307 |
$hosts[] = array( |
... | ... | |
330 | 317 |
'domain' => $syscfg['domain'] |
331 | 318 |
); |
332 | 319 |
|
333 |
if ($config['interfaces']['lan']) {
|
|
320 |
if (config_get_path('interfaces/lan')) {
|
|
334 | 321 |
$sysiflist = array('lan' => "lan"); |
335 | 322 |
} else { |
336 | 323 |
$sysiflist = get_configured_interface_list(); |
... | ... | |
426 | 413 |
|
427 | 414 |
/* Read all dhcpd/dhcpdv6 staticmap entries */ |
428 | 415 |
function system_hosts_dhcpd_entries() { |
429 |
global $config; |
|
430 |
|
|
431 | 416 |
$hosts = array(); |
432 |
$syscfg = $config['system'];
|
|
417 |
$syscfg = config_get_path('system');
|
|
433 | 418 |
|
434 |
if (is_array($config['dhcpd'])) { |
|
435 |
$conf_dhcpd = $config['dhcpd']; |
|
436 |
} else { |
|
437 |
$conf_dhcpd = array(); |
|
438 |
} |
|
419 |
$conf_dhcpd = config_get_path('dhcpd', []); |
|
439 | 420 |
|
440 | 421 |
foreach ($conf_dhcpd as $dhcpif => $dhcpifconf) { |
441 | 422 |
if (!is_array($dhcpifconf['staticmap']) || |
... | ... | |
468 | 449 |
} |
469 | 450 |
unset($conf_dhcpd); |
470 | 451 |
|
471 |
if (is_array($config['dhcpdv6'])) { |
|
472 |
$conf_dhcpdv6 = $config['dhcpdv6']; |
|
473 |
} else { |
|
474 |
$conf_dhcpdv6 = array(); |
|
475 |
} |
|
452 |
$conf_dhcpdv6 = config_get_path('dhcpdv6', []); |
|
476 | 453 |
|
477 | 454 |
foreach ($conf_dhcpdv6 as $dhcpif => $dhcpifconf) { |
478 | 455 |
if (!is_array($dhcpifconf['staticmap']) || |
... | ... | |
480 | 457 |
continue; |
481 | 458 |
} |
482 | 459 |
|
483 |
if (isset($config['interfaces'][$dhcpif]['ipaddrv6']) && |
|
484 |
$config['interfaces'][$dhcpif]['ipaddrv6'] == |
|
460 |
if (config_get_path("interfaces/{$dhcpif}/ipaddrv6") == |
|
485 | 461 |
'track6') { |
486 | 462 |
$isdelegated = true; |
487 | 463 |
} else { |
... | ... | |
553 | 529 |
} |
554 | 530 |
|
555 | 531 |
function system_hosts_generate() { |
556 |
global $config, $g;
|
|
557 |
if (isset($config['system']['developerspew'])) {
|
|
532 |
global $g; |
|
533 |
if (config_path_enabled('system', 'developerspew')) {
|
|
558 | 534 |
$mt = microtime(); |
559 | 535 |
echo "system_hosts_generate() being called $mt\n"; |
560 | 536 |
} |
561 | 537 |
|
562 | 538 |
// prefer dnsmasq for hosts generation where it's enabled. It relies |
563 | 539 |
// on hosts for name resolution of its overrides, unbound does not. |
564 |
if (isset($config['dnsmasq']) && isset($config['dnsmasq']['enable'])) {
|
|
565 |
$dnsmasqcfg = $config['dnsmasq'];
|
|
540 |
if (config_path_enabled('dnsmasq')) {
|
|
541 |
$dnsmasqcfg = config_get_path('dnsmasq');
|
|
566 | 542 |
} else { |
567 |
$dnsmasqcfg = $config['unbound'];
|
|
543 |
$dnsmasqcfg = config_get_path('unbound');
|
|
568 | 544 |
} |
569 | 545 |
|
570 |
$syscfg = $config['system'];
|
|
546 |
$syscfg = config_get_path('system');
|
|
571 | 547 |
$hosts = ""; |
572 | 548 |
$lhosts = ""; |
573 | 549 |
$dhosts = ""; |
... | ... | |
604 | 580 |
fwrite($fd, $hosts); |
605 | 581 |
fclose($fd); |
606 | 582 |
|
607 |
if (isset($config['unbound']['enable'])) {
|
|
583 |
if (config_path_enabled('unbound')) {
|
|
608 | 584 |
require_once("unbound.inc"); |
609 | 585 |
unbound_hosts_generate(); |
610 | 586 |
} |
... | ... | |
618 | 594 |
} |
619 | 595 |
|
620 | 596 |
function system_dhcpleases_configure() { |
621 |
global $config, $g;
|
|
597 |
global $g; |
|
622 | 598 |
if (!function_exists('is_dhcp_server_enabled')) { |
623 | 599 |
require_once('pfsense-utils.inc'); |
624 | 600 |
} |
625 | 601 |
$pidfile = "{$g['varrun_path']}/dhcpleases.pid"; |
626 | 602 |
|
627 | 603 |
/* Start the monitoring process for dynamic dhcpclients. */ |
628 |
if (((isset($config['dnsmasq']['enable']) && isset($config['dnsmasq']['regdhcp'])) ||
|
|
629 |
(isset($config['unbound']['enable']) && isset($config['unbound']['regdhcp']))) &&
|
|
604 |
if (((config_path_enabled('dnsmasq') && (config_get_path('dnsmasq', 'regdhcp') != null)) ||
|
|
605 |
(config_path_enabled('unbound') && (config_get_path('unbound', 'regdhcp') != null))) &&
|
|
630 | 606 |
(is_dhcp_server_enabled())) { |
631 | 607 |
/* Make sure we do not error out */ |
632 | 608 |
mwexec("/bin/mkdir -p {$g['dhcpd_chroot_path']}/var/db"); |
... | ... | |
634 | 610 |
@touch("{$g['dhcpd_chroot_path']}/var/db/dhcpd.leases"); |
635 | 611 |
} |
636 | 612 |
|
637 |
if (isset($config['unbound']['enable'])) {
|
|
613 |
if (config_path_enabled('unbound')) {
|
|
638 | 614 |
$dns_pid = "unbound.pid"; |
639 | 615 |
$unbound_conf = "-u {$g['unbound_chroot_path']}/dhcpleases_entries.conf"; |
640 | 616 |
} else { |
... | ... | |
658 | 634 |
sigkillbyname('dhcpleases', "TERM"); |
659 | 635 |
} |
660 | 636 |
@unlink($pidfile); |
661 |
mwexec("/usr/local/sbin/dhcpleases -l {$g['dhcpd_chroot_path']}/var/db/dhcpd.leases -d {$config['system']['domain']} -p {$g['varrun_path']}/{$dns_pid} {$unbound_conf} -h {$g['etc_path']}/hosts"); |
|
637 |
mwexec("/usr/local/sbin/dhcpleases -l {$g['dhcpd_chroot_path']}/var/db/dhcpd.leases -d " . |
|
638 |
config_get_path('system/domain', '') . |
|
639 |
" -p {$g['varrun_path']}/{$dns_pid} {$unbound_conf} -h {$g['etc_path']}/hosts"); |
|
662 | 640 |
} else { |
663 | 641 |
if (isvalidpid($pidfile)) { |
664 | 642 |
sigkillbypid($pidfile, "TERM"); |
... | ... | |
673 | 651 |
} |
674 | 652 |
|
675 | 653 |
function system_get_dhcpleases($dnsavailable=null) { |
676 |
global $config, $g;
|
|
654 |
global $g; |
|
677 | 655 |
|
678 | 656 |
$leases = array(); |
679 | 657 |
$leases['lease'] = array(); |
... | ... | |
838 | 816 |
} |
839 | 817 |
} |
840 | 818 |
|
841 |
foreach ($config['interfaces'] as $ifname => $ifarr) { |
|
842 |
if (!is_array($config['dhcpd'][$ifname]) || |
|
843 |
!is_array($config['dhcpd'][$ifname]['staticmap'])) { |
|
844 |
continue; |
|
845 |
} |
|
846 |
|
|
847 |
foreach ($config['dhcpd'][$ifname]['staticmap'] as $idx => |
|
819 |
foreach (config_get_path('interfaces', []) as $ifname => $ifarr) { |
|
820 |
foreach (config_get_path("dhcpd/{$ifname}/staticmap", []) as $idx => |
|
848 | 821 |
$static) { |
849 | 822 |
if (empty($static['mac']) && empty($static['cid'])) { |
850 | 823 |
continue; |
... | ... | |
885 | 858 |
} |
886 | 859 |
|
887 | 860 |
function system_hostname_configure() { |
888 |
global $config, $g; |
|
889 |
if (isset($config['system']['developerspew'])) { |
|
861 |
if (config_path_enabled('system', 'developerspew')) { |
|
890 | 862 |
$mt = microtime(); |
891 | 863 |
echo "system_hostname_configure() being called $mt\n"; |
892 | 864 |
} |
893 | 865 |
|
894 |
$syscfg = $config['system'];
|
|
866 |
$syscfg = config_get_path('system');
|
|
895 | 867 |
|
896 | 868 |
/* set hostname */ |
897 | 869 |
$status = mwexec("/bin/hostname " . |
... | ... | |
904 | 876 |
} |
905 | 877 |
|
906 | 878 |
function system_routing_configure($interface = "") { |
907 |
global $config, $g; |
|
908 |
|
|
909 |
if (isset($config['system']['developerspew'])) { |
|
879 |
if (config_path_enabled('system', 'developerspew')) { |
|
910 | 880 |
$mt = microtime(); |
911 | 881 |
echo "system_routing_configure() being called $mt\n"; |
912 | 882 |
} |
... | ... | |
934 | 904 |
} |
935 | 905 |
|
936 | 906 |
function system_staticroutes_configure($interface = "", $update_dns = false) { |
937 |
global $config, $g, $aliastable;
|
|
907 |
global $g, $aliastable; |
|
938 | 908 |
|
939 | 909 |
$filterdns_list = array(); |
940 | 910 |
|
... | ... | |
1045 | 1015 |
/* keep static routes cache, |
1046 | 1016 |
* see https://redmine.pfsense.org/issues/11599 */ |
1047 | 1017 |
$id = 0; |
1048 |
foreach ($config['staticroutes']['route'] as $sroute) {
|
|
1018 |
foreach (config_get_path('staticroutes/route', []) as $sroute) {
|
|
1049 | 1019 |
$targets = array(); |
1050 | 1020 |
if (is_subnet($sroute['network'])) { |
1051 | 1021 |
$targets[] = $sroute['network']; |
... | ... | |
1097 | 1067 |
} |
1098 | 1068 |
|
1099 | 1069 |
function delete_static_route($id, $delete = false) { |
1100 |
global $g, $config, $changedesc_prefix, $a_gateways;
|
|
1070 |
global $g, $changedesc_prefix, $a_gateways; |
|
1101 | 1071 |
|
1102 |
if (!isset($config['staticroutes']['route'][$id])) {
|
|
1072 |
if (empty(config_get_path("staticroutes/route/{$id}"))) {
|
|
1103 | 1073 |
return; |
1104 | 1074 |
} |
1105 | 1075 |
|
... | ... | |
1143 | 1113 |
} |
1144 | 1114 |
|
1145 | 1115 |
function system_routing_enable() { |
1146 |
global $config, $g; |
|
1147 |
if (isset($config['system']['developerspew'])) { |
|
1116 |
if (config_path_enabled('system', 'developerspew')) { |
|
1148 | 1117 |
$mt = microtime(); |
1149 | 1118 |
echo "system_routing_enable() being called $mt\n"; |
1150 | 1119 |
} |
... | ... | |
1158 | 1127 |
} |
1159 | 1128 |
|
1160 | 1129 |
function system_webgui_create_certificate() { |
1161 |
global $config, $g, $cert_strict_values;
|
|
1130 |
global $g, $cert_strict_values; |
|
1162 | 1131 |
|
1163 | 1132 |
init_config_arr(array('ca')); |
1164 |
$a_ca = &$config['ca'];
|
|
1133 |
$a_ca = config_get_path('ca');
|
|
1165 | 1134 |
init_config_arr(array('cert')); |
1166 |
$a_cert = &$config['cert'];
|
|
1135 |
$a_cert = config_get_path('cert');
|
|
1167 | 1136 |
log_error(gettext("Creating SSL/TLS Certificate for this host")); |
1168 | 1137 |
|
1169 | 1138 |
$cert = array(); |
1170 | 1139 |
$cert['refid'] = uniqid(); |
1171 | 1140 |
$cert['descr'] = sprintf(gettext("webConfigurator default (%s)"), $cert['refid']); |
1172 |
$cert_hostname = "{$config['system']['hostname']}-{$cert['refid']}"; |
|
1141 |
$hostname = config_get_path('system/hostname'); |
|
1142 |
$cert_hostname = "{$hostname}-{$cert['refid']}"; |
|
1173 | 1143 |
|
1174 | 1144 |
$dn = array( |
1175 | 1145 |
'organizationName' => "{$g['product_label']} webConfigurator Self-Signed Certificate", |
... | ... | |
1186 | 1156 |
error_reporting($old_err_level); |
1187 | 1157 |
|
1188 | 1158 |
$a_cert[] = $cert; |
1189 |
$config['system']['webgui']['ssl-certref'] = $cert['refid']; |
|
1159 |
config_set_path('cert', $a_cert); |
|
1160 |
config_set_path('system/webgui/ssl-certref', $cert['refid']); |
|
1190 | 1161 |
write_config(sprintf(gettext("Generated new self-signed SSL/TLS certificate for HTTPS (%s)"), $cert['refid'])); |
1191 | 1162 |
return $cert; |
1192 | 1163 |
} |
1193 | 1164 |
|
1194 | 1165 |
function system_webgui_start() { |
1195 |
global $config, $g;
|
|
1166 |
global $g; |
|
1196 | 1167 |
|
1197 | 1168 |
if (platform_booting()) { |
1198 | 1169 |
echo gettext("Starting webConfigurator..."); |
... | ... | |
1201 | 1172 |
chdir($g['www_path']); |
1202 | 1173 |
|
1203 | 1174 |
/* defaults */ |
1204 |
$portarg = "80";
|
|
1175 |
$portarg = config_get_path('system/webgui/port', '80');
|
|
1205 | 1176 |
$crt = ""; |
1206 | 1177 |
$key = ""; |
1207 | 1178 |
$ca = ""; |
1208 | 1179 |
|
1209 |
/* non-standard port? */ |
|
1210 |
if (isset($config['system']['webgui']['port']) && $config['system']['webgui']['port'] <> "") { |
|
1211 |
$portarg = "{$config['system']['webgui']['port']}"; |
|
1212 |
} |
|
1213 |
|
|
1214 |
if ($config['system']['webgui']['protocol'] == "https") { |
|
1180 |
if (config_get_path('system/webgui/protocol') == "https") { |
|
1215 | 1181 |
// Ensure that we have a webConfigurator CERT |
1216 |
$cert =& lookup_cert($config['system']['webgui']['ssl-certref']);
|
|
1182 |
$cert =& lookup_cert(config_get_path('system/webgui/ssl-certref'));
|
|
1217 | 1183 |
if (!is_array($cert) || !$cert['crt'] || !$cert['prv']) { |
1218 | 1184 |
$cert = system_webgui_create_certificate(); |
1219 | 1185 |
} |
1220 | 1186 |
$crt = base64_decode($cert['crt']); |
1221 | 1187 |
$key = base64_decode($cert['prv']); |
1222 | 1188 |
|
1223 |
if (!$config['system']['webgui']['port']) { |
|
1224 |
$portarg = "443"; |
|
1225 |
} |
|
1189 |
$portarg = config_get_path('system/webgui/port', '443'); |
|
1226 | 1190 |
$ca = ca_chain($cert); |
1227 |
$hsts = isset($config['system']['webgui']['disablehsts']) ? false : true;
|
|
1191 |
$hsts = !config_path_enabled('system/webgui', 'disablehsts');
|
|
1228 | 1192 |
} |
1229 | 1193 |
|
1230 | 1194 |
/* generate nginx configuration */ |
... | ... | |
1269 | 1233 |
* $dns_nameservers - An array of the requested DNS servers |
1270 | 1234 |
******/ |
1271 | 1235 |
function get_dns_nameservers($add_v6_brackets = false, $hostns=true) { |
1272 |
global $config; |
|
1273 |
|
|
1274 | 1236 |
$dns_nameservers = array(); |
1275 | 1237 |
|
1276 |
if (isset($config['system']['developerspew'])) {
|
|
1238 |
if (config_path_enabled('system', 'developerspew')) {
|
|
1277 | 1239 |
$mt = microtime(); |
1278 | 1240 |
echo "get_dns_nameservers() being called $mt\n"; |
1279 | 1241 |
} |
1280 | 1242 |
|
1281 |
$syscfg = $config['system']; |
|
1282 |
if ((((isset($config['dnsmasq']['enable'])) && |
|
1283 |
(empty($config['dnsmasq']['port']) || $config['dnsmasq']['port'] == "53") && |
|
1284 |
(empty($config['dnsmasq']['interface']) || |
|
1285 |
in_array("lo0", explode(",", $config['dnsmasq']['interface'])))) || |
|
1286 |
((isset($config['unbound']['enable'])) && |
|
1287 |
(empty($config['unbound']['port']) || $config['unbound']['port'] == "53") && |
|
1288 |
(empty($config['unbound']['active_interface']) || |
|
1289 |
in_array("lo0", explode(",", $config['unbound']['active_interface'])) || |
|
1290 |
in_array("all", explode(",", $config['unbound']['active_interface']), true)))) && |
|
1291 |
($config['system']['dnslocalhost'] != 'remote')) { |
|
1243 |
$syscfg = config_get_path('system'); |
|
1244 |
if ((((config_path_enabled('dnsmasq')) && |
|
1245 |
(config_get_path('dnsmasq/port', '53') == '53') && |
|
1246 |
in_array("lo0", explode(",", config_get_path('dnsmasq/interface', 'lo0'))))) || |
|
1247 |
(config_path_enabled('unbound') && |
|
1248 |
(config_get_path('unbound/port', '53') == '53') && |
|
1249 |
(in_array("lo0", explode(",", config_get_path('unbound/active_interface', 'lo0'))) || |
|
1250 |
in_array("all", explode(",", config_get_path('unbound/active_interface', 'all')), true))) && |
|
1251 |
(config_get_path('system/dnslocalhost') != 'remote')) { |
|
1292 | 1252 |
$dns_nameservers[] = "127.0.0.1"; |
1293 | 1253 |
} |
1294 | 1254 |
|
1295 |
if ($hostns || ($config['system']['dnslocalhost'] != 'local')) {
|
|
1255 |
if ($hostns || (config_get_path('system/dnslocalhost') != 'local')) {
|
|
1296 | 1256 |
if (isset($syscfg['dnsallowoverride'])) { |
1297 | 1257 |
/* get dynamically assigned DNS servers (if any) */ |
1298 | 1258 |
foreach (array_unique(get_dynamic_nameservers()) as $nameserver) { |
... | ... | |
1330 | 1290 |
$captive_portal = false, |
1331 | 1291 |
$hsts = true) { |
1332 | 1292 |
|
1333 |
global $config, $g;
|
|
1293 |
global $g; |
|
1334 | 1294 |
|
1335 |
if (isset($config['system']['developerspew'])) {
|
|
1295 |
if (config_path_enabled('system', 'developerspew')) {
|
|
1336 | 1296 |
$mt = microtime(); |
1337 | 1297 |
echo "system_generate_nginx_config() being called $mt\n"; |
1338 | 1298 |
} |
1339 | 1299 |
|
1340 | 1300 |
if ($captive_portal !== false) { |
1341 |
$cp_interfaces = explode(",", $config['captiveportal'][$captive_portal]['interface']);
|
|
1301 |
$cp_interfaces = explode(",", config_get_path('captiveportal/{$captive_portal}/interface'));
|
|
1342 | 1302 |
$cp_hostcheck = ""; |
1343 | 1303 |
foreach ($cp_interfaces as $cpint) { |
1344 | 1304 |
$cpint_ip = get_interface_ip($cpint); |
... | ... | |
1348 | 1308 |
$cp_hostcheck .= "\t\t}\n"; |
1349 | 1309 |
} |
1350 | 1310 |
} |
1351 |
if (isset($config['captiveportal'][$captive_portal]['httpsname']) && |
|
1352 |
is_domain($config['captiveportal'][$captive_portal]['httpsname'])) { |
|
1353 |
$cp_hostcheck .= "\t\tif (\$http_host ~* {$config['captiveportal'][$captive_portal]['httpsname']}) {\n"; |
|
1311 |
$httpsname = config_get_path('captiveportal/{$captive_portal}/httpsname'); |
|
1312 |
if (!empty($httpsname) && |
|
1313 |
is_domain($httpsname)) { |
|
1314 |
$cp_hostcheck .= "\t\tif (\$http_host ~* {$httpsname}) {\n"; |
|
1354 | 1315 |
$cp_hostcheck .= "\t\t\tset \$cp_redirect no;\n"; |
1355 | 1316 |
$cp_hostcheck .= "\t\t}\n"; |
1356 | 1317 |
} |
... | ... | |
1358 | 1319 |
$cp_rewrite .= "\t\t\trewrite ^ /index.php?zone=$captive_portal&redirurl=\$request_uri break;\n"; |
1359 | 1320 |
$cp_rewrite .= "\t\t}\n"; |
1360 | 1321 |
|
1361 |
$maxprocperip = $config['captiveportal'][$captive_portal]['maxprocperip'];
|
|
1322 |
$maxprocperip = config_get_path('captiveportal/{$captive_portal}/maxprocperip');
|
|
1362 | 1323 |
if (empty($maxprocperip)) { |
1363 | 1324 |
$maxprocperip = 10; |
1364 | 1325 |
} |
... | ... | |
1378 | 1339 |
if ($realmem < 255) { |
1379 | 1340 |
$max_procs = 1; |
1380 | 1341 |
} else { |
1381 |
$max_procs = ($config['system']['webgui']['max_procs']) ? $config['system']['webgui']['max_procs'] : 2;
|
|
1342 |
$max_procs = config_get_path('system/webgui/max_procs', 2);
|
|
1382 | 1343 |
} |
1383 | 1344 |
|
1384 | 1345 |
// Ramp up captive portal max procs, assuming each PHP process can consume up to 64MB RAM |
... | ... | |
1405 | 1366 |
|
1406 | 1367 |
/* Disable file logging */ |
1407 | 1368 |
$nginx_config .= "error_log /dev/null;\n"; |
1408 |
if (!isset($config['syslog']['nolognginx'])) {
|
|
1369 |
if (!config_path_enabled('syslog', 'nolognginx')) {
|
|
1409 | 1370 |
/* Send nginx error log to syslog */ |
1410 | 1371 |
$nginx_config .= "error_log syslog:server=unix:/var/run/log,facility=local5;\n"; |
1411 | 1372 |
} |
... | ... | |
1460 | 1421 |
$nginx_config .= "\t\tadd_header X-Content-Type-Options nosniff;\n"; |
1461 | 1422 |
$nginx_config .= "\t\tssl_session_tickets off;\n"; |
1462 | 1423 |
$nginx_config .= "\t\tssl_dhparam /etc/dh-parameters.4096;\n"; |
1463 |
$cert_temp = lookup_cert($config['system']['webgui']['ssl-certref']);
|
|
1464 |
if (($config['system']['webgui']['ocsp-staple'] == true) or
|
|
1424 |
$cert_temp = lookup_cert(config_get_path('system/webgui/ssl-certref'));
|
|
1425 |
if ((config_get_path('system/webgui/ocsp-staple') == true) or
|
|
1465 | 1426 |
(cert_get_ocspstaple($cert_temp['crt']) == true)) { |
1466 | 1427 |
$nginx_config .= "\t\tssl_stapling on;\n"; |
1467 | 1428 |
$nginx_config .= "\t\tssl_stapling_verify on;\n"; |
... | ... | |
1563 | 1524 |
} |
1564 | 1525 |
|
1565 | 1526 |
// Add HTTP to HTTPS redirect |
1566 |
if ($captive_portal === false && $config['system']['webgui']['protocol'] == "https" && !isset($config['system']['webgui']['disablehttpredirect'])) {
|
|
1527 |
if ($captive_portal === false && config_get_path('system/webgui/protocol') == "https" && !(config_path_enabled('system/webgui', 'disablehttpredirect') != null)) {
|
|
1567 | 1528 |
if ($nginx_port != "443") { |
1568 | 1529 |
$redirectport = ":{$nginx_port}"; |
1569 | 1530 |
} |
... | ... | |
1621 | 1582 |
} |
1622 | 1583 |
|
1623 | 1584 |
function system_timezone_configure() { |
1624 |
global $config, $g;
|
|
1625 |
if (isset($config['system']['developerspew'])) {
|
|
1585 |
global $g; |
|
1586 |
if (config_path_enabled('system', 'developerspew')) {
|
|
1626 | 1587 |
$mt = microtime(); |
1627 | 1588 |
echo "system_timezone_configure() being called $mt\n"; |
1628 | 1589 |
} |
1629 | 1590 |
|
1630 |
$syscfg = $config['system'];
|
|
1591 |
$syscfg = config_get_path('system');
|
|
1631 | 1592 |
|
1632 | 1593 |
if (platform_booting()) { |
1633 | 1594 |
echo gettext("Setting timezone..."); |
... | ... | |
1742 | 1703 |
} |
1743 | 1704 |
|
1744 | 1705 |
function system_ntp_setup_gps($serialport) { |
1745 |
global $config, $g; |
|
1746 |
|
|
1747 |
if (is_array($config['ntpd']) && ($config['ntpd']['enable'] == 'disabled')) { |
|
1706 |
if (config_get_path('ntpd/enable') == 'disabled') { |
|
1748 | 1707 |
return false; |
1749 | 1708 |
} |
1750 | 1709 |
|
... | ... | |
1766 | 1725 |
unlink_if_exists($gps_device); |
1767 | 1726 |
@symlink($serialport, $gps_device); |
1768 | 1727 |
|
1769 |
$gpsbaud = '4800'; |
|
1770 | 1728 |
$speeds = array( |
1771 | 1729 |
0 => '4800', |
1772 | 1730 |
16 => '9600', |
... | ... | |
1775 | 1733 |
64 => '57600', |
1776 | 1734 |
80 => '115200' |
1777 | 1735 |
); |
1778 |
if (!empty($config['ntpd']['gps']['speed']) && array_key_exists($config['ntpd']['gps']['speed'], $speeds)) { |
|
1779 |
$gpsbaud = $speeds[$config['ntpd']['gps']['speed']]; |
|
1780 |
} |
|
1736 |
// $gpsbaud defaults to '4800' if ntpd/gps/speed is unset or does not exist in $speeds |
|
1737 |
$gpsbaud = array_get_path($speeds, config_get_path('ntpd/gps/speed', 0), '4800'); |
|
1781 | 1738 |
|
1782 | 1739 |
system_ntp_setup_rawspeed($serialport, $gpsbaud); |
1783 | 1740 |
|
1784 |
$autospeed = ($config['ntpd']['gps']['speed'] == 'autoalways' || $config['ntpd']['gps']['speed'] == 'autoset'); |
|
1785 |
if ($autospeed || ($config['ntpd']['gps']['autobaudinit'] && !check_gps_speed($gps_device))) { |
|
1741 |
$gpsspeed = config_get_path('ntpd/gps/speed'); |
|
1742 |
$autospeed = ($gpsspeed == 'autoalways' || $gpsspeed == 'autoset'); |
|
1743 |
if ($autospeed || (config_get_path('ntpd/gps/autobaudinit') && !check_gps_speed($gps_device))) { |
|
1786 | 1744 |
$found = false; |
1787 | 1745 |
foreach ($speeds as $baud) { |
1788 | 1746 |
system_ntp_setup_rawspeed($serialport, $baud); |
1789 | 1747 |
if ($found = check_gps_speed($gps_device)) { |
1790 | 1748 |
if ($autospeed) { |
1791 |
$saveconfig = ($config['ntpd']['gps']['speed'] == 'autoset');
|
|
1792 |
$config['ntpd']['gps']['speed'] = array_search($baud, $speeds);
|
|
1749 |
$saveconfig = (config_get_path('ntpd/gps/speed') == 'autoset');
|
|
1750 |
config_set_path('ntpd/gps/speed', array_search($baud, $speeds));
|
|
1793 | 1751 |
$gpsbaud = $baud; |
1794 | 1752 |
if ($saveconfig) { |
1795 | 1753 |
write_config(sprintf(gettext('Autoset GPS baud rate to %s'), $baud)); |
... | ... | |
1805 | 1763 |
} |
1806 | 1764 |
|
1807 | 1765 |
/* Send the following to the GPS port to initialize the GPS */ |
1808 |
if (is_array($config['ntpd']) && is_array($config['ntpd']['gps']) && !empty($config['ntpd']['gps']['type'])) {
|
|
1809 |
$gps_init = base64_decode($config['ntpd']['gps']['initcmd']);
|
|
1766 |
if (!empty(config_get_path('ntpd/gps/type'))) {
|
|
1767 |
$gps_init = base64_decode(config_get_path('ntpd/gps/initcmd'));
|
|
1810 | 1768 |
} else { |
1811 | 1769 |
$gps_init = base64_decode('JFBVQlgsNDAsR1NWLDAsMCwwLDAqNTkNCiRQVUJYLDQwLEdMTCwwLDAsMCwwKjVDDQokUFVCWCw0MCxaREEsMCwwLDAsMCo0NA0KJFBVQlgsNDAsVlRHLDAsMCwwLDAqNUUNCiRQVUJYLDQwLEdTViwwLDAsMCwwKjU5DQokUFVCWCw0MCxHU0EsMCwwLDAsMCo0RQ0KJFBVQlgsNDAsR0dBLDAsMCwwLDANCiRQVUJYLDQwLFRYVCwwLDAsMCwwDQokUFVCWCw0MCxSTUMsMCwwLDAsMCo0Ng0KJFBVQlgsNDEsMSwwMDA3LDAwMDMsNDgwMCwwDQokUFVCWCw0MCxaREEsMSwxLDEsMQ=='); |
1812 | 1770 |
} |
... | ... | |
1815 | 1773 |
@file_put_contents('/tmp/gps.init', $gps_init); |
1816 | 1774 |
mwexec("/bin/cat /tmp/gps.init > {$serialport}"); |
1817 | 1775 |
|
1818 |
if ($found && $config['ntpd']['gps']['autobaudinit']) {
|
|
1776 |
if ($found && config_get_path('ntpd/gps/autobaudinit')) {
|
|
1819 | 1777 |
system_ntp_setup_rawspeed($serialport, $gpsbaud); |
1820 | 1778 |
} |
1821 | 1779 |
|
... | ... | |
1839 | 1797 |
} |
1840 | 1798 |
|
1841 | 1799 |
function system_ntp_setup_pps($serialport) { |
1842 |
global $config, $g; |
|
1843 |
|
|
1844 | 1800 |
$serialports = get_serial_ports(true); |
1845 | 1801 |
|
1846 | 1802 |
if (!array_key_exists($serialport, $serialports)) { |
... | ... | |
1854 | 1810 |
return false; |
1855 | 1811 |
} |
1856 | 1812 |
// If ntpd is disabled, just return |
1857 |
if (is_array($config['ntpd']) && ($config['ntpd']['enable'] == 'disabled')) {
|
|
1813 |
if (config_get_path('ntpd/enable') == 'disabled') {
|
|
1858 | 1814 |
return false; |
1859 | 1815 |
} |
1860 | 1816 |
|
... | ... | |
1867 | 1823 |
} |
1868 | 1824 |
|
1869 | 1825 |
function system_ntp_configure() { |
1870 |
global $config, $g;
|
|
1826 |
global $g; |
|
1871 | 1827 |
global $ntp_poll_min_default_gps, $ntp_poll_max_default_gps; |
1872 | 1828 |
global $ntp_poll_min_default_pps, $ntp_poll_max_default_pps; |
1873 | 1829 |
global $ntp_poll_min_default, $ntp_poll_max_default; |
... | ... | |
1878 | 1834 |
|
1879 | 1835 |
safe_mkdir($statsdir); |
1880 | 1836 |
|
1881 |
if (!is_array($config['ntpd'])) { |
|
1882 |
$config['ntpd'] = array(); |
|
1883 |
} |
|
1837 |
init_config_arr('ntpd'); |
|
1838 |
|
|
1884 | 1839 |
// ntpd is disabled, just stop it and return |
1885 |
if ($config['ntpd']['enable'] == 'disabled') {
|
|
1840 |
if (config_get_path('ntpd/enable') == 'disabled') {
|
|
1886 | 1841 |
while (isvalidpid("{$g['varrun_path']}/ntpd.pid")) { |
1887 | 1842 |
killbypid("{$g['varrun_path']}/ntpd.pid"); |
1888 | 1843 |
} |
... | ... | |
1904 | 1859 |
@unlink("{$g['varrun_path']}/ntpd.pid"); |
1905 | 1860 |
|
1906 | 1861 |
/* set NTP server authentication key */ |
1907 |
if ($config['ntpd']['serverauth'] == 'yes') {
|
|
1908 |
$ntpkeyscfg = "1 " . strtoupper($config['ntpd']['serverauthalgo']) . " " . base64_decode($config['ntpd']['serverauthkey']) . "\n";
|
|
1862 |
if (config_get_path('ntpd/serverauth') == 'yes') {
|
|
1863 |
$ntpkeyscfg = "1 " . strtoupper(config_get_path('ntpd/serverauthalgo')) . " " . base64_decode(config_get_path('ntpd/serverauthkey')) . "\n";
|
|
1909 | 1864 |
if (!@file_put_contents("{$g['varetc_path']}/ntp.keys", $ntpkeyscfg)) { |
1910 | 1865 |
log_error(sprintf(gettext("Could not open %s/ntp.keys for writing"), $g['varetc_path'])); |
1911 | 1866 |
return; |
... | ... | |
1919 | 1874 |
$ntpcfg .= "# \n\n"; |
1920 | 1875 |
$ntpcfg .= "tinker panic 0 \n\n"; |
1921 | 1876 |
|
1922 |
if ($config['ntpd']['serverauth'] == 'yes') {
|
|
1877 |
if (config_get_path('ntpd/serverauth') == 'yes') {
|
|
1923 | 1878 |
$ntpcfg .= "# Authentication settings \n"; |
1924 | 1879 |
$ntpcfg .= "keys /var/etc/ntp.keys \n"; |
1925 | 1880 |
$ntpcfg .= "trustedkey 1 \n"; |
... | ... | |
1931 | 1886 |
/* Add Orphan mode */ |
1932 | 1887 |
$ntpcfg .= "# Orphan mode stratum and Maximum candidate NTP peers\n"; |
1933 | 1888 |
$ntpcfg .= 'tos orphan '; |
1934 |
if (!empty($config['ntpd']['orphan'])) {
|
|
1935 |
$ntpcfg .= $config['ntpd']['orphan'];
|
|
1889 |
if (!empty(config_get_path('ntpd/orphan'))) {
|
|
1890 |
$ntpcfg .= config_get_path('ntpd/orphan');
|
|
1936 | 1891 |
} else { |
1937 | 1892 |
$ntpcfg .= '12'; |
1938 | 1893 |
} |
1939 | 1894 |
/* Add Maximum candidate NTP peers */ |
1940 | 1895 |
$ntpcfg .= ' maxclock '; |
1941 |
if (!empty($config['ntpd']['ntpmaxpeers'])) {
|
|
1942 |
$ntpcfg .= $config['ntpd']['ntpmaxpeers'];
|
|
1896 |
if (!empty(config_get_path('ntpd/ntpmaxpeers'))) {
|
|
1897 |
$ntpcfg .= config_get_path('ntpd/ntpmaxpeers');
|
|
1943 | 1898 |
} else { |
1944 | 1899 |
$ntpcfg .= '5'; |
1945 | 1900 |
} |
1946 | 1901 |
$ntpcfg .= "\n"; |
1947 | 1902 |
|
1948 | 1903 |
/* Add PPS configuration */ |
1949 |
if (is_array($config['ntpd']['pps']) && !empty($config['ntpd']['pps']['port']) &&
|
|
1950 |
file_exists('/dev/'.$config['ntpd']['pps']['port']) &&
|
|
1951 |
system_ntp_setup_pps($config['ntpd']['pps']['port'])) {
|
|
1904 |
if (!empty(config_get_path('ntpd/pps/port')) &&
|
|
1905 |
file_exists('/dev/'.config_get_path('ntpd/pps/port')) &&
|
|
1906 |
system_ntp_setup_pps(config_get_path('ntpd/pps/port'))) {
|
|
1952 | 1907 |
$ntpcfg .= "\n"; |
1953 | 1908 |
$ntpcfg .= "# PPS Setup\n"; |
1954 | 1909 |
$ntpcfg .= 'server 127.127.22.0'; |
1955 |
$ntpcfg .= system_ntp_fixup_poll_value('minpoll', $config['ntpd']['pps']['ppsminpoll'], $ntp_poll_min_default_pps);
|
|
1956 |
$ntpcfg .= system_ntp_fixup_poll_value('maxpoll', $config['ntpd']['pps']['ppsmaxpoll'], $ntp_poll_max_default_pps);
|
|
1957 |
if (empty($config['ntpd']['pps']['prefer'])) { /*note: this one works backwards */
|
|
1910 |
$ntpcfg .= system_ntp_fixup_poll_value('minpoll', config_get_path('ntpd/pps/ppsminpoll'), $ntp_poll_min_default_pps);
|
|
1911 |
$ntpcfg .= system_ntp_fixup_poll_value('maxpoll', config_get_path('ntpd/pps/ppsmaxpoll'), $ntp_poll_max_default_pps);
|
|
1912 |
if (empty(config_get_path('ntpd/pps/prefer'))) { /*note: this one works backwards */
|
|
1958 | 1913 |
$ntpcfg .= ' prefer'; |
1959 | 1914 |
} |
1960 |
if (!empty($config['ntpd']['pps']['noselect'])) {
|
|
1915 |
if (!empty(config_get_path('ntpd/pps/noselect'))) {
|
|
1961 | 1916 |
$ntpcfg .= ' noselect '; |
1962 | 1917 |
} |
1963 | 1918 |
$ntpcfg .= "\n"; |
1964 | 1919 |
$ntpcfg .= 'fudge 127.127.22.0'; |
1965 |
if (!empty($config['ntpd']['pps']['fudge1'])) {
|
|
1920 |
if (!empty(config_get_path('ntpd/pps/fudge1'))) {
|
|
1966 | 1921 |
$ntpcfg .= ' time1 '; |
1967 |
$ntpcfg .= $config['ntpd']['pps']['fudge1'];
|
|
1922 |
$ntpcfg .= config_get_path('ntpd/pps/fudge1');
|
|
1968 | 1923 |
} |
1969 |
if (!empty($config['ntpd']['pps']['flag2'])) {
|
|
1924 |
if (!empty(config_get_path('ntpd/pps/flag2'))) {
|
|
1970 | 1925 |
$ntpcfg .= ' flag2 1'; |
1971 | 1926 |
} |
1972 |
if (!empty($config['ntpd']['pps']['flag3'])) {
|
|
1927 |
if (!empty(config_get_path('ntpd/pps/flag3'))) {
|
|
1973 | 1928 |
$ntpcfg .= ' flag3 1'; |
1974 | 1929 |
} else { |
1975 | 1930 |
$ntpcfg .= ' flag3 0'; |
1976 | 1931 |
} |
1977 |
if (!empty($config['ntpd']['pps']['flag4'])) {
|
|
1932 |
if (!empty(config_get_path('ntpd/pps/flag4'))) {
|
|
1978 | 1933 |
$ntpcfg .= ' flag4 1'; |
1979 | 1934 |
} |
1980 |
if (!empty($config['ntpd']['pps']['refid'])) {
|
|
1935 |
if (!empty(config_get_path('ntpd/pps/refid'))) {
|
|
1981 | 1936 |
$ntpcfg .= ' refid '; |
1982 |
$ntpcfg .= $config['ntpd']['pps']['refid'];
|
|
1937 |
$ntpcfg .= config_get_path('ntpd/pps/refid');
|
|
1983 | 1938 |
} |
1984 | 1939 |
$ntpcfg .= "\n"; |
1985 | 1940 |
} |
1986 | 1941 |
/* End PPS configuration */ |
1987 | 1942 |
|
1988 | 1943 |
/* Add GPS configuration */ |
1989 |
if (is_array($config['ntpd']['gps']) && !empty($config['ntpd']['gps']['port']) &&
|
|
1990 |
system_ntp_setup_gps($config['ntpd']['gps']['port'])) {
|
|
1944 |
if (!empty(config_get_path('ntpd/gps/port')) &&
|
|
1945 |
system_ntp_setup_gps(config_get_path('ntpd/gps/port'))) {
|
|
1991 | 1946 |
$ntpcfg .= "\n"; |
1992 | 1947 |
$ntpcfg .= "# GPS Setup\n"; |
1993 | 1948 |
$ntpcfg .= 'server 127.127.20.0 mode '; |
1994 |
if (!empty($config['ntpd']['gps']['nmea']) || !empty($config['ntpd']['gps']['speed']) || !empty($config['ntpd']['gps']['subsec']) || !empty($config['ntpd']['gps']['processpgrmf'])) {
|
|
1995 |
if (!empty($config['ntpd']['gps']['nmea'])) {
|
|
1996 |
$ntpmode = (int) $config['ntpd']['gps']['nmea'];
|
|
1949 |
if (!empty(config_get_path('ntpd/gps/nmea')) || !empty(config_get_path('ntpd/gps/speed')) || !empty(config_get_path('ntpd/gps/subsec')) || !empty(config_get_path('ntpd/gps/processpgrmf'))) {
|
|
1950 |
if (!empty(config_get_path('ntpd/gps/nmea'))) {
|
|
1951 |
$ntpmode = (int) config_get_path('ntpd/gps/nmea');
|
|
1997 | 1952 |
} |
1998 |
if (!empty($config['ntpd']['gps']['speed'])) {
|
|
1999 |
$ntpmode += (int) $config['ntpd']['gps']['speed'];
|
|
1953 |
if (!empty(config_get_path('ntpd/gps/speed'))) {
|
|
1954 |
$ntpmode += (int) config_get_path('ntpd/gps/speed');
|
|
2000 | 1955 |
} |
2001 |
if (!empty($config['ntpd']['gps']['subsec'])) {
|
|
1956 |
if (!empty(config_get_path('ntpd/gps/subsec'))) {
|
|
2002 | 1957 |
$ntpmode += 128; |
2003 | 1958 |
} |
2004 |
if (!empty($config['ntpd']['gps']['processpgrmf'])) {
|
|
1959 |
if (!empty(config_get_path('ntpd/gps/processpgrmf'))) {
|
|
2005 | 1960 |
$ntpmode += 256; |
2006 | 1961 |
} |
2007 | 1962 |
$ntpcfg .= (string) $ntpmode; |
2008 | 1963 |
} else { |
2009 | 1964 |
$ntpcfg .= '0'; |
2010 | 1965 |
} |
2011 |
$ntpcfg .= system_ntp_fixup_poll_value('minpoll', $config['ntpd']['gps']['gpsminpoll'], $ntp_poll_min_default_gps);
|
|
2012 |
$ntpcfg .= system_ntp_fixup_poll_value('maxpoll', $config['ntpd']['gps']['gpsmaxpoll'], $ntp_poll_max_default_gps);
|
|
1966 |
$ntpcfg .= system_ntp_fixup_poll_value('minpoll', config_get_path('ntpd/gps/gpsminpoll'), $ntp_poll_min_default_gps);
|
|
1967 |
$ntpcfg .= system_ntp_fixup_poll_value('maxpoll', config_get_path('ntpd/gps/gpsmaxpoll'), $ntp_poll_max_default_gps);
|
|
2013 | 1968 |
|
2014 |
if (empty($config['ntpd']['gps']['prefer'])) { /*note: this one works backwards */
|
|
1969 |
if (empty(config_get_path('ntpd/gps/prefer'))) { /*note: this one works backwards */
|
|
2015 | 1970 |
$ntpcfg .= ' prefer'; |
2016 | 1971 |
} |
2017 |
if (!empty($config['ntpd']['gps']['noselect'])) {
|
|
1972 |
if (!empty(config_get_path('ntpd/gps/noselect'))) {
|
|
2018 | 1973 |
$ntpcfg .= ' noselect '; |
2019 | 1974 |
} |
2020 | 1975 |
$ntpcfg .= "\n"; |
2021 | 1976 |
$ntpcfg .= 'fudge 127.127.20.0'; |
2022 |
if (!empty($config['ntpd']['gps']['fudge1'])) {
|
|
1977 |
if (!empty(config_get_path('ntpd/gps/fudge1'))) {
|
|
2023 | 1978 |
$ntpcfg .= ' time1 '; |
2024 |
$ntpcfg .= $config['ntpd']['gps']['fudge1'];
|
|
1979 |
$ntpcfg .= config_get_path('ntpd/gps/fudge1');
|
|
2025 | 1980 |
} |
2026 |
if (!empty($config['ntpd']['gps']['fudge2'])) {
|
|
1981 |
if (!empty(config_get_path('ntpd/gps/fudge2'))) {
|
|
2027 | 1982 |
$ntpcfg .= ' time2 '; |
2028 |
$ntpcfg .= $config['ntpd']['gps']['fudge2'];
|
|
1983 |
$ntpcfg .= config_get_path('ntpd/gps/fudge2');
|
|
2029 | 1984 |
} |
2030 |
if (!empty($config['ntpd']['gps']['flag1'])) {
|
|
1985 |
if (!empty(config_get_path('ntpd/gps/flag1'))) {
|
|
2031 | 1986 |
$ntpcfg .= ' flag1 1'; |
2032 | 1987 |
} else { |
2033 | 1988 |
$ntpcfg .= ' flag1 0'; |
2034 | 1989 |
} |
2035 |
if (!empty($config['ntpd']['gps']['flag2'])) {
|
|
1990 |
if (!empty(config_get_path('ntpd/gps/flag2'))) {
|
|
2036 | 1991 |
$ntpcfg .= ' flag2 1'; |
2037 | 1992 |
} |
2038 |
if (!empty($config['ntpd']['gps']['flag3'])) {
|
|
1993 |
if (!empty(config_get_path('ntpd/gps/flag3'))) {
|
|
2039 | 1994 |
$ntpcfg .= ' flag3 1'; |
2040 | 1995 |
} else { |
2041 | 1996 |
$ntpcfg .= ' flag3 0'; |
2042 | 1997 |
} |
2043 |
if (!empty($config['ntpd']['gps']['flag4'])) {
|
|
1998 |
if (!empty(config_get_path('ntpd/gps/flag4'))) {
|
|
2044 | 1999 |
$ntpcfg .= ' flag4 1'; |
2045 | 2000 |
} |
2046 |
if (!empty($config['ntpd']['gps']['refid'])) {
|
|
2001 |
if (!empty(config_get_path('ntpd/gps/refid'))) {
|
|
2047 | 2002 |
$ntpcfg .= ' refid '; |
2048 |
$ntpcfg .= $config['ntpd']['gps']['refid'];
|
|
2003 |
$ntpcfg .= config_get_path('ntpd/gps/refid');
|
|
2049 | 2004 |
} |
2050 |
if (!empty($config['ntpd']['gps']['stratum'])) {
|
|
2005 |
if (!empty(config_get_path('ntpd/gps/stratum'))) {
|
|
2051 | 2006 |
$ntpcfg .= ' stratum '; |
2052 |
$ntpcfg .= $config['ntpd']['gps']['stratum'];
|
|
2007 |
$ntpcfg .= config_get_path('ntpd/gps/stratum');
|
|
2053 | 2008 |
} |
2054 | 2009 |
$ntpcfg .= "\n"; |
2055 |
} elseif (is_array($config['ntpd']) && !empty($config['ntpd']['gpsport']) && |
|
2056 |
system_ntp_setup_gps($config['ntpd']['gpsport'])) { |
|
2010 |
} elseif (system_ntp_setup_gps(config_get_path('ntpd/gpsport'))) { |
|
2057 | 2011 |
/* This handles a 2.1 and earlier config */ |
2058 | 2012 |
$ntpcfg .= "# GPS Setup\n"; |
2059 | 2013 |
$ntpcfg .= "server 127.127.20.0 mode 0 minpoll 4 maxpoll 4 prefer\n"; |
... | ... | |
2067 | 2021 |
$have_pools = false; |
2068 | 2022 |
$ntpcfg .= "\n\n# Upstream Servers\n"; |
2069 | 2023 |
/* foreach through ntp servers and write out to ntpd.conf */ |
2070 |
foreach (explode(' ', $config['system']['timeservers']) as $ts) {
|
|
2024 |
foreach (explode(' ', config_get_path('system/timeservers')) as $ts) {
|
|
2071 | 2025 |
if ((substr_compare($ts, $auto_pool_suffix, strlen($ts) - strlen($auto_pool_suffix), strlen($auto_pool_suffix)) === 0) |
2072 |
|| substr_count($config['ntpd']['ispool'], $ts)) {
|
|
2026 |
|| substr_count(config_get_path('ntpd/ispool'), $ts)) {
|
|
2073 | 2027 |
$ntpcfg .= 'pool '; |
2074 | 2028 |
$have_pools = true; |
2075 | 2029 |
} else { |
2076 |
if (substr_count($config['ntpd']['ispeer'], $ts)) {
|
|
2030 |
if (substr_count(config_get_path('ntpd/ispeer'), $ts)) {
|
|
2077 | 2031 |
$ntpcfg .= 'peer '; |
2078 | 2032 |
} else { |
2079 | 2033 |
$ntpcfg .= 'server '; |
2080 | 2034 |
} |
2081 |
if ($config['ntpd']['dnsresolv'] == 'inet') {
|
|
2035 |
if (config_get_path('ntpd/dnsresolv') == 'inet') {
|
|
2082 | 2036 |
$ntpcfg .= '-4 '; |
2083 |
} elseif ($config['ntpd']['dnsresolv'] == 'inet6') {
|
|
2037 |
} elseif (config_get_path('ntpd/dnsresolv') == 'inet6') {
|
|
2084 | 2038 |
$ntpcfg .= '-6 '; |
2085 | 2039 |
} |
2086 | 2040 |
} |
2087 | 2041 |
|
2088 | 2042 |
$ntpcfg .= "{$ts}"; |
2089 |
if (!substr_count($config['ntpd']['ispeer'], $ts)) {
|
|
2043 |
if (!substr_count(config_get_path('ntpd/ispeer'), $ts)) {
|
|
2090 | 2044 |
$ntpcfg .= " iburst"; |
2091 | 2045 |
} |
2092 | 2046 |
|
2093 |
$ntpcfg .= system_ntp_fixup_poll_value('minpoll', $config['ntpd']['ntpminpoll'], $ntp_poll_min_default);
|
|
2094 |
$ntpcfg .= system_ntp_fixup_poll_value('maxpoll', $config['ntpd']['ntpmaxpoll'], $ntp_poll_max_default);
|
|
2047 |
$ntpcfg .= system_ntp_fixup_poll_value('minpoll', config_get_path('ntpd/ntpminpoll'), $ntp_poll_min_default);
|
|
2048 |
$ntpcfg .= system_ntp_fixup_poll_value('maxpoll', config_get_path('ntpd/ntpmaxpoll'), $ntp_poll_max_default);
|
|
2095 | 2049 |
|
2096 |
if (substr_count($config['ntpd']['prefer'], $ts)) {
|
|
2050 |
if (substr_count(config_get_path('ntpd/prefer'), $ts)) {
|
|
2097 | 2051 |
$ntpcfg .= ' prefer'; |
2098 | 2052 |
} |
2099 |
if (substr_count($config['ntpd']['noselect'], $ts)) {
|
|
2053 |
if (substr_count(config_get_path('ntpd/noselect'), $ts)) {
|
|
2100 | 2054 |
$ntpcfg .= ' noselect'; |
2101 | 2055 |
} |
2102 | 2056 |
$ntpcfg .= "\n"; |
... | ... | |
2104 | 2058 |
unset($ts); |
2105 | 2059 |
|
2106 | 2060 |
$ntpcfg .= "\n\n"; |
2107 |
if (!empty($config['ntpd']['clockstats']) || !empty($config['ntpd']['loopstats']) || !empty($config['ntpd']['peerstats'])) {
|
|
2061 |
if (!empty(config_get_path('ntpd/clockstats')) || !empty(config_get_path('ntpd/loopstats')) || !empty(config_get_path('ntpd/peerstats'))) {
|
|
2108 | 2062 |
$ntpcfg .= "enable stats\n"; |
2109 | 2063 |
$ntpcfg .= 'statistics'; |
2110 |
if (!empty($config['ntpd']['clockstats'])) {
|
|
2064 |
if (!empty(config_get_path('ntpd/clockstats'))) {
|
|
2111 | 2065 |
$ntpcfg .= ' clockstats'; |
2112 | 2066 |
} |
2113 |
if (!empty($config['ntpd']['loopstats'])) {
|
|
2067 |
if (!empty(config_get_path('ntpd/loopstats'))) {
|
|
2114 | 2068 |
$ntpcfg .= ' loopstats'; |
2115 | 2069 |
} |
2116 |
if (!empty($config['ntpd']['peerstats'])) {
|
|
2070 |
if (!empty(config_get_path('ntpd/peerstats'))) {
|
|
2117 | 2071 |
$ntpcfg .= ' peerstats'; |
2118 | 2072 |
} |
2119 | 2073 |
$ntpcfg .= "\n"; |
2120 | 2074 |
} |
2121 | 2075 |
$ntpcfg .= "statsdir {$statsdir}\n"; |
2122 | 2076 |
$ntpcfg .= 'logconfig =syncall +clockall'; |
2123 |
if (!empty($config['ntpd']['logpeer'])) {
|
|
2077 |
if (!empty(config_get_path('ntpd/logpeer'))) {
|
|
2124 | 2078 |
$ntpcfg .= ' +peerall'; |
2125 | 2079 |
} |
2126 |
if (!empty($config['ntpd']['logsys'])) {
|
|
2080 |
if (!empty(config_get_path('ntpd/logsys'))) {
|
|
2127 | 2081 |
$ntpcfg .= ' +sysall'; |
2128 | 2082 |
} |
2129 | 2083 |
$ntpcfg .= "\n"; |
... | ... | |
2131 | 2085 |
|
2132 | 2086 |
/* Default Access restrictions */ |
2133 | 2087 |
$ntpcfg .= 'restrict default'; |
2134 |
if (empty($config['ntpd']['kod'])) { /*note: this one works backwards */
|
|
2088 |
if (empty(config_get_path('ntpd/kod'))) { /*note: this one works backwards */
|
|
2135 | 2089 |
$ntpcfg .= ' kod limited'; |
2136 | 2090 |
} |
2137 |
if (empty($config['ntpd']['nomodify'])) { /*note: this one works backwards */
|
|
2091 |
if (empty(config_get_path('ntpd/nomodify'))) { /*note: this one works backwards */
|
|
2138 | 2092 |
$ntpcfg .= ' nomodify'; |
2139 | 2093 |
} |
2140 |
if (!empty($config['ntpd']['noquery'])) {
|
|
2094 |
if (!empty(config_get_path('ntpd/noquery'))) {
|
|
2141 | 2095 |
$ntpcfg .= ' noquery'; |
2142 | 2096 |
} |
2143 |
if (empty($config['ntpd']['nopeer'])) { /*note: this one works backwards */
|
|
2097 |
if (empty(config_get_path('ntpd/nopeer'))) { /*note: this one works backwards */
|
|
2144 | 2098 |
$ntpcfg .= ' nopeer'; |
2145 | 2099 |
} |
2146 |
if (empty($config['ntpd']['notrap'])) { /*note: this one works backwards */
|
|
2100 |
if (empty(config_get_path('ntpd/notrap'))) { /*note: this one works backwards */
|
|
2147 | 2101 |
$ntpcfg .= ' notrap'; |
2148 | 2102 |
} |
2149 |
if (!empty($config['ntpd']['noserve'])) {
|
|
2103 |
if (!empty(config_get_path('ntpd/noserve'))) {
|
|
2150 | 2104 |
$ntpcfg .= ' noserve'; |
2151 | 2105 |
} |
2152 | 2106 |
$ntpcfg .= "\nrestrict -6 default"; |
2153 |
if (empty($config['ntpd']['kod'])) { /*note: this one works backwards */
|
|
2107 |
if (empty(config_get_path('ntpd/kod'))) { /*note: this one works backwards */
|
|
2154 | 2108 |
$ntpcfg .= ' kod limited'; |
2155 | 2109 |
} |
2156 |
if (empty($config['ntpd']['nomodify'])) { /*note: this one works backwards */
|
|
2110 |
if (empty(config_get_path('ntpd/nomodify'))) { /*note: this one works backwards */
|
|
2157 | 2111 |
$ntpcfg .= ' nomodify'; |
2158 | 2112 |
} |
2159 |
if (!empty($config['ntpd']['noquery'])) {
|
|
2113 |
if (!empty(config_get_path('ntpd/noquery'))) {
|
|
2160 | 2114 |
$ntpcfg .= ' noquery'; |
2161 | 2115 |
} |
2162 |
if (empty($config['ntpd']['nopeer'])) { /*note: this one works backwards */
|
|
2116 |
if (empty(config_get_path('ntpd/nopeer'))) { /*note: this one works backwards */
|
|
2163 | 2117 |
$ntpcfg .= ' nopeer'; |
2164 | 2118 |
} |
2165 |
if (!empty($config['ntpd']['noserve'])) {
|
|
2119 |
if (!empty(config_get_path('ntpd/noserve'))) {
|
|
2166 | 2120 |
$ntpcfg .= ' noserve'; |
2167 | 2121 |
} |
2168 |
if (empty($config['ntpd']['notrap'])) { /*note: this one works backwards */
|
|
2122 |
if (empty(config_get_path('ntpd/notrap'))) { /*note: this one works backwards */
|
|
2169 | 2123 |
$ntpcfg .= ' notrap'; |
2170 | 2124 |
} |
2171 | 2125 |
|
2172 | 2126 |
/* Pools require "restrict source" and cannot contain "nopeer" and "noserve". */ |
2173 | 2127 |
if ($have_pools) { |
2174 | 2128 |
$ntpcfg .= "\nrestrict source"; |
2175 |
if (empty($config['ntpd']['kod'])) { /*note: this one works backwards */
|
|
2129 |
if (empty(config_get_path('ntpd/kod'))) { /*note: this one works backwards */
|
|
2176 | 2130 |
$ntpcfg .= ' kod limited'; |
2177 | 2131 |
} |
2178 |
if (empty($config['ntpd']['nomodify'])) { /*note: this one works backwards */
|
|
2132 |
if (empty(config_get_path('ntpd/nomodify'))) { /*note: this one works backwards */
|
|
2179 | 2133 |
$ntpcfg .= ' nomodify'; |
2180 | 2134 |
} |
2181 |
if (!empty($config['ntpd']['noquery'])) {
|
|
2135 |
if (!empty(config_get_path('ntpd/noquery'))) {
|
|
2182 | 2136 |
$ntpcfg .= ' noquery'; |
2183 | 2137 |
} |
2184 |
if (empty($config['ntpd']['notrap'])) { /*note: this one works backwards */
|
|
2138 |
if (empty(config_get_path('ntpd/notrap'))) { /*note: this one works backwards */
|
|
2185 | 2139 |
$ntpcfg .= ' notrap'; |
2186 | 2140 |
} |
2187 | 2141 |
} |
2188 | 2142 |
|
2189 | 2143 |
/* Custom Access Restrictions */ |
2190 |
if (is_array($config['ntpd']['restrictions']) && is_array($config['ntpd']['restrictions']['row'])) {
|
|
2191 |
$networkacl = $config['ntpd']['restrictions']['row'];
|
|
2144 |
if (is_array(config_get_path('ntpd/restrictions/row'))) {
|
|
2145 |
$networkacl = config_get_path('ntpd/restrictions/row');
|
|
2192 | 2146 |
foreach ($networkacl as $acl) { |
2193 | 2147 |
$restrict = ""; |
2194 | 2148 |
if (is_ipaddrv6($acl['acl_network'])) { |
... | ... | |
2225 | 2179 |
|
2226 | 2180 |
/* A leapseconds file is really only useful if this clock is stratum 1 */ |
2227 | 2181 |
$ntpcfg .= "\n"; |
2228 |
if (!empty($config['ntpd']['leapsec'])) {
|
|
2229 |
$leapsec .= base64_decode($config['ntpd']['leapsec']);
|
|
2182 |
if (!empty(config_get_path('ntpd/leapsec'))) {
|
|
2183 |
$leapsec .= base64_decode(config_get_path('ntpd/leapsec'));
|
|
2230 | 2184 |
file_put_contents('/var/db/leap-seconds', $leapsec); |
2231 | 2185 |
$ntpcfg .= "leapfile /var/db/leap-seconds\n"; |
2232 | 2186 |
} |
2233 | 2187 |
|
2234 | 2188 |
|
2235 |
if (empty($config['ntpd']['interface'])) { |
|
2236 |
if (is_array($config['installedpackages']['openntpd']) && !empty($config['installedpackages']['openntpd']['config'][0]['interface'])) { |
|
2237 |
$interfaces = explode(",", $config['installedpackages']['openntpd']['config'][0]['interface']); |
|
2238 |
} else { |
|
2239 |
$interfaces = array(); |
|
2240 |
} |
|
2189 |
if (empty(config_get_path('ntpd/interface'))) { |
|
2190 |
$interfaces = |
|
2191 |
explode(",", |
|
2192 |
config_get_path('installedpackages/openntpd/config/0/interface', '')); |
|
2241 | 2193 |
} else { |
2242 |
$interfaces = explode(",", $config['ntpd']['interface']);
|
|
2194 |
$interfaces = explode(",", config_get_path('ntpd/interface'));
|
|
2243 | 2195 |
} |
2244 | 2196 |
|
2245 | 2197 |
if (is_array($interfaces) && count($interfaces)) { |
... | ... | |
2310 | 2262 |
} |
2311 | 2263 |
|
2312 | 2264 |
function system_reboot_cleanup() { |
2313 |
global $config, $g, $cpzone;
|
|
2265 |
global $g, $cpzone; |
|
2314 | 2266 |
|
2315 | 2267 |
mwexec("/usr/local/bin/beep.sh stop"); |
2316 | 2268 |
require_once("captiveportal.inc"); |
2317 |
if (is_array($config['captiveportal'])) { |
|
2318 |
foreach ($config['captiveportal'] as $cpzone=>$cp) { |
|
2319 |
if (!isset($cp['preservedb'])) { |
|
2320 |
/* send Accounting-Stop packet for all clients, termination cause 'Admin-Reboot' */ |
|
2321 |
captiveportal_radius_stop_all(7); // Admin-Reboot |
|
2322 |
unlink_if_exists("{$g['vardb_path']}/captiveportal{$cpzone}.db"); |
|
2323 |
captiveportal_free_dnrules(); |
|
2324 |
} |
|
2325 |
/* Send Accounting-Off packet to the RADIUS server */ |
|
2326 |
captiveportal_send_server_accounting('off'); |
|
2269 |
$cps = config_get_path('captiveportal', []); |
|
2270 |
foreach ($cps as $cpzone=>$cp) { |
|
2271 |
if (!isset($cp['preservedb'])) { |
|
2272 |
/* send Accounting-Stop packet for all clients, termination cause 'Admin-Reboot' */ |
|
2273 |
captiveportal_radius_stop_all(7); // Admin-Reboot |
|
2274 |
unlink_if_exists("{$g['vardb_path']}/captiveportal{$cpzone}.db"); |
|
2275 |
captiveportal_free_dnrules(); |
|
2327 | 2276 |
} |
2277 |
/* Send Accounting-Off packet to the RADIUS server */ |
|
2278 |
captiveportal_send_server_accounting('off'); |
|
2279 |
} |
|
2280 |
|
|
2281 |
if (count($cps)> 0) { |
|
2328 | 2282 |
/* Remove the pipe database */ |
2329 | 2283 |
unlink_if_exists("{$g['vardb_path']}/captiveportaldn.rules"); |
2330 | 2284 |
} |
2285 |
|
|
2331 | 2286 |
require_once("voucher.inc"); |
2332 | 2287 |
voucher_save_db_to_config(); |
2333 | 2288 |
require_once("pkg-utils.inc"); |
... | ... | |
2335 | 2290 |
} |
2336 | 2291 |
|
2337 | 2292 |
function system_do_shell_commands($early = 0) { |
2338 |
global $config, $g; |
|
2339 |
if (isset($config['system']['developerspew'])) { |
|
2293 |
if (config_path_enabled('system', 'developerspew')) { |
|
2340 | 2294 |
$mt = microtime(); |
2341 | 2295 |
echo "system_do_shell_commands() being called $mt\n"; |
2342 | 2296 |
} |
... | ... | |
2347 | 2301 |
$cmdn = "shellcmd"; |
2348 | 2302 |
} |
2349 | 2303 |
|
2350 |
if (is_array($config['system'][$cmdn])) {
|
|
2351 |
|
|
2304 |
$syscmd = config_get_path('system/{$cmdn}', '');
|
|
2305 |
if (is_array($syscmd)) { |
|
2352 | 2306 |
/* *cmd is an array, loop through */ |
2353 |
foreach ($config['system'][$cmdn] as $cmd) {
|
|
2307 |
foreach ($syscmd as $cmd) {
|
|
2354 | 2308 |
exec($cmd); |
2355 | 2309 |
} |
2356 | 2310 |
|
2357 |
} elseif ($config['system'][$cmdn] <> "") { |
|
2358 |
|
|
2311 |
} elseif ($syscmd <> "") { |
|
2359 | 2312 |
/* execute single item */ |
2360 |
exec($config['system'][$cmdn]);
|
|
2313 |
exec($syscmd);
|
|
2361 | 2314 |
|
2362 | 2315 |
} |
2363 | 2316 |
} |
2364 | 2317 |
|
2365 | 2318 |
function system_dmesg_save() { |
2366 | 2319 |
global $g; |
2367 |
if (isset($config['system']['developerspew'])) {
|
|
2320 |
if (config_path_enabled('system', 'developerspew')) {
|
|
2368 | 2321 |
$mt = microtime(); |
2369 | 2322 |
echo "system_dmesg_save() being called $mt\n"; |
2370 | 2323 |
} |
... | ... | |
2401 | 2354 |
} |
2402 | 2355 |
|
2403 | 2356 |
function system_set_harddisk_standby() { |
2404 |
global $g, $config; |
|
2405 |
|
|
2406 |
if (isset($config['system']['developerspew'])) { |
|
2357 |
if (config_path_enabled('system', 'developerspew')) { |
|
2407 | 2358 |
$mt = microtime(); |
2408 | 2359 |
echo "system_set_harddisk_standby() being called $mt\n"; |
2409 | 2360 |
} |
2410 | 2361 |
|
2411 |
if (isset($config['system']['harddiskstandby'])) {
|
|
2362 |
if (config_path_enabled('system', 'harddiskstandby')) {
|
|
2412 | 2363 |
if (platform_booting()) { |
2413 | 2364 |
echo gettext('Setting hard disk standby... '); |
2414 | 2365 |
} |
2415 | 2366 |
|
2416 |
$standby = $config['system']['harddiskstandby'];
|
|
2367 |
$standby = config_get_path('system/harddiskstandby');
|
|
2417 | 2368 |
// Check for a numeric value |
2418 | 2369 |
if (is_numeric($standby)) { |
2419 | 2370 |
// Get only suitable candidates for standby; using get_smart_drive_list() |
... | ... | |
2440 | 2391 |
} |
2441 | 2392 |
|
2442 | 2393 |
function system_setup_sysctl() { |
2443 |
global $config; |
|
2444 |
if (isset($config['system']['developerspew'])) { |
|
2394 |
if (config_path_enabled('system', 'developerspew')) { |
|
2445 | 2395 |
$mt = microtime(); |
2446 | 2396 |
echo "system_setup_sysctl() being called $mt\n"; |
2447 | 2397 |
} |
2448 | 2398 |
|
2449 | 2399 |
activate_sysctls(); |
2450 | 2400 |
|
2451 |
if (isset($config['system']['sharednet'])) {
|
|
2401 |
if (config_path_enabled('system', 'sharednet')) {
|
|
2452 | 2402 |
system_disable_arp_wrong_if(); |
2453 | 2403 |
} |
2454 | 2404 |
} |
2455 | 2405 |
|
2456 | 2406 |
function system_disable_arp_wrong_if() { |
2457 |
global $config; |
|
2458 |
if (isset($config['system']['developerspew'])) { |
|
2407 |
if (config_path_enabled('system', 'developerspew')) { |
|
2459 | 2408 |
$mt = microtime(); |
2460 | 2409 |
echo "system_disable_arp_wrong_if() being called $mt\n"; |
2461 | 2410 |
} |
... | ... | |
2466 | 2415 |
} |
2467 | 2416 |
|
2468 | 2417 |
function system_enable_arp_wrong_if() { |
2469 |
global $config; |
|
2470 |
if (isset($config['system']['developerspew'])) { |
|
2418 |
if (config_path_enabled('system', 'developerspew')) { |
|
2471 | 2419 |
$mt = microtime(); |
2472 | 2420 |
echo "system_enable_arp_wrong_if() being called $mt\n"; |
2473 | 2421 |
} |
... | ... | |
2478 | 2426 |
} |
2479 | 2427 |
|
2480 | 2428 |
function enable_watchdog() { |
2481 |
global $config; |
|
2482 | 2429 |
return; |
2483 | 2430 |
$install_watchdog = false; |
2484 | 2431 |
$supported_watchdogs = array("Geode"); |
Also available in: Unified diff
Replace direct config accesses in system.inc. Issue #13446.