1
|
<?php
|
2
|
/*
|
3
|
* globals.inc
|
4
|
*
|
5
|
* part of pfSense (https://www.pfsense.org)
|
6
|
* Copyright (c) 2004-2016 Electric Sheep Fencing, LLC
|
7
|
* All rights reserved.
|
8
|
*
|
9
|
* Redistribution and use in source and binary forms, with or without
|
10
|
* modification, are permitted provided that the following conditions are met:
|
11
|
*
|
12
|
* 1. Redistributions of source code must retain the above copyright notice,
|
13
|
* this list of conditions and the following disclaimer.
|
14
|
*
|
15
|
* 2. Redistributions in binary form must reproduce the above copyright
|
16
|
* notice, this list of conditions and the following disclaimer in
|
17
|
* the documentation and/or other materials provided with the
|
18
|
* distribution.
|
19
|
*
|
20
|
* 3. All advertising materials mentioning features or use of this software
|
21
|
* must display the following acknowledgment:
|
22
|
* "This product includes software developed by the pfSense Project
|
23
|
* for use in the pfSense® software distribution. (http://www.pfsense.org/).
|
24
|
*
|
25
|
* 4. The names "pfSense" and "pfSense Project" must not be used to
|
26
|
* endorse or promote products derived from this software without
|
27
|
* prior written permission. For written permission, please contact
|
28
|
* coreteam@pfsense.org.
|
29
|
*
|
30
|
* 5. Products derived from this software may not be called "pfSense"
|
31
|
* nor may "pfSense" appear in their names without prior written
|
32
|
* permission of the Electric Sheep Fencing, LLC.
|
33
|
*
|
34
|
* 6. Redistributions of any form whatsoever must retain the following
|
35
|
* acknowledgment:
|
36
|
*
|
37
|
* "This product includes software developed by the pfSense Project
|
38
|
* for use in the pfSense software distribution (http://www.pfsense.org/).
|
39
|
*
|
40
|
* THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
|
41
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
42
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
43
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
|
44
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
45
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
46
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
47
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
48
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
49
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
50
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
51
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
52
|
*/
|
53
|
|
54
|
// Global defines
|
55
|
|
56
|
// Automatic panel collapse
|
57
|
define('COLLAPSIBLE', 0x08);
|
58
|
define('SEC_CLOSED', 0x04);
|
59
|
define('SEC_OPEN', 0x00);
|
60
|
|
61
|
// AddPassword method defines
|
62
|
define('DMYPWD', "********");
|
63
|
|
64
|
global $g;
|
65
|
$g = array(
|
66
|
"base_packages" => "siproxd",
|
67
|
"event_address" => "unix:///var/run/check_reload_status",
|
68
|
"factory_shipped_username" => "admin",
|
69
|
"factory_shipped_password" => "pfsense",
|
70
|
"upload_path" => "/root",
|
71
|
"dhcpd_chroot_path" => "/var/dhcpd",
|
72
|
"unbound_chroot_path" => "/var/unbound",
|
73
|
"var_path" => "/var",
|
74
|
"varrun_path" => "/var/run",
|
75
|
"varetc_path" => "/var/etc",
|
76
|
"vardb_path" => "/var/db",
|
77
|
"varlog_path" => "/var/log",
|
78
|
"etc_path" => "/etc",
|
79
|
"tmp_path" => "/tmp",
|
80
|
"conf_path" => "/conf",
|
81
|
"conf_default_path" => "/conf.default",
|
82
|
"cf_path" => "/cf",
|
83
|
"cf_conf_path" => "/cf/conf",
|
84
|
"www_path" => "/usr/local/www",
|
85
|
"xml_rootobj" => "pfsense",
|
86
|
"admin_group" => "admins",
|
87
|
"product_name" => "pfSense",
|
88
|
"product_version" => trim(file_get_contents("/etc/version"), " \n"),
|
89
|
"product_copyright" => "Electric Sheep Fencing LLC",
|
90
|
"product_copyright_url" => "https://pfsense.org/license",
|
91
|
"product_copyright_years" => "2004 - ".date("Y"),
|
92
|
"product_website" => "www.pfsense.org",
|
93
|
"product_website_footer" => "https://www.pfsense.org/?gui=bootstrap",
|
94
|
"product_email" => "coreteam@pfsense.org",
|
95
|
"hideplatform" => false,
|
96
|
"hidebackupbeforeupgrade" => false,
|
97
|
"disablehelpmenu" => false,
|
98
|
"disablehelpicon" => false,
|
99
|
"disablecrashreporter" => false,
|
100
|
"crashreporterurl" => "https://crashreporter.pfsense.org/crash_reporter.php",
|
101
|
"debug" => false,
|
102
|
"latest_config" => "15.5",
|
103
|
"nopkg_platforms" => array("cdrom"),
|
104
|
"minimum_ram_warning" => "101",
|
105
|
"minimum_ram_warning_text" => "128 MB",
|
106
|
"wan_interface_name" => "wan",
|
107
|
"captiveportal_path" => "/usr/local/captiveportal",
|
108
|
"captiveportal_element_path" => "/var/db/cpelements",
|
109
|
"captiveportal_element_sizelimit" => 1048576,
|
110
|
"services_dhcp_server_enable" => true,
|
111
|
"wireless_regex" => "/^(ndis|wi|ath|an|ral|ural|iwi|wlan|rum|run|bwn|zyd|mwl|bwi|ipw|iwn|malo|uath|upgt|urtw|wpi)/",
|
112
|
"help_base_url" => "/help.php",
|
113
|
"pkg_prefix" => "pfSense-pkg-",
|
114
|
"default_timezone" => "Etc/UTC",
|
115
|
"language" => "en_US"
|
116
|
);
|
117
|
|
118
|
/* IP TOS flags */
|
119
|
$iptos = array("lowdelay", "throughput", "reliability");
|
120
|
|
121
|
/* TCP flags */
|
122
|
$tcpflags = array("syn", "ack", "fin", "rst", "psh", "urg", "ece", "cwr");
|
123
|
|
124
|
if (file_exists("/etc/version.patch")) {
|
125
|
$g["product_version_patch"] = trim(file_get_contents("/etc/version.patch"), " \n");
|
126
|
} else {
|
127
|
$g["product_version_patch"] = "0";
|
128
|
}
|
129
|
|
130
|
$g['product_version_string'] = $g['product_version'];
|
131
|
if (is_numeric($g["product_version_patch"]) && $g["product_version_patch"] != "0") {
|
132
|
$g['product_version_string'] .= "-p{$g['product_version_patch']}";
|
133
|
}
|
134
|
|
135
|
if (file_exists("/etc/platform")) {
|
136
|
$arch = php_uname("m");
|
137
|
|
138
|
if (strstr($g['product_version'], "-RELEASE")) {
|
139
|
/* This is only necessary for RELEASE */
|
140
|
$arch = ($arch == "i386") ? "" : '/' . $arch;
|
141
|
/* Full installs and NanoBSD use the same update directory and manifest in 2.x */
|
142
|
$g['update_url']="https://updates.pfsense.org/_updaters{$arch}";
|
143
|
$g['update_manifest']="https://updates.pfsense.org/manifest";
|
144
|
} else {
|
145
|
/* Full installs and NanoBSD use the same update directory and manifest in 2.x */
|
146
|
$g['update_url']="https://snapshots.pfsense.org/FreeBSD_releng/10.1/{$arch}/pfSense_HEAD/.updaters/";
|
147
|
$g['update_manifest']="https://updates.pfSense.org/manifest";
|
148
|
}
|
149
|
|
150
|
$g['platform'] = trim(file_get_contents("/etc/platform"));
|
151
|
if ($g['platform'] == "nanobsd") {
|
152
|
$g['firmware_update_text']="pfSense-*.img.gz";
|
153
|
$g['hidebackupbeforeupgrade'] = true;
|
154
|
$g['default_config_backup_count'] = 5;
|
155
|
} else {
|
156
|
$g['firmware_update_text']="pfSense-*.tgz";
|
157
|
$g['default_config_backup_count'] = 30;
|
158
|
}
|
159
|
} else {
|
160
|
// shouldn't happen but "just in case" no platform were detected
|
161
|
$g['platform'] = 'undetected';
|
162
|
$g['default_config_backup_count'] = 30;
|
163
|
}
|
164
|
|
165
|
|
166
|
if (file_exists("{$g['etc_path']}/default-config-flavor")) {
|
167
|
$flavor_array = file("{$g['etc_path']}/default-config-flavor");
|
168
|
$g['default-config-flavor'] = chop($flavor_array[0]);
|
169
|
} else {
|
170
|
$g['default-config-flavor'] = '';
|
171
|
}
|
172
|
|
173
|
/* Default sysctls */
|
174
|
$sysctls = array("net.inet.ip.portrange.first" => "1024",
|
175
|
"net.inet.tcp.blackhole" => "2",
|
176
|
"net.inet.udp.blackhole" => "1",
|
177
|
"net.inet.ip.random_id" => "1",
|
178
|
"net.inet.tcp.drop_synfin" => "1",
|
179
|
"net.inet.ip.redirect" => "1",
|
180
|
"net.inet6.ip6.redirect" => "1",
|
181
|
"net.inet6.ip6.use_tempaddr" => "0",
|
182
|
"net.inet6.ip6.prefer_tempaddr" => "0",
|
183
|
"net.inet.tcp.syncookies" => "1",
|
184
|
"net.inet.tcp.recvspace" => "65228",
|
185
|
"net.inet.tcp.sendspace" => "65228",
|
186
|
"net.inet.tcp.delayed_ack" => "0",
|
187
|
"net.inet.udp.maxdgram" => "57344",
|
188
|
"net.link.bridge.pfil_onlyip" => "0",
|
189
|
"net.link.bridge.pfil_member" => "1",
|
190
|
"net.link.bridge.pfil_bridge" => "0",
|
191
|
"net.link.tap.user_open" => "1",
|
192
|
"kern.randompid" => "347",
|
193
|
"net.inet.ip.intr_queue_maxlen" => "1000",
|
194
|
"hw.syscons.kbd_reboot" => "0",
|
195
|
"net.inet.tcp.log_debug" => "0",
|
196
|
"net.inet.tcp.tso" => "1",
|
197
|
"net.inet.icmp.icmplim" => "0",
|
198
|
"vfs.read_max" => "32",
|
199
|
"kern.ipc.maxsockbuf" => "4262144",
|
200
|
"net.inet.ip.process_options" => 0,
|
201
|
"kern.random.sys.harvest.interrupt" => 0,
|
202
|
"kern.random.sys.harvest.point_to_point" => 0,
|
203
|
"kern.random.sys.harvest.ethernet" => 0,
|
204
|
"net.route.netisr_maxqlen" => 1024,
|
205
|
"net.inet.udp.checksum" => 1,
|
206
|
"net.inet.icmp.reply_from_interface" => 1,
|
207
|
"net.inet6.ip6.rfc6204w3" => 1,
|
208
|
"net.enc.out.ipsec_bpf_mask" => "0x0001",
|
209
|
"net.enc.out.ipsec_filter_mask" => "0x0001",
|
210
|
"net.enc.in.ipsec_bpf_mask" => "0x0002",
|
211
|
"net.enc.in.ipsec_filter_mask" => "0x0002",
|
212
|
"net.key.preferred_oldsa" => "0",
|
213
|
"net.inet.carp.senderr_demotion_factor" => 0, /* Do not demote CARP for interface send errors */
|
214
|
"net.pfsync.carp_demotion_factor" => 0, /* Do not demote CARP for pfsync errors */
|
215
|
"net.raw.recvspace" => 65536,
|
216
|
"net.raw.sendspace" => 65536,
|
217
|
"net.inet.raw.recvspace" => 131072,
|
218
|
"net.inet.raw.maxdgram" => 131072,
|
219
|
"kern.corefile" => "/root/%N.core" /* Write all core files to /root/ so they do not consume space on other slices */
|
220
|
);
|
221
|
|
222
|
/* Include override values for the above if needed. If the file doesn't exist, don't try to load it. */
|
223
|
if (file_exists("/etc/inc/globals_override.inc")) {
|
224
|
@include_once("globals_override.inc");
|
225
|
}
|
226
|
|
227
|
/* Read all XML files in following dir and load menu entries */
|
228
|
$g["ext_menu_path"] = "/usr/local/share/{$g['product_name']}/menu";
|
229
|
|
230
|
function platform_booting($on_console = false) {
|
231
|
global $g;
|
232
|
|
233
|
if ($g['booting'] || file_exists("{$g['varrun_path']}/booting")) {
|
234
|
if ($on_console == false || php_sapi_name() != 'fpm-fcgi') {
|
235
|
return true;
|
236
|
}
|
237
|
}
|
238
|
|
239
|
return false;
|
240
|
}
|
241
|
|
242
|
if (file_exists("{$g['cf_conf_path']}/enableserial_force")) {
|
243
|
$g['enableserial_force'] = true;
|
244
|
}
|
245
|
|
246
|
$config_parsed = false;
|
247
|
|
248
|
?>
|