1 |
791bcfd4
|
Bill Marquette
|
<?php
|
2 |
|
|
/*
|
3 |
a1a4a22b
|
Scott Ullrich
|
Copyright (C) 2004-2009 Scott Ullrich <sullrich@gmail.com>
|
4 |
791bcfd4
|
Bill Marquette
|
All rights reserved.
|
5 |
|
|
|
6 |
|
|
originally part of m0n0wall (http://m0n0.ch/wall)
|
7 |
a1a4a22b
|
Scott Ullrich
|
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
8 |
791bcfd4
|
Bill Marquette
|
All rights reserved.
|
9 |
|
|
|
10 |
|
|
Redistribution and use in source and binary forms, with or without
|
11 |
|
|
modification, are permitted provided that the following conditions are met:
|
12 |
|
|
|
13 |
|
|
1. Redistributions of source code must retain the above copyright notice,
|
14 |
|
|
this list of conditions and the following disclaimer.
|
15 |
|
|
|
16 |
|
|
2. Redistributions in binary form must reproduce the above copyright
|
17 |
|
|
notice, this list of conditions and the following disclaimer in the
|
18 |
|
|
documentation and/or other materials provided with the distribution.
|
19 |
|
|
|
20 |
|
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
21 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
22 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
23 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
24 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25 |
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
30 |
|
|
*/
|
31 |
|
|
|
32 |
523855b0
|
Scott Ullrich
|
/*
|
33 |
|
|
pfSense_BUILDER_BINARIES: /usr/bin/find /bin/cd /usr/local/bin/rrdtool /usr/bin/nice
|
34 |
|
|
pfSense_MODULE: config
|
35 |
|
|
*/
|
36 |
791bcfd4
|
Bill Marquette
|
|
37 |
901aa044
|
Scott Ullrich
|
if(!function_exists("dump_rrd_to_xml"))
|
38 |
|
|
require("rrd.inc");
|
39 |
|
|
|
40 |
791bcfd4
|
Bill Marquette
|
/* Upgrade functions must be named:
|
41 |
|
|
* upgrade_XXX_to_YYY
|
42 |
|
|
* where XXX == previous version, zero padded, and YYY == next version, zero padded
|
43 |
|
|
*/
|
44 |
|
|
function upgrade_010_to_011() {
|
45 |
|
|
global $config;
|
46 |
|
|
$opti = 1;
|
47 |
|
|
$ifmap = array('lan' => 'lan', 'wan' => 'wan', 'pptp' => 'pptp');
|
48 |
|
|
|
49 |
|
|
/* convert DMZ to optional, if necessary */
|
50 |
|
|
if (isset($config['interfaces']['dmz'])) {
|
51 |
|
|
|
52 |
|
|
$dmzcfg = &$config['interfaces']['dmz'];
|
53 |
|
|
|
54 |
|
|
if ($dmzcfg['if']) {
|
55 |
|
|
$config['interfaces']['opt' . $opti] = array();
|
56 |
|
|
$optcfg = &$config['interfaces']['opt' . $opti];
|
57 |
|
|
|
58 |
|
|
$optcfg['enable'] = $dmzcfg['enable'];
|
59 |
|
|
$optcfg['descr'] = "DMZ";
|
60 |
|
|
$optcfg['if'] = $dmzcfg['if'];
|
61 |
|
|
$optcfg['ipaddr'] = $dmzcfg['ipaddr'];
|
62 |
|
|
$optcfg['subnet'] = $dmzcfg['subnet'];
|
63 |
|
|
|
64 |
|
|
$ifmap['dmz'] = "opt" . $opti;
|
65 |
|
|
$opti++;
|
66 |
|
|
}
|
67 |
|
|
|
68 |
|
|
unset($config['interfaces']['dmz']);
|
69 |
|
|
}
|
70 |
|
|
|
71 |
|
|
/* convert WLAN1/2 to optional, if necessary */
|
72 |
|
|
for ($i = 1; isset($config['interfaces']['wlan' . $i]); $i++) {
|
73 |
|
|
|
74 |
|
|
if (!$config['interfaces']['wlan' . $i]['if']) {
|
75 |
|
|
unset($config['interfaces']['wlan' . $i]);
|
76 |
|
|
continue;
|
77 |
|
|
}
|
78 |
|
|
|
79 |
|
|
$wlancfg = &$config['interfaces']['wlan' . $i];
|
80 |
|
|
$config['interfaces']['opt' . $opti] = array();
|
81 |
|
|
$optcfg = &$config['interfaces']['opt' . $opti];
|
82 |
|
|
|
83 |
|
|
$optcfg['enable'] = $wlancfg['enable'];
|
84 |
|
|
$optcfg['descr'] = "WLAN" . $i;
|
85 |
|
|
$optcfg['if'] = $wlancfg['if'];
|
86 |
|
|
$optcfg['ipaddr'] = $wlancfg['ipaddr'];
|
87 |
|
|
$optcfg['subnet'] = $wlancfg['subnet'];
|
88 |
|
|
$optcfg['bridge'] = $wlancfg['bridge'];
|
89 |
|
|
|
90 |
|
|
$optcfg['wireless'] = array();
|
91 |
|
|
$optcfg['wireless']['mode'] = $wlancfg['mode'];
|
92 |
|
|
$optcfg['wireless']['ssid'] = $wlancfg['ssid'];
|
93 |
|
|
$optcfg['wireless']['channel'] = $wlancfg['channel'];
|
94 |
|
|
$optcfg['wireless']['wep'] = $wlancfg['wep'];
|
95 |
|
|
|
96 |
|
|
$ifmap['wlan' . $i] = "opt" . $opti;
|
97 |
|
|
|
98 |
|
|
unset($config['interfaces']['wlan' . $i]);
|
99 |
|
|
$opti++;
|
100 |
|
|
}
|
101 |
|
|
|
102 |
|
|
/* convert filter rules */
|
103 |
|
|
$n = count($config['filter']['rule']);
|
104 |
|
|
for ($i = 0; $i < $n; $i++) {
|
105 |
|
|
|
106 |
|
|
$fr = &$config['filter']['rule'][$i];
|
107 |
|
|
|
108 |
|
|
/* remap interface */
|
109 |
|
|
if (array_key_exists($fr['interface'], $ifmap))
|
110 |
|
|
$fr['interface'] = $ifmap[$fr['interface']];
|
111 |
|
|
else {
|
112 |
|
|
/* remove the rule */
|
113 |
4b48d1b9
|
Carlos Eduardo Ramos
|
printf(gettext("%sWarning: filter rule removed " .
|
114 |
|
|
"(interface '%s' does not exist anymore)."), "\n", $fr['interface']);
|
115 |
791bcfd4
|
Bill Marquette
|
unset($config['filter']['rule'][$i]);
|
116 |
|
|
continue;
|
117 |
|
|
}
|
118 |
|
|
|
119 |
|
|
/* remap source network */
|
120 |
|
|
if (isset($fr['source']['network'])) {
|
121 |
|
|
if (array_key_exists($fr['source']['network'], $ifmap))
|
122 |
|
|
$fr['source']['network'] = $ifmap[$fr['source']['network']];
|
123 |
|
|
else {
|
124 |
|
|
/* remove the rule */
|
125 |
4b48d1b9
|
Carlos Eduardo Ramos
|
printf(gettext("%sWarning: filter rule removed " .
|
126 |
|
|
"(source network '%s' does not exist anymore)."), "\n", $fr['source']['network']);
|
127 |
791bcfd4
|
Bill Marquette
|
unset($config['filter']['rule'][$i]);
|
128 |
|
|
continue;
|
129 |
|
|
}
|
130 |
|
|
}
|
131 |
|
|
|
132 |
|
|
/* remap destination network */
|
133 |
|
|
if (isset($fr['destination']['network'])) {
|
134 |
|
|
if (array_key_exists($fr['destination']['network'], $ifmap))
|
135 |
|
|
$fr['destination']['network'] = $ifmap[$fr['destination']['network']];
|
136 |
|
|
else {
|
137 |
|
|
/* remove the rule */
|
138 |
4b48d1b9
|
Carlos Eduardo Ramos
|
printf(gettext("%sWarning: filter rule removed " .
|
139 |
|
|
"(destination network '%s' does not exist anymore)."), "\n", $fr['destination']['network']);
|
140 |
791bcfd4
|
Bill Marquette
|
unset($config['filter']['rule'][$i]);
|
141 |
|
|
continue;
|
142 |
|
|
}
|
143 |
|
|
}
|
144 |
|
|
}
|
145 |
|
|
|
146 |
|
|
/* convert shaper rules */
|
147 |
|
|
$n = count($config['pfqueueing']['rule']);
|
148 |
|
|
if (is_array($config['pfqueueing']['rule']))
|
149 |
|
|
for ($i = 0; $i < $n; $i++) {
|
150 |
|
|
|
151 |
|
|
$fr = &$config['pfqueueing']['rule'][$i];
|
152 |
|
|
|
153 |
|
|
/* remap interface */
|
154 |
|
|
if (array_key_exists($fr['interface'], $ifmap))
|
155 |
|
|
$fr['interface'] = $ifmap[$fr['interface']];
|
156 |
|
|
else {
|
157 |
|
|
/* remove the rule */
|
158 |
4b48d1b9
|
Carlos Eduardo Ramos
|
printf(gettext("%sWarning: traffic shaper rule removed " .
|
159 |
|
|
"(interface '%s' does not exist anymore)."), "\n", $fr['interface']);
|
160 |
791bcfd4
|
Bill Marquette
|
unset($config['pfqueueing']['rule'][$i]);
|
161 |
|
|
continue;
|
162 |
|
|
}
|
163 |
|
|
|
164 |
|
|
/* remap source network */
|
165 |
|
|
if (isset($fr['source']['network'])) {
|
166 |
|
|
if (array_key_exists($fr['source']['network'], $ifmap))
|
167 |
|
|
$fr['source']['network'] = $ifmap[$fr['source']['network']];
|
168 |
|
|
else {
|
169 |
|
|
/* remove the rule */
|
170 |
4d511e5b
|
Renato Botelho
|
printf(gettext("%sWarning: traffic shaper rule removed " .
|
171 |
|
|
"(source network '%s' does not exist anymore)."), "\n", $fr['source']['network']);
|
172 |
791bcfd4
|
Bill Marquette
|
unset($config['pfqueueing']['rule'][$i]);
|
173 |
|
|
continue;
|
174 |
|
|
}
|
175 |
|
|
}
|
176 |
|
|
|
177 |
|
|
/* remap destination network */
|
178 |
|
|
if (isset($fr['destination']['network'])) {
|
179 |
|
|
if (array_key_exists($fr['destination']['network'], $ifmap))
|
180 |
|
|
$fr['destination']['network'] = $ifmap[$fr['destination']['network']];
|
181 |
|
|
else {
|
182 |
|
|
/* remove the rule */
|
183 |
4d511e5b
|
Renato Botelho
|
printf(gettext("%sWarning: traffic shaper rule removed " .
|
184 |
|
|
"(destination network '%s' does not exist anymore)."), "\n", $fr['destination']['network']);
|
185 |
791bcfd4
|
Bill Marquette
|
unset($config['pfqueueing']['rule'][$i]);
|
186 |
|
|
continue;
|
187 |
|
|
}
|
188 |
|
|
}
|
189 |
|
|
}
|
190 |
|
|
}
|
191 |
|
|
|
192 |
|
|
|
193 |
|
|
function upgrade_011_to_012() {
|
194 |
|
|
global $config;
|
195 |
|
|
/* move LAN DHCP server config */
|
196 |
|
|
$tmp = $config['dhcpd'];
|
197 |
|
|
$config['dhcpd'] = array();
|
198 |
|
|
$config['dhcpd']['lan'] = $tmp;
|
199 |
|
|
|
200 |
|
|
/* encrypt password */
|
201 |
|
|
$config['system']['password'] = crypt($config['system']['password']);
|
202 |
|
|
}
|
203 |
|
|
|
204 |
|
|
|
205 |
|
|
function upgrade_012_to_013() {
|
206 |
|
|
global $config;
|
207 |
|
|
/* convert advanced outbound NAT config */
|
208 |
|
|
for ($i = 0; isset($config['nat']['advancedoutbound']['rule'][$i]); $i++) {
|
209 |
|
|
$curent = &$config['nat']['advancedoutbound']['rule'][$i];
|
210 |
|
|
$src = $curent['source'];
|
211 |
|
|
$curent['source'] = array();
|
212 |
|
|
$curent['source']['network'] = $src;
|
213 |
|
|
$curent['destination'] = array();
|
214 |
|
|
$curent['destination']['any'] = true;
|
215 |
|
|
}
|
216 |
|
|
|
217 |
|
|
/* add an explicit type="pass" to all filter rules to make things consistent */
|
218 |
|
|
for ($i = 0; isset($config['filter']['rule'][$i]); $i++) {
|
219 |
|
|
$config['filter']['rule'][$i]['type'] = "pass";
|
220 |
|
|
}
|
221 |
|
|
}
|
222 |
|
|
|
223 |
|
|
|
224 |
|
|
function upgrade_013_to_014() {
|
225 |
|
|
global $config;
|
226 |
|
|
/* convert shaper rules (make pipes) */
|
227 |
|
|
if (is_array($config['pfqueueing']['rule'])) {
|
228 |
|
|
$config['pfqueueing']['pipe'] = array();
|
229 |
|
|
|
230 |
|
|
for ($i = 0; isset($config['pfqueueing']['rule'][$i]); $i++) {
|
231 |
|
|
$curent = &$config['pfqueueing']['rule'][$i];
|
232 |
|
|
|
233 |
|
|
/* make new pipe and associate with this rule */
|
234 |
|
|
$newpipe = array();
|
235 |
|
|
$newpipe['descr'] = $curent['descr'];
|
236 |
|
|
$newpipe['bandwidth'] = $curent['bandwidth'];
|
237 |
|
|
$newpipe['delay'] = $curent['delay'];
|
238 |
|
|
$newpipe['mask'] = $curent['mask'];
|
239 |
|
|
$config['pfqueueing']['pipe'][$i] = $newpipe;
|
240 |
|
|
|
241 |
|
|
$curent['targetpipe'] = $i;
|
242 |
|
|
|
243 |
|
|
unset($curent['bandwidth']);
|
244 |
|
|
unset($curent['delay']);
|
245 |
|
|
unset($curent['mask']);
|
246 |
|
|
}
|
247 |
|
|
}
|
248 |
|
|
}
|
249 |
|
|
|
250 |
|
|
|
251 |
|
|
function upgrade_014_to_015() {
|
252 |
|
|
global $config;
|
253 |
|
|
/* Default route moved */
|
254 |
|
|
if (isset($config['interfaces']['wan']['gateway']))
|
255 |
|
|
if ($config['interfaces']['wan']['gateway'] <> "")
|
256 |
|
|
$config['interfaces']['wan']['gateway'] = $config['interfaces']['wan']['gateway'];
|
257 |
|
|
unset($config['interfaces']['wan']['gateway']);
|
258 |
|
|
|
259 |
|
|
/* Queues are no longer interface specific */
|
260 |
|
|
if (isset($config['interfaces']['lan']['schedulertype']))
|
261 |
|
|
unset($config['interfaces']['lan']['schedulertype']);
|
262 |
|
|
if (isset($config['interfaces']['wan']['schedulertype']))
|
263 |
|
|
unset($config['interfaces']['wan']['schedulertype']);
|
264 |
|
|
|
265 |
|
|
for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
|
266 |
|
|
if(isset($config['interfaces']['opt' . $i]['schedulertype']))
|
267 |
|
|
unset($config['interfaces']['opt' . $i]['schedulertype']);
|
268 |
|
|
}
|
269 |
|
|
}
|
270 |
|
|
|
271 |
|
|
|
272 |
|
|
function upgrade_015_to_016() {
|
273 |
|
|
global $config;
|
274 |
|
|
/* Alternate firmware URL moved */
|
275 |
|
|
if (isset($config['system']['firmwareurl']) && isset($config['system']['firmwarename'])) { // Only convert if *both* are defined.
|
276 |
|
|
$config['system']['alt_firmware_url'] = array();
|
277 |
|
|
$config['system']['alt_firmware_url']['enabled'] = "";
|
278 |
|
|
$config['system']['alt_firmware_url']['firmware_base_url'] = $config['system']['firmwareurl'];
|
279 |
|
|
$config['system']['alt_firmware_url']['firmware_filename'] = $config['system']['firmwarename'];
|
280 |
|
|
unset($config['system']['firmwareurl'], $config['system']['firmwarename']);
|
281 |
|
|
} else {
|
282 |
|
|
unset($config['system']['firmwareurl'], $config['system']['firmwarename']);
|
283 |
|
|
}
|
284 |
|
|
}
|
285 |
|
|
|
286 |
|
|
|
287 |
|
|
function upgrade_016_to_017() {
|
288 |
|
|
global $config;
|
289 |
|
|
/* wipe previous shaper configuration */
|
290 |
|
|
unset($config['shaper']['queue']);
|
291 |
|
|
unset($config['shaper']['rule']);
|
292 |
|
|
unset($config['interfaces']['wan']['bandwidth']);
|
293 |
|
|
unset($config['interfaces']['wan']['bandwidthtype']);
|
294 |
|
|
unset($config['interfaces']['lan']['bandwidth']);
|
295 |
|
|
unset($config['interfaces']['lan']['bandwidthtype']);
|
296 |
|
|
$config['shaper']['enable'] = FALSE;
|
297 |
|
|
}
|
298 |
|
|
|
299 |
|
|
|
300 |
|
|
function upgrade_017_to_018() {
|
301 |
|
|
global $config;
|
302 |
|
|
if(isset($config['proxyarp']) && is_array($config['proxyarp']['proxyarpnet'])) {
|
303 |
|
|
$proxyarp = &$config['proxyarp']['proxyarpnet'];
|
304 |
|
|
foreach($proxyarp as $arpent){
|
305 |
|
|
$vip = array();
|
306 |
|
|
$vip['mode'] = "proxyarp";
|
307 |
|
|
$vip['interface'] = $arpent['interface'];
|
308 |
|
|
$vip['descr'] = $arpent['descr'];
|
309 |
|
|
if (isset($arpent['range'])) {
|
310 |
|
|
$vip['range'] = $arpent['range'];
|
311 |
|
|
$vip['type'] = "range";
|
312 |
|
|
} else {
|
313 |
|
|
$subnet = explode('/', $arpent['network']);
|
314 |
|
|
$vip['subnet'] = $subnet[0];
|
315 |
|
|
if (isset($subnet[1])) {
|
316 |
|
|
$vip['subnet_bits'] = $subnet[1];
|
317 |
|
|
$vip['type'] = "network";
|
318 |
|
|
} else {
|
319 |
|
|
$vip['subnet_bits'] = "32";
|
320 |
|
|
$vip['type'] = "single";
|
321 |
|
|
}
|
322 |
|
|
}
|
323 |
|
|
$config['virtualip']['vip'][] = $vip;
|
324 |
|
|
}
|
325 |
|
|
unset($config['proxyarp']);
|
326 |
|
|
}
|
327 |
|
|
if(isset($config['installedpackages']) && isset($config['installedpackages']['carp']) && is_array($config['installedpackages']['carp']['config'])) {
|
328 |
|
|
$carp = &$config['installedpackages']['carp']['config'];
|
329 |
|
|
foreach($carp as $carpent){
|
330 |
|
|
$vip = array();
|
331 |
|
|
$vip['mode'] = "carp";
|
332 |
|
|
$vip['interface'] = "AUTO";
|
333 |
4d511e5b
|
Renato Botelho
|
$vip['descr'] = sprintf(gettext("CARP vhid %s"), $carpent['vhid']);
|
334 |
791bcfd4
|
Bill Marquette
|
$vip['type'] = "single";
|
335 |
|
|
$vip['vhid'] = $carpent['vhid'];
|
336 |
|
|
$vip['advskew'] = $carpent['advskew'];
|
337 |
|
|
$vip['password'] = $carpent['password'];
|
338 |
|
|
$vip['subnet'] = $carpent['ipaddress'];
|
339 |
|
|
$vip['subnet_bits'] = $carpent['netmask'];
|
340 |
|
|
$config['virtualip']['vip'][] = $vip;
|
341 |
|
|
}
|
342 |
|
|
unset($config['installedpackages']['carp']);
|
343 |
|
|
}
|
344 |
|
|
/* Server NAT is no longer needed */
|
345 |
|
|
unset($config['nat']['servernat']);
|
346 |
|
|
|
347 |
|
|
/* enable SSH */
|
348 |
|
|
if ($config['version'] == "1.8") {
|
349 |
|
|
$config['system']['sshenabled'] = true;
|
350 |
|
|
}
|
351 |
|
|
}
|
352 |
|
|
|
353 |
|
|
|
354 |
|
|
function upgrade_018_to_019() {
|
355 |
|
|
global $config;
|
356 |
|
|
$config['theme']="metallic";
|
357 |
|
|
}
|
358 |
|
|
|
359 |
|
|
|
360 |
|
|
function upgrade_019_to_020() {
|
361 |
|
|
global $config;
|
362 |
|
|
if(is_array($config['ipsec']['tunnel'])) {
|
363 |
|
|
reset($config['ipsec']['tunnel']);
|
364 |
|
|
while (list($index, $tunnel) = each($config['ipsec']['tunnel'])) {
|
365 |
|
|
/* Sanity check on required variables */
|
366 |
|
|
/* This fixes bogus <tunnel> entries - remnant of bug #393 */
|
367 |
|
|
if (!isset($tunnel['local-subnet']) && !isset($tunnel['remote-subnet'])) {
|
368 |
|
|
unset($config['ipsec']['tunnel'][$tunnel]);
|
369 |
|
|
}
|
370 |
|
|
}
|
371 |
|
|
}
|
372 |
|
|
}
|
373 |
|
|
|
374 |
|
|
function upgrade_020_to_021() {
|
375 |
|
|
global $config;
|
376 |
|
|
/* shaper scheduler moved */
|
377 |
|
|
if(isset($config['system']['schedulertype'])) {
|
378 |
|
|
$config['shaper']['schedulertype'] = $config['system']['schedulertype'];
|
379 |
|
|
unset($config['system']['schedulertype']);
|
380 |
|
|
}
|
381 |
|
|
}
|
382 |
|
|
|
383 |
|
|
|
384 |
|
|
function upgrade_021_to_022() {
|
385 |
|
|
global $config;
|
386 |
|
|
/* move gateway to wan interface */
|
387 |
|
|
$config['interfaces']['wan']['gateway'] = $config['system']['gateway'];
|
388 |
|
|
}
|
389 |
|
|
|
390 |
|
|
function upgrade_022_to_023() {
|
391 |
|
|
global $config;
|
392 |
|
|
if(isset($config['shaper'])) {
|
393 |
|
|
/* wipe previous shaper configuration */
|
394 |
|
|
unset($config['shaper']);
|
395 |
|
|
}
|
396 |
|
|
}
|
397 |
|
|
|
398 |
|
|
|
399 |
|
|
function upgrade_023_to_024() {
|
400 |
|
|
global $config;
|
401 |
|
|
}
|
402 |
|
|
|
403 |
|
|
|
404 |
|
|
function upgrade_024_to_025() {
|
405 |
|
|
global $config;
|
406 |
|
|
$config['interfaces']['wan']['use_rrd_gateway'] = $config['system']['use_rrd_gateway'];
|
407 |
|
|
unset($config['system']['use_rrd_gateway']);
|
408 |
|
|
}
|
409 |
|
|
|
410 |
|
|
|
411 |
|
|
function upgrade_025_to_026() {
|
412 |
|
|
global $config;
|
413 |
|
|
$cron_item = array();
|
414 |
|
|
$cron_item['minute'] = "0";
|
415 |
|
|
$cron_item['hour'] = "*";
|
416 |
|
|
$cron_item['mday'] = "*";
|
417 |
|
|
$cron_item['month'] = "*";
|
418 |
|
|
$cron_item['wday'] = "*";
|
419 |
|
|
$cron_item['who'] = "root";
|
420 |
|
|
$cron_item['command'] = "/usr/bin/nice -n20 newsyslog";
|
421 |
|
|
|
422 |
|
|
$config['cron']['item'][] = $cron_item;
|
423 |
|
|
|
424 |
|
|
$cron_item = array();
|
425 |
|
|
$cron_item['minute'] = "1,31";
|
426 |
|
|
$cron_item['hour'] = "0-5";
|
427 |
|
|
$cron_item['mday'] = "*";
|
428 |
|
|
$cron_item['month'] = "*";
|
429 |
|
|
$cron_item['wday'] = "*";
|
430 |
|
|
$cron_item['who'] = "root";
|
431 |
|
|
$cron_item['command'] = "/usr/bin/nice -n20 adjkerntz -a";
|
432 |
|
|
|
433 |
|
|
$config['cron']['item'][] = $cron_item;
|
434 |
|
|
|
435 |
|
|
$cron_item = array();
|
436 |
|
|
$cron_item['minute'] = "1";
|
437 |
|
|
$cron_item['hour'] = "*";
|
438 |
|
|
$cron_item['mday'] = "1";
|
439 |
|
|
$cron_item['month'] = "*";
|
440 |
|
|
$cron_item['wday'] = "*";
|
441 |
|
|
$cron_item['who'] = "root";
|
442 |
|
|
$cron_item['command'] = "/usr/bin/nice -n20 /etc/rc.update_bogons.sh";
|
443 |
|
|
|
444 |
|
|
$config['cron']['item'][] = $cron_item;
|
445 |
|
|
|
446 |
|
|
$cron_item = array();
|
447 |
|
|
$cron_item['minute'] = "*/60";
|
448 |
|
|
$cron_item['hour'] = "*";
|
449 |
|
|
$cron_item['mday'] = "*";
|
450 |
|
|
$cron_item['month'] = "*";
|
451 |
|
|
$cron_item['wday'] = "*";
|
452 |
|
|
$cron_item['who'] = "root";
|
453 |
|
|
$cron_item['command'] = "/usr/bin/nice -n20 /usr/local/sbin/expiretable -v -t 3600 sshlockout";
|
454 |
|
|
|
455 |
|
|
$config['cron']['item'][] = $cron_item;
|
456 |
|
|
|
457 |
|
|
$cron_item = array();
|
458 |
|
|
$cron_item['minute'] = "1";
|
459 |
|
|
$cron_item['hour'] = "1";
|
460 |
|
|
$cron_item['mday'] = "*";
|
461 |
|
|
$cron_item['month'] = "*";
|
462 |
|
|
$cron_item['wday'] = "*";
|
463 |
|
|
$cron_item['who'] = "root";
|
464 |
|
|
$cron_item['command'] = "/usr/bin/nice -n20 /etc/rc.dyndns.update";
|
465 |
|
|
|
466 |
|
|
$config['cron']['item'][] = $cron_item;
|
467 |
|
|
|
468 |
|
|
$cron_item = array();
|
469 |
|
|
$cron_item['minute'] = "*/60";
|
470 |
|
|
$cron_item['hour'] = "*";
|
471 |
|
|
$cron_item['mday'] = "*";
|
472 |
|
|
$cron_item['month'] = "*";
|
473 |
|
|
$cron_item['wday'] = "*";
|
474 |
|
|
$cron_item['who'] = "root";
|
475 |
|
|
$cron_item['command'] = "/usr/bin/nice -n20 /usr/local/sbin/expiretable -v -t 3600 virusprot";
|
476 |
|
|
|
477 |
|
|
$config['cron']['item'][] = $cron_item;
|
478 |
|
|
|
479 |
|
|
$cron_item = array();
|
480 |
|
|
$cron_item['minute'] = "*/60";
|
481 |
|
|
$cron_item['hour'] = "*";
|
482 |
|
|
$cron_item['mday'] = "*";
|
483 |
|
|
$cron_item['month'] = "*";
|
484 |
|
|
$cron_item['wday'] = "*";
|
485 |
|
|
$cron_item['who'] = "root";
|
486 |
|
|
$cron_item['command'] = "/usr/bin/nice -n20 /usr/local/sbin/expiretable -t 1800 snort2c";
|
487 |
|
|
|
488 |
|
|
$config['cron']['item'][] = $cron_item;
|
489 |
|
|
}
|
490 |
|
|
|
491 |
|
|
|
492 |
|
|
function upgrade_026_to_027() {
|
493 |
|
|
global $config;
|
494 |
|
|
}
|
495 |
|
|
|
496 |
|
|
|
497 |
|
|
function upgrade_027_to_028() {
|
498 |
|
|
global $config;
|
499 |
|
|
}
|
500 |
|
|
|
501 |
|
|
|
502 |
|
|
function upgrade_028_to_029() {
|
503 |
|
|
global $config;
|
504 |
|
|
$rule_item = array();
|
505 |
|
|
$a_filter = &$config['filter']['rule'];
|
506 |
|
|
$rule_item['interface'] = "enc0";
|
507 |
|
|
$rule_item['type'] = "pass";
|
508 |
|
|
$rule_item['source']['any'] = true;
|
509 |
|
|
$rule_item['destination']['any'] = true;
|
510 |
4d511e5b
|
Renato Botelho
|
$rule_item['descr'] = gettext("Permit IPsec traffic.");
|
511 |
791bcfd4
|
Bill Marquette
|
$rule_item['statetype'] = "keep state";
|
512 |
|
|
$a_filter[] = $rule_item;
|
513 |
|
|
}
|
514 |
|
|
|
515 |
|
|
|
516 |
|
|
function upgrade_029_to_030() {
|
517 |
|
|
global $config;
|
518 |
|
|
/* enable the rrd config setting by default */
|
519 |
|
|
$config['rrd']['enable'] = true;
|
520 |
|
|
}
|
521 |
|
|
|
522 |
|
|
|
523 |
|
|
function upgrade_030_to_031() {
|
524 |
|
|
global $config;
|
525 |
|
|
/* Insert upgrade code here */
|
526 |
|
|
}
|
527 |
|
|
|
528 |
|
|
|
529 |
|
|
function upgrade_031_to_032() {
|
530 |
|
|
global $config;
|
531 |
|
|
/* Insert upgrade code here */
|
532 |
|
|
}
|
533 |
|
|
|
534 |
|
|
|
535 |
|
|
function upgrade_032_to_033() {
|
536 |
|
|
global $config;
|
537 |
|
|
/* Insert upgrade code here */
|
538 |
|
|
}
|
539 |
|
|
|
540 |
|
|
|
541 |
|
|
function upgrade_033_to_034() {
|
542 |
|
|
global $config;
|
543 |
|
|
/* Insert upgrade code here */
|
544 |
|
|
}
|
545 |
|
|
|
546 |
|
|
|
547 |
|
|
function upgrade_034_to_035() {
|
548 |
|
|
global $config;
|
549 |
|
|
/* Insert upgrade code here */
|
550 |
|
|
}
|
551 |
|
|
|
552 |
|
|
|
553 |
|
|
function upgrade_035_to_036() {
|
554 |
|
|
global $config;
|
555 |
|
|
/* Insert upgrade code here */
|
556 |
|
|
}
|
557 |
|
|
|
558 |
|
|
|
559 |
|
|
function upgrade_036_to_037() {
|
560 |
|
|
global $config;
|
561 |
|
|
/* Insert upgrade code here */
|
562 |
|
|
}
|
563 |
|
|
|
564 |
|
|
|
565 |
|
|
function upgrade_037_to_038() {
|
566 |
|
|
global $config;
|
567 |
db7f618b
|
Seth Mos
|
/* Insert upgrade code here */
|
568 |
791bcfd4
|
Bill Marquette
|
}
|
569 |
|
|
|
570 |
|
|
|
571 |
|
|
function upgrade_038_to_039() {
|
572 |
|
|
global $config;
|
573 |
ef026950
|
Ermal Lu?i
|
/* Insert upgrade code here */
|
574 |
791bcfd4
|
Bill Marquette
|
}
|
575 |
|
|
|
576 |
|
|
|
577 |
|
|
function upgrade_039_to_040() {
|
578 |
|
|
global $config;
|
579 |
|
|
$config['system']['webgui']['auth_method'] = "session";
|
580 |
|
|
$config['system']['webgui']['backing_method'] = "htpasswd";
|
581 |
|
|
|
582 |
|
|
if (isset ($config['system']['username'])) {
|
583 |
|
|
$config['system']['group'] = array();
|
584 |
|
|
$config['system']['group'][0]['name'] = "admins";
|
585 |
4d511e5b
|
Renato Botelho
|
$config['system']['group'][0]['description'] = gettext("System Administrators");
|
586 |
791bcfd4
|
Bill Marquette
|
$config['system']['group'][0]['scope'] = "system";
|
587 |
ebcdcaaa
|
jim-p
|
$config['system']['group'][0]['priv'] = "page-all";
|
588 |
791bcfd4
|
Bill Marquette
|
$config['system']['group'][0]['home'] = "index.php";
|
589 |
|
|
$config['system']['group'][0]['gid'] = "110";
|
590 |
|
|
|
591 |
|
|
$config['system']['user'] = array();
|
592 |
|
|
$config['system']['user'][0]['name'] = "{$config['system']['username']}";
|
593 |
9ff73b79
|
jim-p
|
$config['system']['user'][0]['descr'] = "System Administrator";
|
594 |
791bcfd4
|
Bill Marquette
|
$config['system']['user'][0]['scope'] = "system";
|
595 |
|
|
$config['system']['user'][0]['groupname'] = "admins";
|
596 |
|
|
$config['system']['user'][0]['password'] = "{$config['system']['password']}";
|
597 |
|
|
$config['system']['user'][0]['uid'] = "0";
|
598 |
6d8e6b22
|
jim-p
|
/* Ensure that we follow what this new "admin" username should be in the session. */
|
599 |
|
|
$_SESSION["Username"] = "{$config['system']['username']}";
|
600 |
791bcfd4
|
Bill Marquette
|
|
601 |
|
|
$config['system']['user'][0]['priv'] = array();
|
602 |
|
|
$config['system']['user'][0]['priv'][0]['id'] = "lockwc";
|
603 |
|
|
$config['system']['user'][0]['priv'][0]['name'] = "Lock webConfigurator";
|
604 |
4d511e5b
|
Renato Botelho
|
$config['system']['user'][0]['priv'][0]['descr'] = gettext("Indicates whether this user will lock access to the webConfigurator for other users.");
|
605 |
791bcfd4
|
Bill Marquette
|
$config['system']['user'][0]['priv'][1]['id'] = "lock-ipages";
|
606 |
|
|
$config['system']['user'][0]['priv'][1]['name'] = "Lock individual pages";
|
607 |
4d511e5b
|
Renato Botelho
|
$config['system']['user'][0]['priv'][1]['descr'] = gettext("Indicates whether this user will lock individual HTML pages after having accessed a particular page (the lock will be freed if the user leaves or saves the page form).");
|
608 |
791bcfd4
|
Bill Marquette
|
$config['system']['user'][0]['priv'][2]['id'] = "hasshell";
|
609 |
|
|
$config['system']['user'][0]['priv'][2]['name'] = "Has shell access";
|
610 |
4d511e5b
|
Renato Botelho
|
$config['system']['user'][0]['priv'][2]['descr'] = gettext("Indicates whether this user is able to login for example via SSH.");
|
611 |
791bcfd4
|
Bill Marquette
|
$config['system']['user'][0]['priv'][3]['id'] = "copyfiles";
|
612 |
|
|
$config['system']['user'][0]['priv'][3]['name'] = "Is allowed to copy files";
|
613 |
4d511e5b
|
Renato Botelho
|
$config['system']['user'][0]['priv'][3]['descr'] = sprintf(gettext("Indicates whether this user is allowed to copy files onto the %s appliance via SCP/SFTP. If you are going to use this privilege, you must install scponly on the appliance (Hint: pkg_add -r scponly)."), $g['product_name']);
|
614 |
791bcfd4
|
Bill Marquette
|
$config['system']['user'][0]['priv'][4]['id'] = "isroot";
|
615 |
|
|
$config['system']['user'][0]['priv'][4]['name'] = "Is root user";
|
616 |
4d511e5b
|
Renato Botelho
|
$config['system']['user'][0]['priv'][4]['descr'] = gettext("This user is associated with the UNIX root user (you should associate this privilege only with one single user).");
|
617 |
791bcfd4
|
Bill Marquette
|
|
618 |
|
|
$config['system']['nextuid'] = "111";
|
619 |
|
|
$config['system']['nextgid'] = "111";
|
620 |
|
|
|
621 |
|
|
/* wipe previous auth configuration */
|
622 |
|
|
unset ($config['system']['username']);
|
623 |
|
|
unset ($config['system']['password']);
|
624 |
|
|
}
|
625 |
|
|
}
|
626 |
|
|
|
627 |
|
|
function upgrade_040_to_041() {
|
628 |
|
|
global $config;
|
629 |
|
|
if(!$config['sysctl']) {
|
630 |
|
|
$config['sysctl']['item'] = array();
|
631 |
|
|
|
632 |
|
|
$config['sysctl']['item'][0]['tunable'] = "net.inet.tcp.blackhole";
|
633 |
4816e5ca
|
Renato Botelho
|
$config['sysctl']['item'][0]['descr'] = gettext("Drop packets to closed TCP ports without returning a RST");
|
634 |
908c4eea
|
sullrich
|
$config['sysctl']['item'][0]['value'] = "default";
|
635 |
791bcfd4
|
Bill Marquette
|
|
636 |
|
|
$config['sysctl']['item'][1]['tunable'] = "net.inet.udp.blackhole";
|
637 |
4816e5ca
|
Renato Botelho
|
$config['sysctl']['item'][1]['descr'] = gettext("Do not send ICMP port unreachable messages for closed UDP ports");
|
638 |
908c4eea
|
sullrich
|
$config['sysctl']['item'][1]['value'] = "default";
|
639 |
791bcfd4
|
Bill Marquette
|
|
640 |
|
|
$config['sysctl']['item'][2]['tunable'] = "net.inet.ip.random_id";
|
641 |
4816e5ca
|
Renato Botelho
|
$config['sysctl']['item'][2]['descr'] = gettext("Randomize the ID field in IP packets (default is 0: sequential IP IDs)");
|
642 |
908c4eea
|
sullrich
|
$config['sysctl']['item'][2]['value'] = "default";
|
643 |
791bcfd4
|
Bill Marquette
|
|
644 |
|
|
$config['sysctl']['item'][3]['tunable'] = "net.inet.tcp.drop_synfin";
|
645 |
4816e5ca
|
Renato Botelho
|
$config['sysctl']['item'][3]['descr'] = gettext("Drop SYN-FIN packets (breaks RFC1379, but nobody uses it anyway)");
|
646 |
908c4eea
|
sullrich
|
$config['sysctl']['item'][3]['value'] = "default";
|
647 |
791bcfd4
|
Bill Marquette
|
|
648 |
|
|
$config['sysctl']['item'][4]['tunable'] = "net.inet.ip.redirect";
|
649 |
4816e5ca
|
Renato Botelho
|
$config['sysctl']['item'][4]['descr'] = gettext("Sending of IPv4 ICMP redirects");
|
650 |
908c4eea
|
sullrich
|
$config['sysctl']['item'][4]['value'] = "default";
|
651 |
791bcfd4
|
Bill Marquette
|
|
652 |
|
|
$config['sysctl']['item'][5]['tunable'] = "net.inet6.ip6.redirect";
|
653 |
4816e5ca
|
Renato Botelho
|
$config['sysctl']['item'][5]['descr'] = gettext("Sending of IPv6 ICMP redirects");
|
654 |
908c4eea
|
sullrich
|
$config['sysctl']['item'][5]['value'] = "default";
|
655 |
791bcfd4
|
Bill Marquette
|
|
656 |
|
|
$config['sysctl']['item'][6]['tunable'] = "net.inet.tcp.syncookies";
|
657 |
4816e5ca
|
Renato Botelho
|
$config['sysctl']['item'][6]['descr'] = gettext("Generate SYN cookies for outbound SYN-ACK packets");
|
658 |
908c4eea
|
sullrich
|
$config['sysctl']['item'][6]['value'] = "default";
|
659 |
791bcfd4
|
Bill Marquette
|
|
660 |
|
|
$config['sysctl']['item'][7]['tunable'] = "net.inet.tcp.recvspace";
|
661 |
4816e5ca
|
Renato Botelho
|
$config['sysctl']['item'][7]['descr'] = gettext("Maximum incoming TCP datagram size");
|
662 |
908c4eea
|
sullrich
|
$config['sysctl']['item'][7]['value'] = "default";
|
663 |
791bcfd4
|
Bill Marquette
|
|
664 |
|
|
$config['sysctl']['item'][8]['tunable'] = "net.inet.tcp.sendspace";
|
665 |
4816e5ca
|
Renato Botelho
|
$config['sysctl']['item'][8]['descr'] = gettext("Maximum outgoing TCP datagram size");
|
666 |
908c4eea
|
sullrich
|
$config['sysctl']['item'][8]['value'] = "default";
|
667 |
791bcfd4
|
Bill Marquette
|
|
668 |
|
|
$config['sysctl']['item'][9]['tunable'] = "net.inet.ip.fastforwarding";
|
669 |
4816e5ca
|
Renato Botelho
|
$config['sysctl']['item'][9]['descr'] = gettext("Fastforwarding (see http://lists.freebsd.org/pipermail/freebsd-net/2004-January/002534.html)");
|
670 |
908c4eea
|
sullrich
|
$config['sysctl']['item'][9]['value'] = "default";
|
671 |
791bcfd4
|
Bill Marquette
|
|
672 |
|
|
$config['sysctl']['item'][10]['tunable'] = "net.inet.tcp.delayed_ack";
|
673 |
4816e5ca
|
Renato Botelho
|
$config['sysctl']['item'][10]['descr'] = gettext("Do not delay ACK to try and piggyback it onto a data packet");
|
674 |
908c4eea
|
sullrich
|
$config['sysctl']['item'][10]['value'] = "default";
|
675 |
791bcfd4
|
Bill Marquette
|
|
676 |
|
|
$config['sysctl']['item'][11]['tunable'] = "net.inet.udp.maxdgram";
|
677 |
4816e5ca
|
Renato Botelho
|
$config['sysctl']['item'][11]['descr'] = gettext("Maximum outgoing UDP datagram size");
|
678 |
908c4eea
|
sullrich
|
$config['sysctl']['item'][11]['value'] = "default";
|
679 |
791bcfd4
|
Bill Marquette
|
|
680 |
|
|
$config['sysctl']['item'][12]['tunable'] = "net.link.bridge.pfil_onlyip";
|
681 |
4816e5ca
|
Renato Botelho
|
$config['sysctl']['item'][12]['descr'] = gettext("Handling of non-IP packets which are not passed to pfil (see if_bridge(4))");
|
682 |
908c4eea
|
sullrich
|
$config['sysctl']['item'][12]['value'] = "default";
|
683 |
791bcfd4
|
Bill Marquette
|
|
684 |
|
|
$config['sysctl']['item'][13]['tunable'] = "net.link.tap.user_open";
|
685 |
4816e5ca
|
Renato Botelho
|
$config['sysctl']['item'][13]['descr'] = gettext("Allow unprivileged access to tap(4) device nodes");
|
686 |
908c4eea
|
sullrich
|
$config['sysctl']['item'][13]['value'] = "default";
|
687 |
791bcfd4
|
Bill Marquette
|
|
688 |
|
|
$config['sysctl']['item'][15]['tunable'] = "kern.randompid";
|
689 |
4816e5ca
|
Renato Botelho
|
$config['sysctl']['item'][15]['descr'] = gettext("Randomize PID's (see src/sys/kern/kern_fork.c: sysctl_kern_randompid())");
|
690 |
908c4eea
|
sullrich
|
$config['sysctl']['item'][15]['value'] = "default";
|
691 |
791bcfd4
|
Bill Marquette
|
|
692 |
|
|
$config['sysctl']['item'][16]['tunable'] = "net.inet.tcp.inflight.enable";
|
693 |
4816e5ca
|
Renato Botelho
|
$config['sysctl']['item'][16]['descr'] = gettext("The system will attempt to calculate the bandwidth delay product for each connection and limit the amount of data queued to the network to just the amount required to maintain optimum throughput. ");
|
694 |
908c4eea
|
sullrich
|
$config['sysctl']['item'][16]['value'] = "default";
|
695 |
791bcfd4
|
Bill Marquette
|
|
696 |
|
|
$config['sysctl']['item'][17]['tunable'] = "net.inet.icmp.icmplim";
|
697 |
4816e5ca
|
Renato Botelho
|
$config['sysctl']['item'][17]['descr'] = gettext("Set ICMP Limits");
|
698 |
908c4eea
|
sullrich
|
$config['sysctl']['item'][17]['value'] = "default";
|
699 |
791bcfd4
|
Bill Marquette
|
|
700 |
|
|
$config['sysctl']['item'][18]['tunable'] = "net.inet.tcp.tso";
|
701 |
4816e5ca
|
Renato Botelho
|
$config['sysctl']['item'][18]['descr'] = gettext("TCP Offload engine");
|
702 |
908c4eea
|
sullrich
|
$config['sysctl']['item'][18]['value'] = "default";
|
703 |
06702ef7
|
Chris Buechler
|
|
704 |
558dda01
|
Scott Ullrich
|
$config['sysctl']['item'][19]['tunable'] = "net.inet.ip.portrange.first";
|
705 |
|
|
$config['sysctl']['item'][19]['descr'] = "Set the ephemeral port range starting port";
|
706 |
|
|
$config['sysctl']['item'][19]['value'] = "default";
|
707 |
908c4eea
|
sullrich
|
|
708 |
64c86313
|
Warren Baker
|
$config['sysctl']['item'][20]['tunable'] = "hw.syscons.kbd_reboot";
|
709 |
558dda01
|
Scott Ullrich
|
$config['sysctl']['item'][20]['descr'] = "Enables ctrl+alt+delete";
|
710 |
|
|
$config['sysctl']['item'][20]['value'] = "default";
|
711 |
06702ef7
|
Chris Buechler
|
|
712 |
99fbc94a
|
Warren Baker
|
$config['sysctl']['item'][21]['tunable'] = "kern.ipc.maxsockbuf";
|
713 |
|
|
$config['sysctl']['item'][21]['descr'] = "Maximum socket buffer size";
|
714 |
|
|
$config['sysctl']['item'][21]['value'] = "default";
|
715 |
64c86313
|
Warren Baker
|
|
716 |
791bcfd4
|
Bill Marquette
|
}
|
717 |
|
|
}
|
718 |
|
|
|
719 |
|
|
|
720 |
|
|
function upgrade_041_to_042() {
|
721 |
|
|
global $config;
|
722 |
|
|
if (isset($config['shaper']))
|
723 |
|
|
unset($config['shaper']);
|
724 |
|
|
if (isset($config['ezshaper']))
|
725 |
|
|
unset($config['ezshaper']);
|
726 |
|
|
}
|
727 |
|
|
|
728 |
|
|
|
729 |
|
|
function upgrade_042_to_043() {
|
730 |
|
|
global $config;
|
731 |
|
|
/* migrate old interface gateway to the new gateways config */
|
732 |
ab0eced7
|
Ermal
|
$iflist = get_configured_interface_list(false, true);
|
733 |
791bcfd4
|
Bill Marquette
|
$gateways = array();
|
734 |
|
|
$i = 0;
|
735 |
fc85edaf
|
Seth Mos
|
foreach($iflist as $ifname => $interface) {
|
736 |
|
|
if(! interface_has_gateway($ifname)) {
|
737 |
|
|
continue;
|
738 |
|
|
}
|
739 |
b314ab72
|
Ermal
|
$config['gateways']['gateway_item'][$i] = array();
|
740 |
a63ab6b6
|
Seth Mos
|
if(is_ipaddr($config['interfaces'][$ifname]['gateway'])) {
|
741 |
3240836a
|
Seth Mos
|
$config['gateways']['gateway_item'][$i]['gateway'] = $config['interfaces'][$ifname]['gateway'];
|
742 |
4d511e5b
|
Renato Botelho
|
$config['gateways']['gateway_item'][$i]['descr'] = sprintf(gettext("Interface %s Static Gateway"), $ifname);
|
743 |
2328dcc5
|
Seth Mos
|
} else {
|
744 |
|
|
$config['gateways']['gateway_item'][$i]['gateway'] = "dynamic";
|
745 |
4d511e5b
|
Renato Botelho
|
$config['gateways']['gateway_item'][$i]['descr'] = sprintf(gettext("Interface %s Dynamic Gateway"), $ifname);
|
746 |
2328dcc5
|
Seth Mos
|
}
|
747 |
|
|
$config['gateways']['gateway_item'][$i]['interface'] = $ifname;
|
748 |
|
|
$config['gateways']['gateway_item'][$i]['name'] = "GW_" . strtoupper($ifname);
|
749 |
|
|
/* add default gateway bit for wan on upgrade */
|
750 |
|
|
if($ifname == "wan") {
|
751 |
|
|
$config['gateways']['gateway_item'][$i]['defaultgw'] = true;
|
752 |
|
|
}
|
753 |
|
|
if(is_ipaddr($config['interfaces'][$ifname]['use_rrd_gateway'])) {
|
754 |
|
|
$config['gateways']['gateway_item'][$i]['monitor'] = $config['interfaces'][$ifname]['use_rrd_gateway'];
|
755 |
|
|
unset($config['interfaces'][$ifname]['use_rrd_gateway']);
|
756 |
|
|
}
|
757 |
|
|
$config['interfaces'][$ifname]['gateway'] = $config['gateways']['gateway_item'][$i]['name'];
|
758 |
3240836a
|
Seth Mos
|
|
759 |
2328dcc5
|
Seth Mos
|
/* Update all filter rules which might reference this gateway */
|
760 |
|
|
$j = 0;
|
761 |
|
|
foreach($config['filter']['rule'] as $rule) {
|
762 |
6364b88b
|
Ermal
|
if(is_ipaddr($rule['gateway'])) {
|
763 |
|
|
if ($rule['gateway'] == $config['gateways']['gateway_item'][$i]['gateway'])
|
764 |
|
|
$config['filter']['rule'][$j]['gateway'] = $config['gateways']['gateway_item'][$i]['name'];
|
765 |
|
|
else if ($rule['gateway'] == $ifname)
|
766 |
|
|
$config['filter']['rule'][$j]['gateway'] = $config['gateways']['gateway_item'][$i]['name'];
|
767 |
3240836a
|
Seth Mos
|
}
|
768 |
2328dcc5
|
Seth Mos
|
$j++;
|
769 |
791bcfd4
|
Bill Marquette
|
}
|
770 |
c9ba2835
|
smos
|
|
771 |
|
|
/* rename old Quality RRD files in the process */
|
772 |
|
|
$rrddbpath = "/var/db/rrd";
|
773 |
|
|
$gwname = "GW_" . strtoupper($ifname);
|
774 |
|
|
if(is_readable("{$rrddbpath}/{$ifname}-quality.rrd")) {
|
775 |
|
|
rename("{$rrddbpath}/{$ifname}-quality.rrd", "{$rrddbpath}/{$gwname}-quality.rrd");
|
776 |
|
|
}
|
777 |
2328dcc5
|
Seth Mos
|
$i++;
|
778 |
791bcfd4
|
Bill Marquette
|
}
|
779 |
|
|
}
|
780 |
|
|
|
781 |
|
|
|
782 |
|
|
function upgrade_043_to_044() {
|
783 |
|
|
global $config;
|
784 |
a842e988
|
Ermal
|
|
785 |
|
|
/* migrate static routes to the new gateways config */
|
786 |
|
|
$gateways = return_gateways_array(true);
|
787 |
6cae2c44
|
Ermal
|
$i = 0;
|
788 |
a842e988
|
Ermal
|
if (is_array($config['staticroutes']['route'])) {
|
789 |
323f3f9c
|
smos
|
$gwmap = array();
|
790 |
a842e988
|
Ermal
|
foreach ($config['staticroutes']['route'] as $idx => $sroute) {
|
791 |
|
|
$found = false;
|
792 |
|
|
foreach ($gateways as $gwname => $gw) {
|
793 |
|
|
if ($gw['gateway'] == $sroute['gateway']) {
|
794 |
|
|
$config['staticroutes']['route'][$idx]['gateway'] = $gwname;
|
795 |
|
|
$found = true;
|
796 |
|
|
break;
|
797 |
|
|
}
|
798 |
|
|
}
|
799 |
323f3f9c
|
smos
|
if($gwmap[$sroute['gateway']]) {
|
800 |
|
|
/* We already added a gateway name for this IP */
|
801 |
|
|
$config['staticroutes']['route'][$idx]['gateway'] = "{$gwmap[$sroute['gateway']]}";
|
802 |
|
|
$found = true;
|
803 |
|
|
}
|
804 |
a842e988
|
Ermal
|
if ($found == false) {
|
805 |
|
|
$gateway = array();
|
806 |
323f3f9c
|
smos
|
$gateway['name'] = "SROUTE{$i}";
|
807 |
|
|
$gwmap[$sroute['gateway']] = $gateway['name'];
|
808 |
a842e988
|
Ermal
|
$gateway['gateway'] = $sroute['gateway'];
|
809 |
|
|
$gateway['interface'] = $sroute['interface'];
|
810 |
4d511e5b
|
Renato Botelho
|
$gateway['descr'] = sprintf(gettext("Upgraded static route for %s"), $sroute['network']);
|
811 |
a842e988
|
Ermal
|
if (!is_array($config['gateways']['gateway_item']))
|
812 |
|
|
$config['gateways']['gateway_item'] = array();
|
813 |
|
|
$config['gateways']['gateway_item'][] = $gateway;
|
814 |
|
|
$config['staticroutes']['route'][$idx]['gateway'] = $gateway['name'];
|
815 |
6cae2c44
|
Ermal
|
$i++;
|
816 |
a842e988
|
Ermal
|
}
|
817 |
|
|
}
|
818 |
|
|
}
|
819 |
791bcfd4
|
Bill Marquette
|
}
|
820 |
|
|
|
821 |
|
|
|
822 |
|
|
function upgrade_044_to_045() {
|
823 |
|
|
global $config;
|
824 |
da74e673
|
Seth Mos
|
$iflist = get_configured_interface_list(false, true);
|
825 |
791bcfd4
|
Bill Marquette
|
if (is_array($config['vlans']['vlan']) && count($config['vlans']['vlan'])) {
|
826 |
3d039701
|
smos
|
$i = 0;
|
827 |
da74e673
|
Seth Mos
|
foreach ($config['vlans']['vlan'] as $id => $vlan) {
|
828 |
|
|
/* Make sure to update the interfaces section with the right name */
|
829 |
62958eae
|
smos
|
$vlan_name = "{$vlan['if']}_vlan{$vlan['tag']}";
|
830 |
da74e673
|
Seth Mos
|
foreach($iflist as $ifname) {
|
831 |
3d039701
|
smos
|
if($config['interfaces'][$ifname]['if'] == "vlan{$i}") {
|
832 |
62958eae
|
smos
|
$config['interfaces'][$ifname]['if'] = $vlan_name;
|
833 |
|
|
continue;
|
834 |
da74e673
|
Seth Mos
|
}
|
835 |
|
|
}
|
836 |
62958eae
|
smos
|
$config['vlans']['vlan'][$i]['vlanif'] = "{$vlan_name}";
|
837 |
3d039701
|
smos
|
$i++;
|
838 |
da74e673
|
Seth Mos
|
}
|
839 |
791bcfd4
|
Bill Marquette
|
}
|
840 |
|
|
}
|
841 |
|
|
|
842 |
|
|
|
843 |
|
|
function upgrade_045_to_046() {
|
844 |
|
|
global $config;
|
845 |
506514e7
|
jim-p
|
/* Load up monitors that are in the default config for 2.0 but not in 1.2.3
|
846 |
|
|
thus wouldn't be in an upgraded config. */
|
847 |
|
|
$config['load_balancer']['monitor_type'] = array (
|
848 |
|
|
array ( 'name' => 'ICMP',
|
849 |
|
|
'type' => 'icmp',
|
850 |
|
|
'descr' => 'ICMP',
|
851 |
|
|
'options' => '',
|
852 |
|
|
),
|
853 |
|
|
array ( 'name' => 'TCP',
|
854 |
|
|
'type' => 'tcp',
|
855 |
|
|
'descr' => 'Generic TCP',
|
856 |
|
|
'options' => '',
|
857 |
|
|
),
|
858 |
|
|
array ( 'name' => 'HTTP',
|
859 |
|
|
'type' => 'http',
|
860 |
|
|
'descr' => 'Generic HTTP',
|
861 |
|
|
'options' =>
|
862 |
|
|
array ( 'path' => '/',
|
863 |
|
|
'host' => '',
|
864 |
|
|
'code' => '200',
|
865 |
|
|
),
|
866 |
|
|
),
|
867 |
|
|
array ( 'name' => 'HTTPS',
|
868 |
|
|
'type' => 'https',
|
869 |
|
|
'descr' => 'Generic HTTPS',
|
870 |
|
|
'options' =>
|
871 |
|
|
array ( 'path' => '/',
|
872 |
|
|
'host' => '',
|
873 |
|
|
'code' => '200',
|
874 |
|
|
),
|
875 |
|
|
),
|
876 |
|
|
array ( 'name' => 'SMTP',
|
877 |
|
|
'type' => 'send',
|
878 |
|
|
'descr' => 'Generic SMTP',
|
879 |
|
|
'options' =>
|
880 |
520d4137
|
jim-p
|
array ( 'send' => '',
|
881 |
|
|
'expect' => '220 *',
|
882 |
506514e7
|
jim-p
|
),
|
883 |
|
|
),
|
884 |
|
|
);
|
885 |
791bcfd4
|
Bill Marquette
|
/* Upgrade load balancer from slb to relayd */
|
886 |
|
|
if (is_array($config['load_balancer']['virtual_server']) && count($config['load_balancer']['virtual_server'])) {
|
887 |
|
|
$vs_a = &$config['load_balancer']['virtual_server'];
|
888 |
|
|
$pool_a = &$config['load_balancer']['lbpool'];
|
889 |
|
|
$pools = array();
|
890 |
25753b5b
|
sullrich
|
/* Index pools by name */
|
891 |
791bcfd4
|
Bill Marquette
|
if(is_array($pool_a)) {
|
892 |
|
|
for ($i = 0; isset($pool_a[$i]); $i++) {
|
893 |
cb945ced
|
sullrich
|
if($pool_a[$i]['type'] == "server") {
|
894 |
791bcfd4
|
Bill Marquette
|
$pools[$pool_a[$i]['name']] = $pool_a[$i];
|
895 |
|
|
}
|
896 |
|
|
}
|
897 |
|
|
}
|
898 |
|
|
/* Convert sitedown entries to pools and re-attach */
|
899 |
|
|
for ($i = 0; isset($vs_a[$i]); $i++) {
|
900 |
d30afa60
|
jim-p
|
/* Set mode while we're here. */
|
901 |
|
|
$vs_a[$i]['mode'] = "redirect_mode";
|
902 |
791bcfd4
|
Bill Marquette
|
if (isset($vs_a[$i]['sitedown'])) {
|
903 |
|
|
$pool = array();
|
904 |
|
|
$pool['type'] = 'server';
|
905 |
|
|
$pool['behaviour'] = 'balance';
|
906 |
|
|
$pool['name'] = "{$vs_a[$i]['name']}-sitedown";
|
907 |
4816e5ca
|
Renato Botelho
|
$pool['descr'] = sprintf(gettext("Sitedown pool for VS: %s"), $vs_a[$i]['name']);
|
908 |
791bcfd4
|
Bill Marquette
|
$pool['port'] = $pools[$vs_a[$i]['pool']]['port'];
|
909 |
|
|
$pool['servers'] = array();
|
910 |
|
|
$pool['servers'][] = $vs_a[$i]['sitedown'];
|
911 |
|
|
$pool['monitor'] = $pools[$vs_a[$i]['pool']]['monitor'];
|
912 |
|
|
$pool_a[] = $pool;
|
913 |
|
|
$vs_a[$i]['sitedown'] = $pool['name'];
|
914 |
|
|
}
|
915 |
|
|
}
|
916 |
|
|
}
|
917 |
0b5b4f32
|
Seth Mos
|
if(count($config['load_balancer']) == 0) {
|
918 |
|
|
unset($config['load_balancer']);
|
919 |
|
|
}
|
920 |
a09d8bfc
|
jim-p
|
mwexec('/usr/sbin/pw groupadd -n _relayd -g 913');
|
921 |
|
|
mwexec('/usr/sbin/pw useradd -n _relayd -c "Relay Daemon" -d /var/empty -s /usr/sbin/nologin -u 913 -g 913');
|
922 |
791bcfd4
|
Bill Marquette
|
}
|
923 |
|
|
|
924 |
|
|
|
925 |
|
|
function upgrade_046_to_047() {
|
926 |
|
|
global $config;
|
927 |
|
|
/* Upgrade IPsec from tunnel to phase1/phase2 */
|
928 |
|
|
|
929 |
|
|
if(is_array($config['ipsec']['tunnel'])) {
|
930 |
|
|
|
931 |
|
|
$a_phase1 = array();
|
932 |
|
|
$a_phase2 = array();
|
933 |
|
|
$ikeid = 0;
|
934 |
|
|
|
935 |
|
|
foreach ($config['ipsec']['tunnel'] as $tunnel) {
|
936 |
|
|
|
937 |
|
|
unset($ph1ent);
|
938 |
|
|
unset($ph2ent);
|
939 |
|
|
|
940 |
|
|
/*
|
941 |
|
|
* attempt to locate an enabled phase1
|
942 |
|
|
* entry that matches the peer gateway
|
943 |
|
|
*/
|
944 |
|
|
|
945 |
|
|
if (!isset($tunnel['disabled'])) {
|
946 |
|
|
|
947 |
|
|
$remote_gateway = $tunnel['remote-gateway'];
|
948 |
|
|
|
949 |
|
|
foreach ($a_phase1 as $ph1tmp) {
|
950 |
|
|
if ($ph1tmp['remote-gateway'] == $remote_gateway) {
|
951 |
|
|
$ph1ent = $ph1tmp;
|
952 |
|
|
break;
|
953 |
|
|
}
|
954 |
|
|
}
|
955 |
|
|
}
|
956 |
|
|
|
957 |
|
|
/* none found, create a new one */
|
958 |
|
|
|
959 |
|
|
if (!isset( $ph1ent )) {
|
960 |
|
|
|
961 |
|
|
/* build new phase1 entry */
|
962 |
|
|
|
963 |
|
|
$ph1ent = array();
|
964 |
|
|
|
965 |
|
|
$ph1ent['ikeid'] = ++$ikeid;
|
966 |
|
|
|
967 |
|
|
if (isset($tunnel['disabled']))
|
968 |
|
|
$ph1ent['disabled'] = $tunnel['disabled'];
|
969 |
|
|
|
970 |
443f2e6e
|
smos
|
/* convert to the new vip[$vhid] name */
|
971 |
|
|
if(preg_match("/^carp/", $tunnel['interface'])) {
|
972 |
bc75a430
|
smos
|
$carpid = str_replace("carp", "", $tunnel['interface']);
|
973 |
4aa58d46
|
smos
|
$tunnel['interface'] = "vip" . $config['virtualip']['vip'][$carpid]['vhid'];
|
974 |
443f2e6e
|
smos
|
}
|
975 |
791bcfd4
|
Bill Marquette
|
$ph1ent['interface'] = $tunnel['interface'];
|
976 |
|
|
$ph1ent['remote-gateway'] = $tunnel['remote-gateway'];
|
977 |
|
|
$ph1ent['descr'] = $tunnel['descr'];
|
978 |
|
|
|
979 |
|
|
$ph1ent['mode'] = $tunnel['p1']['mode'];
|
980 |
|
|
|
981 |
|
|
if (isset($tunnel['p1']['myident']['myaddress']))
|
982 |
|
|
$ph1ent['myid_type'] = "myaddress";
|
983 |
|
|
if (isset($tunnel['p1']['myident']['address'])) {
|
984 |
|
|
$ph1ent['myid_type'] = "address";
|
985 |
|
|
$ph1ent['myid_data'] = $tunnel['p1']['myident']['address'];
|
986 |
|
|
}
|
987 |
|
|
if (isset($tunnel['p1']['myident']['fqdn'])) {
|
988 |
|
|
$ph1ent['myid_type'] = "fqdn";
|
989 |
|
|
$ph1ent['myid_data'] = $tunnel['p1']['myident']['fqdn'];
|
990 |
|
|
}
|
991 |
dfa11031
|
jim-p
|
if (isset($tunnel['p1']['myident']['ufqdn'])) {
|
992 |
791bcfd4
|
Bill Marquette
|
$ph1ent['myid_type'] = "user_fqdn";
|
993 |
dfa11031
|
jim-p
|
$ph1ent['myid_data'] = $tunnel['p1']['myident']['ufqdn'];
|
994 |
791bcfd4
|
Bill Marquette
|
}
|
995 |
|
|
if (isset($tunnel['p1']['myident']['asn1dn'])) {
|
996 |
|
|
$ph1ent['myid_type'] = "asn1dn";
|
997 |
|
|
$ph1ent['myid_data'] = $tunnel['p1']['myident']['asn1dn'];
|
998 |
|
|
}
|
999 |
|
|
if (isset($tunnel['p1']['myident']['dyn_dns'])) {
|
1000 |
|
|
$ph1ent['myid_type'] = "dyn_dns";
|
1001 |
|
|
$ph1ent['myid_data'] = $tunnel['p1']['myident']['dyn_dns'];
|
1002 |
|
|
}
|
1003 |
|
|
|
1004 |
|
|
$ph1ent['peerid_type'] = "peeraddress";
|
1005 |
|
|
|
1006 |
|
|
switch ($tunnel['p1']['encryption-algorithm']) {
|
1007 |
|
|
case "des":
|
1008 |
|
|
$ph1alg = array( 'name' => 'des' );
|
1009 |
|
|
break;
|
1010 |
|
|
case "3des":
|
1011 |
|
|
$ph1alg = array( 'name' => '3des' );
|
1012 |
|
|
break;
|
1013 |
|
|
case "blowfish":
|
1014 |
|
|
$ph1alg = array( 'name' => 'blowfish', 'keylen' => '128' );
|
1015 |
|
|
break;
|
1016 |
|
|
case "cast128":
|
1017 |
|
|
$ph1alg = array( 'name' => 'cast128' );
|
1018 |
|
|
break;
|
1019 |
|
|
case "rijndael":
|
1020 |
|
|
$ph1alg = array( 'name' => 'aes', 'keylen' => '128' );
|
1021 |
|
|
break;
|
1022 |
|
|
case "rijndael 256":
|
1023 |
a5187d43
|
jim-p
|
case "aes 256":
|
1024 |
791bcfd4
|
Bill Marquette
|
$ph1alg = array( 'name' => 'aes', 'keylen' => '256' );
|
1025 |
|
|
break;
|
1026 |
|
|
}
|
1027 |
|
|
|
1028 |
|
|
$ph1ent['encryption-algorithm'] = $ph1alg;
|
1029 |
|
|
$ph1ent['hash-algorithm'] = $tunnel['p1']['hash-algorithm'];
|
1030 |
|
|
$ph1ent['dhgroup'] = $tunnel['p1']['dhgroup'];
|
1031 |
|
|
$ph1ent['lifetime'] = $tunnel['p1']['lifetime'];
|
1032 |
|
|
$ph1ent['authentication_method'] = $tunnel['p1']['authentication_method'];
|
1033 |
|
|
|
1034 |
|
|
if (isset($tunnel['p1']['pre-shared-key']))
|
1035 |
|
|
$ph1ent['pre-shared-key'] = $tunnel['p1']['pre-shared-key'];
|
1036 |
|
|
if (isset($tunnel['p1']['cert']))
|
1037 |
|
|
$ph1ent['cert'] = $tunnel['p1']['cert'];
|
1038 |
|
|
if (isset($tunnel['p1']['peercert']))
|
1039 |
|
|
$ph1ent['peercert'] = $tunnel['p1']['peercert'];
|
1040 |
|
|
if (isset($tunnel['p1']['private-key']))
|
1041 |
|
|
$ph1ent['private-key'] = $tunnel['p1']['private-key'];
|
1042 |
|
|
|
1043 |
|
|
$ph1ent['nat_traversal'] = "on";
|
1044 |
|
|
$ph1ent['dpd_enable'] = 1;
|
1045 |
|
|
$ph1ent['dpd_delay'] = 10;
|
1046 |
|
|
$ph1ent['dpd_maxfail'] = 5;
|
1047 |
|
|
|
1048 |
|
|
$a_phase1[] = $ph1ent;
|
1049 |
|
|
}
|
1050 |
|
|
|
1051 |
|
|
/* build new phase2 entry */
|
1052 |
|
|
|
1053 |
|
|
$ph2ent = array();
|
1054 |
|
|
|
1055 |
|
|
$ph2ent['ikeid'] = $ph1ent['ikeid'];
|
1056 |
|
|
|
1057 |
|
|
if (isset($tunnel['disabled']))
|
1058 |
|
|
$ph1ent['disabled'] = $tunnel['disabled'];
|
1059 |
|
|
|
1060 |
4d511e5b
|
Renato Botelho
|
$ph2ent['descr'] = sprintf(gettext("phase2 for %s"), $tunnel['descr']);
|
1061 |
791bcfd4
|
Bill Marquette
|
|
1062 |
|
|
$type = "lan";
|
1063 |
|
|
if ($tunnel['local-subnet']['network'])
|
1064 |
|
|
$type = $tunnel['local-subnet']['network'];
|
1065 |
|
|
if ($tunnel['local-subnet']['address']) {
|
1066 |
|
|
list($address,$netbits) = explode("/",$tunnel['local-subnet']['address']);
|
1067 |
|
|
if (is_null($netbits))
|
1068 |
|
|
$type = "address";
|
1069 |
|
|
else
|
1070 |
|
|
$type = "network";
|
1071 |
|
|
}
|
1072 |
|
|
|
1073 |
|
|
switch ($type) {
|
1074 |
|
|
case "address":
|
1075 |
|
|
$ph2ent['localid'] = array('type' => $type,'address' => $address);
|
1076 |
|
|
break;
|
1077 |
|
|
case "network":
|
1078 |
|
|
$ph2ent['localid'] = array('type' => $type,'address' => $address,'netbits' => $netbits);
|
1079 |
|
|
break;
|
1080 |
|
|
default:
|
1081 |
|
|
$ph2ent['localid'] = array('type' => $type);
|
1082 |
|
|
break;
|
1083 |
|
|
}
|
1084 |
|
|
|
1085 |
|
|
list($address,$netbits) = explode("/",$tunnel['remote-subnet']);
|
1086 |
|
|
$ph2ent['remoteid'] = array('type' => 'network','address' => $address,'netbits' => $netbits);
|
1087 |
|
|
|
1088 |
|
|
$ph2ent['protocol'] = $tunnel['p2']['protocol'];
|
1089 |
|
|
|
1090 |
|
|
$aes_count = 0;
|
1091 |
|
|
foreach( $tunnel['p2']['encryption-algorithm-option'] as $tunalg ) {
|
1092 |
|
|
$aes_found = false;
|
1093 |
|
|
switch ($tunalg) {
|
1094 |
|
|
case "des":
|
1095 |
|
|
$ph2alg = array( 'name' => 'des' );
|
1096 |
|
|
break;
|
1097 |
|
|
case "3des":
|
1098 |
|
|
$ph2alg = array( 'name' => '3des' );
|
1099 |
|
|
break;
|
1100 |
|
|
case "blowfish":
|
1101 |
|
|
$ph2alg = array( 'name' => 'blowfish', 'keylen' => 'auto' );
|
1102 |
|
|
break;
|
1103 |
|
|
case "cast128":
|
1104 |
|
|
$ph2alg = array( 'name' => 'cast128' );
|
1105 |
|
|
break;
|
1106 |
|
|
case "rijndael":
|
1107 |
|
|
case "rijndael 256":
|
1108 |
a5187d43
|
jim-p
|
case "aes 256":
|
1109 |
791bcfd4
|
Bill Marquette
|
$ph2alg = array( 'name' => 'aes', 'keylen' => 'auto' );
|
1110 |
|
|
$aes_found = true;
|
1111 |
|
|
$aes_count++;
|
1112 |
|
|
break;
|
1113 |
|
|
}
|
1114 |
|
|
|
1115 |
|
|
if( !$aes_found || ($aes_count < 2))
|
1116 |
|
|
$ph2ent['encryption-algorithm-option'][] = $ph2alg;
|
1117 |
|
|
}
|
1118 |
|
|
|
1119 |
|
|
$ph2ent['hash-algorithm-option'] = $tunnel['p2']['hash-algorithm-option'];
|
1120 |
|
|
$ph2ent['pfsgroup'] = $tunnel['p2']['pfsgroup'];
|
1121 |
|
|
$ph2ent['lifetime'] = $tunnel['p2']['lifetime'];
|
1122 |
|
|
|
1123 |
87e07f52
|
mgrooms
|
if (isset($tunnel['pinghost']['pinghost']))
|
1124 |
|
|
$ph2ent['pinghost'] = $tunnel['pinghost'];
|
1125 |
|
|
|
1126 |
791bcfd4
|
Bill Marquette
|
$a_phase2[] = $ph2ent;
|
1127 |
|
|
}
|
1128 |
|
|
|
1129 |
|
|
unset($config['ipsec']['tunnel']);
|
1130 |
|
|
$config['ipsec']['phase1'] = $a_phase1;
|
1131 |
|
|
$config['ipsec']['phase2'] = $a_phase2;
|
1132 |
|
|
}
|
1133 |
49bb5c07
|
jim-p
|
|
1134 |
|
|
/* Upgrade Mobile IPsec */
|
1135 |
|
|
if (isset($config['ipsec']['mobileclients'])
|
1136 |
|
|
&& is_array($config['ipsec']['mobileclients'])
|
1137 |
|
|
&& is_array($config['ipsec']['mobileclients']['p1'])
|
1138 |
|
|
&& is_array($config['ipsec']['mobileclients']['p2'])) {
|
1139 |
|
|
|
1140 |
|
|
if (isset($config['ipsec']['mobileclients']['enable'])) {
|
1141 |
|
|
$config['ipsec']['client']['enable'] = true;
|
1142 |
|
|
$config['ipsec']['client']['user_source'] = 'system';
|
1143 |
|
|
$config['ipsec']['client']['group_source'] = 'system';
|
1144 |
|
|
}
|
1145 |
|
|
|
1146 |
|
|
$mobilecfg = $config['ipsec']['mobileclients'];
|
1147 |
|
|
|
1148 |
|
|
$ph1ent = array();
|
1149 |
|
|
$ph1ent['ikeid'] = ++$ikeid;
|
1150 |
|
|
|
1151 |
|
|
if (!isset($mobilecfg['enable']))
|
1152 |
|
|
$ph1ent['disabled'] = true;
|
1153 |
|
|
|
1154 |
|
|
/* Assume WAN since mobile tunnels couldn't be on a separate interface on 1.2.x */
|
1155 |
|
|
$ph1ent['interface'] = 'wan';
|
1156 |
|
|
$ph1ent['descr'] = "Mobile Clients (upgraded)";
|
1157 |
|
|
$ph1ent['mode'] = $mobilecfg['p1']['mode'];
|
1158 |
|
|
|
1159 |
|
|
if (isset($mobilecfg['p1']['myident']['myaddress']))
|
1160 |
|
|
$ph1ent['myid_type'] = "myaddress";
|
1161 |
|
|
if (isset($mobilecfg['p1']['myident']['address'])) {
|
1162 |
|
|
$ph1ent['myid_type'] = "address";
|
1163 |
|
|
$ph1ent['myid_data'] = $mobilecfg['p1']['myident']['address'];
|
1164 |
|
|
}
|
1165 |
|
|
if (isset($mobilecfg['p1']['myident']['fqdn'])) {
|
1166 |
|
|
$ph1ent['myid_type'] = "fqdn";
|
1167 |
|
|
$ph1ent['myid_data'] = $mobilecfg['p1']['myident']['fqdn'];
|
1168 |
|
|
}
|
1169 |
|
|
if (isset($mobilecfg['p1']['myident']['ufqdn'])) {
|
1170 |
|
|
$ph1ent['myid_type'] = "user_fqdn";
|
1171 |
|
|
$ph1ent['myid_data'] = $mobilecfg['p1']['myident']['ufqdn'];
|
1172 |
|
|
}
|
1173 |
|
|
if (isset($mobilecfg['p1']['myident']['asn1dn'])) {
|
1174 |
|
|
$ph1ent['myid_type'] = "asn1dn";
|
1175 |
|
|
$ph1ent['myid_data'] = $mobilecfg['p1']['myident']['asn1dn'];
|
1176 |
|
|
}
|
1177 |
|
|
if (isset($mobilecfg['p1']['myident']['dyn_dns'])) {
|
1178 |
|
|
$ph1ent['myid_type'] = "dyn_dns";
|
1179 |
|
|
$ph1ent['myid_data'] = $mobilecfg['p1']['myident']['dyn_dns'];
|
1180 |
|
|
}
|
1181 |
|
|
$ph1ent['peerid_type'] = "fqdn";
|
1182 |
|
|
$ph1ent['peerid_data'] = "";
|
1183 |
|
|
|
1184 |
|
|
switch ($mobilecfg['p1']['encryption-algorithm']) {
|
1185 |
|
|
case "des":
|
1186 |
|
|
$ph1alg = array( 'name' => 'des' );
|
1187 |
|
|
break;
|
1188 |
|
|
case "3des":
|
1189 |
|
|
$ph1alg = array( 'name' => '3des' );
|
1190 |
|
|
break;
|
1191 |
|
|
case "blowfish":
|
1192 |
|
|
$ph1alg = array( 'name' => 'blowfish', 'keylen' => '128' );
|
1193 |
|
|
break;
|
1194 |
|
|
case "cast128":
|
1195 |
|
|
$ph1alg = array( 'name' => 'cast128' );
|
1196 |
|
|
break;
|
1197 |
|
|
case "rijndael":
|
1198 |
|
|
$ph1alg = array( 'name' => 'aes', 'keylen' => '128' );
|
1199 |
|
|
break;
|
1200 |
|
|
case "rijndael 256":
|
1201 |
a5187d43
|
jim-p
|
case "aes 256":
|
1202 |
49bb5c07
|
jim-p
|
$ph1alg = array( 'name' => 'aes', 'keylen' => '256' );
|
1203 |
|
|
break;
|
1204 |
|
|
}
|
1205 |
|
|
|
1206 |
|
|
$ph1ent['encryption-algorithm'] = $ph1alg;
|
1207 |
|
|
$ph1ent['hash-algorithm'] = $mobilecfg['p1']['hash-algorithm'];
|
1208 |
|
|
$ph1ent['dhgroup'] = $mobilecfg['p1']['dhgroup'];
|
1209 |
|
|
$ph1ent['lifetime'] = $mobilecfg['p1']['lifetime'];
|
1210 |
|
|
$ph1ent['authentication_method'] = $mobilecfg['p1']['authentication_method'];
|
1211 |
|
|
|
1212 |
|
|
if (isset($mobilecfg['p1']['cert']))
|
1213 |
|
|
$ph1ent['cert'] = $mobilecfg['p1']['cert'];
|
1214 |
|
|
if (isset($mobilecfg['p1']['peercert']))
|
1215 |
|
|
$ph1ent['peercert'] = $mobilecfg['p1']['peercert'];
|
1216 |
|
|
if (isset($mobilecfg['p1']['private-key']))
|
1217 |
|
|
$ph1ent['private-key'] = $mobilecfg['p1']['private-key'];
|
1218 |
|
|
|
1219 |
|
|
$ph1ent['nat_traversal'] = "on";
|
1220 |
|
|
$ph1ent['dpd_enable'] = 1;
|
1221 |
|
|
$ph1ent['dpd_delay'] = 10;
|
1222 |
|
|
$ph1ent['dpd_maxfail'] = 5;
|
1223 |
|
|
$ph1ent['mobile'] = true;
|
1224 |
|
|
|
1225 |
|
|
$ph2ent = array();
|
1226 |
|
|
$ph2ent['ikeid'] = $ph1ent['ikeid'];
|
1227 |
|
|
$ph2ent['descr'] = "phase2 for ".$mobilecfg['descr'];
|
1228 |
|
|
$ph2ent['localid'] = array('type' => 'none');
|
1229 |
|
|
$ph2ent['remoteid'] = array('type' => 'mobile');
|
1230 |
|
|
$ph2ent['protocol'] = $mobilecfg['p2']['protocol'];
|
1231 |
|
|
|
1232 |
|
|
$aes_count = 0;
|
1233 |
|
|
foreach( $mobilecfg['p2']['encryption-algorithm-option'] as $tunalg ) {
|
1234 |
|
|
$aes_found = false;
|
1235 |
|
|
switch ($tunalg) {
|
1236 |
|
|
case "des":
|
1237 |
|
|
$ph2alg = array( 'name' => 'des' );
|
1238 |
|
|
break;
|
1239 |
|
|
case "3des":
|
1240 |
|
|
$ph2alg = array( 'name' => '3des' );
|
1241 |
|
|
break;
|
1242 |
|
|
case "blowfish":
|
1243 |
|
|
$ph2alg = array( 'name' => 'blowfish', 'keylen' => 'auto' );
|
1244 |
|
|
break;
|
1245 |
|
|
case "cast128":
|
1246 |
|
|
$ph2alg = array( 'name' => 'cast128' );
|
1247 |
|
|
break;
|
1248 |
|
|
case "rijndael":
|
1249 |
|
|
case "rijndael 256":
|
1250 |
a5187d43
|
jim-p
|
case "aes 256":
|
1251 |
49bb5c07
|
jim-p
|
$ph2alg = array( 'name' => 'aes', 'keylen' => 'auto' );
|
1252 |
|
|
$aes_found = true;
|
1253 |
|
|
$aes_count++;
|
1254 |
|
|
break;
|
1255 |
|
|
}
|
1256 |
|
|
|
1257 |
|
|
if( !$aes_found || ($aes_count < 2))
|
1258 |
|
|
$ph2ent['encryption-algorithm-option'][] = $ph2alg;
|
1259 |
|
|
}
|
1260 |
|
|
$ph2ent['hash-algorithm-option'] = $mobilecfg['p2']['hash-algorithm-option'];
|
1261 |
|
|
$ph2ent['pfsgroup'] = $mobilecfg['p2']['pfsgroup'];
|
1262 |
|
|
$ph2ent['lifetime'] = $mobilecfg['p2']['lifetime'];
|
1263 |
|
|
$ph2ent['mobile'] = true;
|
1264 |
|
|
|
1265 |
|
|
$config['ipsec']['phase1'][] = $ph1ent;
|
1266 |
|
|
$config['ipsec']['phase2'][] = $ph2ent;
|
1267 |
|
|
unset($config['ipsec']['mobileclients']);
|
1268 |
|
|
}
|
1269 |
791bcfd4
|
Bill Marquette
|
}
|
1270 |
|
|
|
1271 |
|
|
|
1272 |
|
|
function upgrade_047_to_048() {
|
1273 |
|
|
global $config;
|
1274 |
e31c90fc
|
Ermal
|
if (!empty($config['dyndns'])) {
|
1275 |
|
|
$config['dyndnses'] = array();
|
1276 |
|
|
$config['dyndnses']['dyndns'] = array();
|
1277 |
c9e13418
|
Ermal
|
if(isset($config['dyndns'][0]['host'])) {
|
1278 |
246aceaa
|
smos
|
$tempdyn = array();
|
1279 |
|
|
$tempdyn['enable'] = isset($config['dyndns'][0]['enable']);
|
1280 |
|
|
$tempdyn['type'] = $config['dyndns'][0]['type'];
|
1281 |
|
|
$tempdyn['wildcard'] = isset($config['dyndns'][0]['wildcard']);
|
1282 |
7d62c4c8
|
Ermal
|
$tempdyn['username'] = $config['dyndns'][0]['username'];
|
1283 |
|
|
$tempdyn['password'] = $config['dyndns'][0]['password'];
|
1284 |
246aceaa
|
smos
|
$tempdyn['host'] = $config['dyndns'][0]['host'];
|
1285 |
|
|
$tempdyn['mx'] = $config['dyndns'][0]['mx'];
|
1286 |
|
|
$tempdyn['interface'] = "wan";
|
1287 |
4d511e5b
|
Renato Botelho
|
$tempdyn['descr'] = sprintf(gettext("Upgraded Dyndns %s"), $tempdyn['type']);
|
1288 |
246aceaa
|
smos
|
$config['dyndnses']['dyndns'][] = $tempdyn;
|
1289 |
|
|
}
|
1290 |
791bcfd4
|
Bill Marquette
|
unset($config['dyndns']);
|
1291 |
|
|
}
|
1292 |
e31c90fc
|
Ermal
|
if (!empty($config['dnsupdate'])) {
|
1293 |
2b1b78e6
|
jim-p
|
$pconfig = $config['dnsupdate'][0];
|
1294 |
|
|
if (!$pconfig['ttl'])
|
1295 |
|
|
$pconfig['ttl'] = 60;
|
1296 |
|
|
if (!$pconfig['keytype'])
|
1297 |
|
|
$pconfig['keytype'] = "zone";
|
1298 |
e31c90fc
|
Ermal
|
$pconfig['interface'] = "wan";
|
1299 |
791bcfd4
|
Bill Marquette
|
$config['dnsupdates']['dnsupdate'][] = $pconfig;
|
1300 |
|
|
unset($config['dnsupdate']);
|
1301 |
|
|
}
|
1302 |
|
|
|
1303 |
1f0c76cf
|
jim-p
|
if (is_array($config['pppoe']) && is_array($config['pppoe'][0])) {
|
1304 |
791bcfd4
|
Bill Marquette
|
$pconfig = array();
|
1305 |
1f0c76cf
|
jim-p
|
$pconfig['username'] = $config['pppoe'][0]['username'];
|
1306 |
|
|
$pconfig['password'] = $config['pppoe'][0]['password'];
|
1307 |
|
|
$pconfig['provider'] = $config['pppoe'][0]['provider'];
|
1308 |
|
|
$pconfig['ondemand'] = isset($config['pppoe'][0]['ondemand']);
|
1309 |
|
|
$pconfig['timeout'] = $config['pppoe'][0]['timeout'];
|
1310 |
791bcfd4
|
Bill Marquette
|
unset($config['pppoe']);
|
1311 |
|
|
$config['interfaces']['wan']['pppoe_username'] = $pconfig['username'];
|
1312 |
|
|
$config['interfaces']['wan']['pppoe_password'] = $pconfig['password'];
|
1313 |
|
|
$config['interfaces']['wan']['provider'] = $pconfig['provider'];
|
1314 |
|
|
$config['interfaces']['wan']['ondemand'] = isset($pconfig['ondemand']);
|
1315 |
|
|
$config['interfaces']['wan']['timeout'] = $pconfig['timeout'];
|
1316 |
|
|
}
|
1317 |
|
|
if (is_array($config['pptp'])) {
|
1318 |
|
|
$pconfig = array();
|
1319 |
|
|
$pconfig['username'] = $config['pptp']['username'];
|
1320 |
|
|
$pconfig['password'] = $config['pptp']['password'];
|
1321 |
|
|
$pconfig['provider'] = $config['pptp']['provider'];
|
1322 |
|
|
$pconfig['ondemand'] = isset($config['pptp']['ondemand']);
|
1323 |
|
|
$pconfig['timeout'] = $config['pptp']['timeout'];
|
1324 |
|
|
unset($config['pptp']);
|
1325 |
|
|
$config['interfaces']['wan']['pptp_username'] = $pconfig['username'];
|
1326 |
|
|
$config['interfaces']['wan']['pptp_password'] = $pconfig['password'];
|
1327 |
|
|
$config['interfaces']['wan']['provider'] = $pconfig['provider'];
|
1328 |
|
|
$config['interfaces']['wan']['ondemand'] = isset($pconfig['ondemand'] );
|
1329 |
|
|
$config['interfaces']['wan']['timeout'] = $pconfig['timeout'];
|
1330 |
|
|
}
|
1331 |
|
|
}
|
1332 |
|
|
|
1333 |
|
|
|
1334 |
|
|
function upgrade_048_to_049() {
|
1335 |
|
|
global $config;
|
1336 |
|
|
/* setup new all users group */
|
1337 |
|
|
$all = array();
|
1338 |
|
|
$all['name'] = "all";
|
1339 |
4d511e5b
|
Renato Botelho
|
$all['description'] = gettext("All Users");
|
1340 |
791bcfd4
|
Bill Marquette
|
$all['scope'] = "system";
|
1341 |
|
|
$all['gid'] = 1998;
|
1342 |
|
|
$all['member'] = array();
|
1343 |
|
|
|
1344 |
84924e76
|
Ermal
|
if (!is_array($config['system']['user']))
|
1345 |
|
|
$config['system']['user'] = array();
|
1346 |
791bcfd4
|
Bill Marquette
|
if (!is_array($config['system']['group']))
|
1347 |
|
|
$config['system']['group'] = array();
|
1348 |
|
|
|
1349 |
|
|
/* work around broken uid assignments */
|
1350 |
|
|
$config['system']['nextuid'] = 2000;
|
1351 |
|
|
foreach ($config['system']['user'] as & $user) {
|
1352 |
|
|
if (isset($user['uid']) && !$user['uid'])
|
1353 |
|
|
continue;
|
1354 |
|
|
$user['uid'] = $config['system']['nextuid']++;
|
1355 |
|
|
}
|
1356 |
|
|
|
1357 |
|
|
/* work around broken gid assignments */
|
1358 |
|
|
$config['system']['nextgid'] = 2000;
|
1359 |
|
|
foreach ($config['system']['group'] as & $group) {
|
1360 |
|
|
if ($group['name'] == $g['admin_group'])
|
1361 |
|
|
$group['gid'] = 1999;
|
1362 |
|
|
else
|
1363 |
|
|
$group['gid'] = $config['system']['nextgid']++;
|
1364 |
|
|
}
|
1365 |
|
|
|
1366 |
|
|
/* build group membership information */
|
1367 |
|
|
foreach ($config['system']['group'] as & $group) {
|
1368 |
|
|
$group['member'] = array();
|
1369 |
|
|
foreach ($config['system']['user'] as & $user) {
|
1370 |
|
|
$groupnames = explode(",", $user['groupname']);
|
1371 |
|
|
if (in_array($group['name'],$groupnames))
|
1372 |
|
|
$group['member'][] = $user['uid'];
|
1373 |
|
|
}
|
1374 |
|
|
}
|
1375 |
|
|
|
1376 |
|
|
/* reset user group information */
|
1377 |
|
|
foreach ($config['system']['user'] as & $user) {
|
1378 |
|
|
unset($user['groupname']);
|
1379 |
|
|
$all['member'][] = $user['uid'];
|
1380 |
|
|
}
|
1381 |
|
|
|
1382 |
|
|
/* reset group scope information */
|
1383 |
|
|
foreach ($config['system']['group'] as & $group)
|
1384 |
|
|
if ($group['name'] != $g['admin_group'])
|
1385 |
|
|
$group['scope'] = "user";
|
1386 |
|
|
|
1387 |
|
|
/* insert new all group */
|
1388 |
|
|
$groups = Array();
|
1389 |
|
|
$groups[] = $all;
|
1390 |
|
|
$groups = array_merge($config['system']['group'],$groups);
|
1391 |
|
|
$config['system']['group'] = $groups;
|
1392 |
|
|
}
|
1393 |
|
|
|
1394 |
|
|
|
1395 |
|
|
function upgrade_049_to_050() {
|
1396 |
|
|
global $config;
|
1397 |
84924e76
|
Ermal
|
|
1398 |
|
|
if (!is_array($config['system']['user']))
|
1399 |
|
|
$config['system']['user'] = array();
|
1400 |
791bcfd4
|
Bill Marquette
|
/* update user privileges */
|
1401 |
|
|
foreach ($config['system']['user'] as & $user) {
|
1402 |
|
|
$privs = array();
|
1403 |
|
|
if (!is_array($user['priv'])) {
|
1404 |
|
|
unset($user['priv']);
|
1405 |
|
|
continue;
|
1406 |
|
|
}
|
1407 |
|
|
foreach ($user['priv'] as $priv) {
|
1408 |
|
|
switch($priv['id']) {
|
1409 |
|
|
case "hasshell":
|
1410 |
|
|
$privs[] = "user-shell-access";
|
1411 |
|
|
break;
|
1412 |
|
|
case "copyfiles":
|
1413 |
|
|
$privs[] = "user-copy-files";
|
1414 |
|
|
break;
|
1415 |
|
|
}
|
1416 |
|
|
}
|
1417 |
|
|
$user['priv'] = $privs;
|
1418 |
|
|
}
|
1419 |
|
|
|
1420 |
|
|
/* update group privileges */
|
1421 |
|
|
foreach ($config['system']['group'] as & $group) {
|
1422 |
|
|
$privs = array();
|
1423 |
|
|
if (!is_array($group['pages'])) {
|
1424 |
|
|
unset($group['pages']);
|
1425 |
|
|
continue;
|
1426 |
|
|
}
|
1427 |
|
|
foreach ($group['pages'] as $page) {
|
1428 |
|
|
$priv = map_page_privname($page);
|
1429 |
|
|
if ($priv)
|
1430 |
|
|
$privs[] = $priv;
|
1431 |
|
|
}
|
1432 |
|
|
unset($group['pages']);
|
1433 |
|
|
$group['priv'] = $privs;
|
1434 |
|
|
}
|
1435 |
|
|
|
1436 |
|
|
/* sync all local account information */
|
1437 |
|
|
local_sync_accounts();
|
1438 |
|
|
}
|
1439 |
|
|
|
1440 |
|
|
|
1441 |
|
|
function upgrade_050_to_051() {
|
1442 |
|
|
global $config;
|
1443 |
|
|
$pconfig = array();
|
1444 |
15864861
|
jim-p
|
$pconfig['descr'] = "Set to 0 to disable filtering on the incoming and outgoing member interfaces.";
|
1445 |
791bcfd4
|
Bill Marquette
|
$pconfig['tunable'] = "net.link.bridge.pfil_member";
|
1446 |
|
|
$pconfig['value'] = "1";
|
1447 |
|
|
$config['sysctl']['item'][] = $pconfig;
|
1448 |
|
|
$pconfig = array();
|
1449 |
15864861
|
jim-p
|
$pconfig['descr'] = "Set to 1 to enable filtering on the bridge interface";
|
1450 |
791bcfd4
|
Bill Marquette
|
$pconfig['tunable'] = "net.link.bridge.pfil_bridge";
|
1451 |
|
|
$pconfig['value'] = "0";
|
1452 |
|
|
$config['sysctl']['item'][] = $pconfig;
|
1453 |
|
|
|
1454 |
|
|
unset($config['bridge']);
|
1455 |
|
|
|
1456 |
|
|
$convert_bridges = false;
|
1457 |
|
|
foreach($config['interfaces'] as $intf) {
|
1458 |
|
|
if (isset($intf['bridge']) && $intf['bridge'] <> "") {
|
1459 |
|
|
$config['bridges'] = array();
|
1460 |
|
|
$config['bridges']['bridged'] = array();
|
1461 |
|
|
$convert_bridges = true;
|
1462 |
|
|
break;
|
1463 |
|
|
}
|
1464 |
|
|
}
|
1465 |
|
|
if ($convert_bridges == true) {
|
1466 |
|
|
$i = 0;
|
1467 |
|
|
foreach ($config['interfaces'] as $ifr => &$intf) {
|
1468 |
|
|
if (isset($intf['bridge']) && $intf['bridge'] <> "") {
|
1469 |
|
|
$nbridge = array();
|
1470 |
|
|
$nbridge['members'] = "{$ifr},{$intf['bridge']}";
|
1471 |
4d511e5b
|
Renato Botelho
|
$nbridge['descr'] = sprintf(gettext("Converted bridged %s"), $ifr);
|
1472 |
791bcfd4
|
Bill Marquette
|
$nbridge['bridgeif'] = "bridge{$i}";
|
1473 |
|
|
$config['bridges']['bridged'][] = $nbridge;
|
1474 |
|
|
unset($intf['bridge']);
|
1475 |
|
|
$i++;
|
1476 |
|
|
}
|
1477 |
|
|
}
|
1478 |
|
|
}
|
1479 |
|
|
}
|
1480 |
|
|
|
1481 |
|
|
|
1482 |
|
|
function upgrade_051_to_052() {
|
1483 |
|
|
global $config;
|
1484 |
|
|
$config['openvpn'] = array();
|
1485 |
9ad72e5e
|
jim-p
|
if (!is_array($config['ca']))
|
1486 |
|
|
$config['ca'] = array();
|
1487 |
|
|
if (!is_array($config['cert']))
|
1488 |
|
|
$config['cert'] = array();
|
1489 |
791bcfd4
|
Bill Marquette
|
|
1490 |
|
|
$vpnid = 1;
|
1491 |
|
|
|
1492 |
|
|
/* openvpn server configurations */
|
1493 |
|
|
if (is_array($config['installedpackages']['openvpnserver'])) {
|
1494 |
|
|
$config['openvpn']['openvpn-server'] = array();
|
1495 |
|
|
|
1496 |
|
|
$index = 1;
|
1497 |
|
|
foreach($config['installedpackages']['openvpnserver']['config'] as $server) {
|
1498 |
|
|
|
1499 |
|
|
if (!is_array($server))
|
1500 |
|
|
continue;
|
1501 |
|
|
|
1502 |
|
|
if ($server['auth_method'] == "pki") {
|
1503 |
|
|
|
1504 |
|
|
/* create ca entry */
|
1505 |
|
|
$ca = array();
|
1506 |
|
|
$ca['refid'] = uniqid();
|
1507 |
f2a86ca9
|
jim-p
|
$ca['descr'] = "OpenVPN Server CA #{$index}";
|
1508 |
791bcfd4
|
Bill Marquette
|
$ca['crt'] = $server['ca_cert'];
|
1509 |
9ad72e5e
|
jim-p
|
$config['ca'][] = $ca;
|
1510 |
791bcfd4
|
Bill Marquette
|
|
1511 |
|
|
/* create ca reference */
|
1512 |
|
|
unset($server['ca_cert']);
|
1513 |
|
|
$server['caref'] = $ca['refid'];
|
1514 |
|
|
|
1515 |
47319bfb
|
jim-p
|
/* create a crl entry if needed */
|
1516 |
ab75b4ee
|
jim-p
|
if (!empty($server['crl'][0])) {
|
1517 |
47319bfb
|
jim-p
|
$crl = array();
|
1518 |
|
|
$crl['refid'] = uniqid();
|
1519 |
|
|
$crl['descr'] = "Imported OpenVPN CRL #{$index}";
|
1520 |
|
|
$crl['caref'] = $ca['refid'];
|
1521 |
ab75b4ee
|
jim-p
|
$crl['text'] = $server['crl'][0];
|
1522 |
90e64fad
|
Warren Baker
|
if(!is_array($config['crl']))
|
1523 |
|
|
$config['crl'] = array();
|
1524 |
fc3e88f1
|
jim-p
|
$config['crl'][] = $crl;
|
1525 |
47319bfb
|
jim-p
|
$server['crlref'] = $crl['refid'];
|
1526 |
|
|
}
|
1527 |
|
|
unset($server['crl']);
|
1528 |
|
|
|
1529 |
791bcfd4
|
Bill Marquette
|
/* create cert entry */
|
1530 |
|
|
$cert = array();
|
1531 |
|
|
$cert['refid'] = uniqid();
|
1532 |
f2a86ca9
|
jim-p
|
$cert['descr'] = "OpenVPN Server Certificate #{$index}";
|
1533 |
791bcfd4
|
Bill Marquette
|
$cert['crt'] = $server['server_cert'];
|
1534 |
|
|
$cert['prv'] = $server['server_key'];
|
1535 |
9ad72e5e
|
jim-p
|
$config['cert'][] = $cert;
|
1536 |
791bcfd4
|
Bill Marquette
|
|
1537 |
|
|
/* create cert reference */
|
1538 |
|
|
unset($server['server_cert']);
|
1539 |
|
|
unset($server['server_key']);
|
1540 |
|
|
$server['certref'] = $cert['refid'];
|
1541 |
|
|
|
1542 |
|
|
$index++;
|
1543 |
|
|
}
|
1544 |
|
|
|
1545 |
|
|
/* determine operational mode */
|
1546 |
|
|
if ($server['auth_method'] == 'pki') {
|
1547 |
|
|
if($server['nopool']) {
|
1548 |
|
|
$server['mode'] = "p2p_tls";
|
1549 |
|
|
} else {
|
1550 |
|
|
$server['mode'] = "server_tls";
|
1551 |
|
|
}
|
1552 |
|
|
} else {
|
1553 |
|
|
$server['mode'] = "p2p_shared_key";
|
1554 |
|
|
}
|
1555 |
|
|
unset($server['auth_method']);
|
1556 |
|
|
|
1557 |
|
|
/* modify configuration values */
|
1558 |
|
|
$server['dh_length'] = 1024;
|
1559 |
|
|
unset($server['dh_params']);
|
1560 |
|
|
if (!$server['interface'])
|
1561 |
a15a7738
|
jim-p
|
$server['interface'] = 'any';
|
1562 |
791bcfd4
|
Bill Marquette
|
$server['tunnel_network'] = $server['addresspool'];
|
1563 |
|
|
unset($server['addresspool']);
|
1564 |
a843870d
|
jim-p
|
if (isset($server['use_lzo']) && ($server['use_lzo'] == "on")) {
|
1565 |
8b666514
|
jim-p
|
$server['compression'] = "on";
|
1566 |
da831323
|
Ermal Lu?i
|
unset($server['use_lzo']);
|
1567 |
|
|
}
|
1568 |
791bcfd4
|
Bill Marquette
|
if ($server['nopool'])
|
1569 |
|
|
$server['pool_enable'] = false;
|
1570 |
|
|
else
|
1571 |
|
|
$server['pool_enable'] = "yes";
|
1572 |
|
|
unset($server['nopool']);
|
1573 |
|
|
$server['dns_domain'] = $server['dhcp_domainname'];
|
1574 |
|
|
unset($server['dhcp_domainname']);
|
1575 |
c3ae41e6
|
jim-p
|
|
1576 |
|
|
$tmparr = explode(";", $server['dhcp_dns'], 4);
|
1577 |
|
|
$d=1;
|
1578 |
|
|
foreach ($tmparr as $tmpa) {
|
1579 |
|
|
$server["dns_server{$d}"] = $tmpa;
|
1580 |
|
|
$d++;
|
1581 |
|
|
}
|
1582 |
791bcfd4
|
Bill Marquette
|
unset($server['dhcp_dns']);
|
1583 |
c3ae41e6
|
jim-p
|
|
1584 |
|
|
$tmparr = explode(";", $server['dhcp_ntp'], 2);
|
1585 |
|
|
$d=1;
|
1586 |
|
|
foreach ($tmparr as $tmpa) {
|
1587 |
|
|
$server["ntp_server{$d}"] = $tmpa;
|
1588 |
|
|
$d++;
|
1589 |
|
|
}
|
1590 |
791bcfd4
|
Bill Marquette
|
unset($server['dhcp_ntp']);
|
1591 |
c3ae41e6
|
jim-p
|
|
1592 |
791bcfd4
|
Bill Marquette
|
if ($server['dhcp_nbtdisable'])
|
1593 |
|
|
$server['netbios_enable'] = false;
|
1594 |
|
|
else
|
1595 |
|
|
$server['netbios_enable'] = "yes";
|
1596 |
|
|
unset($server['dhcp_nbtdisable']);
|
1597 |
|
|
$server['netbios_ntype'] = $server['dhcp_nbttype'];
|
1598 |
|
|
unset($server['dhcp_nbttype']);
|
1599 |
|
|
$server['netbios_scope'] = $server['dhcp_nbtscope'];
|
1600 |
|
|
unset($server['dhcp_nbtscope']);
|
1601 |
c3ae41e6
|
jim-p
|
|
1602 |
|
|
$tmparr = explode(";", $server['dhcp_nbdd'], 2);
|
1603 |
|
|
$d=1;
|
1604 |
|
|
foreach ($tmparr as $tmpa) {
|
1605 |
|
|
$server["nbdd_server{$d}"] = $tmpa;
|
1606 |
|
|
$d++;
|
1607 |
|
|
}
|
1608 |
791bcfd4
|
Bill Marquette
|
unset($server['dhcp_nbdd']);
|
1609 |
c3ae41e6
|
jim-p
|
|
1610 |
|
|
$tmparr = explode(";", $server['dhcp_wins'], 2);
|
1611 |
|
|
$d=1;
|
1612 |
|
|
foreach ($tmparr as $tmpa) {
|
1613 |
|
|
$server["wins_server{$d}"] = $tmpa;
|
1614 |
|
|
$d++;
|
1615 |
|
|
}
|
1616 |
791bcfd4
|
Bill Marquette
|
unset($server['dhcp_wins']);
|
1617 |
|
|
|
1618 |
763a1b52
|
jim-p
|
if (!empty($server['disable']))
|
1619 |
|
|
$server['disable'] = true;
|
1620 |
|
|
else
|
1621 |
|
|
unset($server['disable']);
|
1622 |
|
|
|
1623 |
791bcfd4
|
Bill Marquette
|
/* allocate vpnid */
|
1624 |
|
|
$server['vpnid'] = $vpnid++;
|
1625 |
|
|
|
1626 |
4f1ebacb
|
Ermal
|
if (!empty($server['custom_options'])) {
|
1627 |
|
|
$cstmopts = array();
|
1628 |
|
|
$tmpcstmopts = explode(";", $server['custom_options']);
|
1629 |
48e24ada
|
jim-p
|
$assigned_if = "";
|
1630 |
4f1ebacb
|
Ermal
|
$tmpstr = "";
|
1631 |
|
|
foreach ($tmpcstmopts as $tmpcstmopt) {
|
1632 |
|
|
$tmpstr = str_replace(" ", "", $tmpcstmopt);
|
1633 |
|
|
if (substr($tmpstr,0 ,6) == "devtun") {
|
1634 |
48e24ada
|
jim-p
|
$assigned_if = substr($tmpstr, 3);
|
1635 |
4f1ebacb
|
Ermal
|
continue;
|
1636 |
8fd0badd
|
Ermal
|
} else if (substr($tmpstr, 0, 5) == "local") {
|
1637 |
9bc27ae5
|
jim-p
|
$localip = substr($tmpstr, 5);
|
1638 |
8fd0badd
|
Ermal
|
$server['ipaddr'] = str_replace("\n", "", $localip);
|
1639 |
4f1ebacb
|
Ermal
|
} else
|
1640 |
|
|
$cstmopts[] = $tmpcstmopt;
|
1641 |
|
|
}
|
1642 |
|
|
$server['custom_options'] = implode(";", $cstmopts);
|
1643 |
48e24ada
|
jim-p
|
if (!empty($assigned_if)) {
|
1644 |
4f1ebacb
|
Ermal
|
foreach ($config['interfaces'] as $iface => $cfgif) {
|
1645 |
48e24ada
|
jim-p
|
if ($cfgif['if'] == $assigned_if) {
|
1646 |
4f1ebacb
|
Ermal
|
$config['interfaces'][$iface]['if'] = "ovpns{$server['vpnid']}";
|
1647 |
|
|
break;
|
1648 |
|
|
}
|
1649 |
|
|
}
|
1650 |
|
|
}
|
1651 |
|
|
}
|
1652 |
|
|
|
1653 |
791bcfd4
|
Bill Marquette
|
$config['openvpn']['openvpn-server'][] = $server;
|
1654 |
|
|
}
|
1655 |
|
|
unset($config['installedpackages']['openvpnserver']);
|
1656 |
|
|
}
|
1657 |
|
|
|
1658 |
|
|
/* openvpn client configurations */
|
1659 |
|
|
if (is_array($config['installedpackages']['openvpnclient'])) {
|
1660 |
|
|
$config['openvpn']['openvpn-client'] = array();
|
1661 |
|
|
|
1662 |
|
|
$index = 1;
|
1663 |
|
|
foreach($config['installedpackages']['openvpnclient']['config'] as $client) {
|
1664 |
|
|
|
1665 |
|
|
if (!is_array($client))
|
1666 |
|
|
continue;
|
1667 |
|
|
|
1668 |
|
|
if ($client['auth_method'] == "pki") {
|
1669 |
|
|
|
1670 |
|
|
/* create ca entry */
|
1671 |
|
|
$ca = array();
|
1672 |
|
|
$ca['refid'] = uniqid();
|
1673 |
f2a86ca9
|
jim-p
|
$ca['descr'] = "OpenVPN Client CA #{$index}";
|
1674 |
791bcfd4
|
Bill Marquette
|
$ca['crt'] = $client['ca_cert'];
|
1675 |
|
|
$ca['crl'] = $client['crl'];
|
1676 |
9ad72e5e
|
jim-p
|
$config['ca'][] = $ca;
|
1677 |
791bcfd4
|
Bill Marquette
|
|
1678 |
|
|
/* create ca reference */
|
1679 |
|
|
unset($client['ca_cert']);
|
1680 |
|
|
unset($client['crl']);
|
1681 |
|
|
$client['caref'] = $ca['refid'];
|
1682 |
|
|
|
1683 |
|
|
/* create cert entry */
|
1684 |
|
|
$cert = array();
|
1685 |
|
|
$cert['refid'] = uniqid();
|
1686 |
f2a86ca9
|
jim-p
|
$cert['descr'] = "OpenVPN Client Certificate #{$index}";
|
1687 |
791bcfd4
|
Bill Marquette
|
$cert['crt'] = $client['client_cert'];
|
1688 |
|
|
$cert['prv'] = $client['client_key'];
|
1689 |
9ad72e5e
|
jim-p
|
$config['cert'][] = $cert;
|
1690 |
791bcfd4
|
Bill Marquette
|
|
1691 |
|
|
/* create cert reference */
|
1692 |
|
|
unset($client['client_cert']);
|
1693 |
|
|
unset($client['client_key']);
|
1694 |
|
|
$client['certref'] = $cert['refid'];
|
1695 |
|
|
|
1696 |
|
|
$index++;
|
1697 |
|
|
}
|
1698 |
|
|
|
1699 |
|
|
/* determine operational mode */
|
1700 |
|
|
if ($client['auth_method'] == 'pki')
|
1701 |
|
|
$client['mode'] = "p2p_tls";
|
1702 |
|
|
else
|
1703 |
|
|
$client['mode'] = "p2p_shared_key";
|
1704 |
|
|
unset($client['auth_method']);
|
1705 |
|
|
|
1706 |
|
|
/* modify configuration values */
|
1707 |
|
|
if (!$client['interface'])
|
1708 |
|
|
$client['interface'] = 'wan';
|
1709 |
|
|
$client['tunnel_network'] = $client['interface_ip'];
|
1710 |
|
|
unset($client['interface_ip']);
|
1711 |
|
|
$client['server_addr'] = $client['serveraddr'];
|
1712 |
|
|
unset($client['serveraddr']);
|
1713 |
|
|
$client['server_port'] = $client['serverport'];
|
1714 |
|
|
unset($client['serverport']);
|
1715 |
|
|
$client['proxy_addr'] = $client['poxy_hostname'];
|
1716 |
|
|
unset($client['proxy_addr']);
|
1717 |
a843870d
|
jim-p
|
if (isset($client['use_lzo']) && ($client['use_lzo'] == "on")) {
|
1718 |
8b666514
|
jim-p
|
$client['compression'] = "on";
|
1719 |
da831323
|
Ermal Lu?i
|
unset($client['use_lzo']);
|
1720 |
|
|
}
|
1721 |
791bcfd4
|
Bill Marquette
|
$client['resolve_retry'] = $client['infiniteresolvretry'];
|
1722 |
|
|
unset($client['infiniteresolvretry']);
|
1723 |
|
|
|
1724 |
|
|
/* allocate vpnid */
|
1725 |
|
|
$client['vpnid'] = $vpnid++;
|
1726 |
|
|
|
1727 |
4f1ebacb
|
Ermal
|
if (!empty($client['custom_options'])) {
|
1728 |
|
|
$cstmopts = array();
|
1729 |
|
|
$tmpcstmopts = explode(";", $client['custom_options']);
|
1730 |
48e24ada
|
jim-p
|
$assigned_if = "";
|
1731 |
4f1ebacb
|
Ermal
|
$tmpstr = "";
|
1732 |
|
|
foreach ($tmpcstmopts as $tmpcstmopt) {
|
1733 |
|
|
$tmpstr = str_replace(" ", "", $tmpcstmopt);
|
1734 |
|
|
if (substr($tmpstr,0 ,6) == "devtun") {
|
1735 |
48e24ada
|
jim-p
|
$assigned_if = substr($tmpstr, 3);
|
1736 |
4f1ebacb
|
Ermal
|
continue;
|
1737 |
8fd0badd
|
Ermal
|
} else if (substr($tmpstr, 0, 5) == "local") {
|
1738 |
9bc27ae5
|
jim-p
|
$localip = substr($tmpstr, 5);
|
1739 |
8fd0badd
|
Ermal
|
$client['ipaddr'] = str_replace("\n", "", $localip);
|
1740 |
4f1ebacb
|
Ermal
|
} else
|
1741 |
|
|
$cstmopts[] = $tmpcstmopt;
|
1742 |
|
|
}
|
1743 |
|
|
$client['custom_options'] = implode(";", $cstmopts);
|
1744 |
48e24ada
|
jim-p
|
if (!empty($assigned_if)) {
|
1745 |
4f1ebacb
|
Ermal
|
foreach ($config['interfaces'] as $iface => $cfgif) {
|
1746 |
48e24ada
|
jim-p
|
if ($cfgif['if'] == $assigned_if) {
|
1747 |
4f1ebacb
|
Ermal
|
$config['interfaces'][$iface]['if'] = "ovpnc{$client['vpnid']}";
|
1748 |
|
|
break;
|
1749 |
|
|
}
|
1750 |
|
|
}
|
1751 |
|
|
}
|
1752 |
|
|
}
|
1753 |
|
|
|
1754 |
763a1b52
|
jim-p
|
if (!empty($client['disable']))
|
1755 |
|
|
$client['disable'] = true;
|
1756 |
|
|
else
|
1757 |
|
|
unset($client['disable']);
|
1758 |
|
|
|
1759 |
791bcfd4
|
Bill Marquette
|
$config['openvpn']['openvpn-client'][] = $client;
|
1760 |
|
|
}
|
1761 |
|
|
|
1762 |
|
|
unset($config['installedpackages']['openvpnclient']);
|
1763 |
|
|
}
|
1764 |
|
|
|
1765 |
|
|
/* openvpn client specific configurations */
|
1766 |
|
|
if (is_array($config['installedpackages']['openvpncsc'])) {
|
1767 |
|
|
$config['openvpn']['openvpn-csc'] = array();
|
1768 |
|
|
|
1769 |
|
|
foreach($config['installedpackages']['openvpncsc']['config'] as $csc) {
|
1770 |
|
|
|
1771 |
|
|
if (!is_array($csc))
|
1772 |
|
|
continue;
|
1773 |
|
|
|
1774 |
|
|
/* modify configuration values */
|
1775 |
|
|
$csc['common_name'] = $csc['commonname'];
|
1776 |
|
|
unset($csc['commonname']);
|
1777 |
|
|
$csc['tunnel_network'] = $csc['ifconfig_push'];
|
1778 |
|
|
unset($csc['ifconfig_push']);
|
1779 |
|
|
$csc['dns_domain'] = $csc['dhcp_domainname'];
|
1780 |
|
|
unset($csc['dhcp_domainname']);
|
1781 |
c3ae41e6
|
jim-p
|
|
1782 |
|
|
$tmparr = explode(";", $csc['dhcp_dns'], 4);
|
1783 |
|
|
$d=1;
|
1784 |
|
|
foreach ($tmparr as $tmpa) {
|
1785 |
|
|
$csc["dns_server{$d}"] = $tmpa;
|
1786 |
|
|
$d++;
|
1787 |
|
|
}
|
1788 |
791bcfd4
|
Bill Marquette
|
unset($csc['dhcp_dns']);
|
1789 |
c3ae41e6
|
jim-p
|
|
1790 |
|
|
$tmparr = explode(";", $csc['dhcp_ntp'], 2);
|
1791 |
|
|
$d=1;
|
1792 |
|
|
foreach ($tmparr as $tmpa) {
|
1793 |
|
|
$csc["ntp_server{$d}"] = $tmpa;
|
1794 |
|
|
$d++;
|
1795 |
|
|
}
|
1796 |
791bcfd4
|
Bill Marquette
|
unset($csc['dhcp_ntp']);
|
1797 |
c3ae41e6
|
jim-p
|
|
1798 |
791bcfd4
|
Bill Marquette
|
if ($csc['dhcp_nbtdisable'])
|
1799 |
|
|
$csc['netbios_enable'] = false;
|
1800 |
|
|
else
|
1801 |
|
|
$csc['netbios_enable'] = "yes";
|
1802 |
|
|
unset($csc['dhcp_nbtdisable']);
|
1803 |
|
|
$csc['netbios_ntype'] = $csc['dhcp_nbttype'];
|
1804 |
|
|
unset($csc['dhcp_nbttype']);
|
1805 |
|
|
$csc['netbios_scope'] = $csc['dhcp_nbtscope'];
|
1806 |
|
|
unset($csc['dhcp_nbtscope']);
|
1807 |
c3ae41e6
|
jim-p
|
|
1808 |
|
|
$tmparr = explode(";", $csc['dhcp_nbdd'], 2);
|
1809 |
|
|
$d=1;
|
1810 |
|
|
foreach ($tmparr as $tmpa) {
|
1811 |
|
|
$csc["nbdd_server{$d}"] = $tmpa;
|
1812 |
|
|
$d++;
|
1813 |
|
|
}
|
1814 |
791bcfd4
|
Bill Marquette
|
unset($csc['dhcp_nbdd']);
|
1815 |
c3ae41e6
|
jim-p
|
|
1816 |
|
|
$tmparr = explode(";", $csc['dhcp_wins'], 2);
|
1817 |
|
|
$d=1;
|
1818 |
|
|
foreach ($tmparr as $tmpa) {
|
1819 |
|
|
$csc["wins_server{$d}"] = $tmpa;
|
1820 |
|
|
$d++;
|
1821 |
|
|
}
|
1822 |
791bcfd4
|
Bill Marquette
|
unset($csc['dhcp_wins']);
|
1823 |
|
|
|
1824 |
1e68a58b
|
jim-p
|
if (!empty($csc['disable']))
|
1825 |
|
|
$csc['disable'] = true;
|
1826 |
|
|
else
|
1827 |
|
|
unset($csc['disable']);
|
1828 |
|
|
|
1829 |
791bcfd4
|
Bill Marquette
|
$config['openvpn']['openvpn-csc'][] = $csc;
|
1830 |
|
|
}
|
1831 |
|
|
|
1832 |
|
|
unset($config['installedpackages']['openvpncsc']);
|
1833 |
|
|
}
|
1834 |
|
|
|
1835 |
c73bd8f0
|
Ermal Lu?i
|
if (count($config['openvpn']['openvpn-server']) > 0 ||
|
1836 |
|
|
count($config['openvpn']['openvpn-client']) > 0) {
|
1837 |
|
|
$ovpnrule = array();
|
1838 |
|
|
$ovpnrule['type'] = "pass";
|
1839 |
|
|
$ovpnrule['interface'] = "openvpn";
|
1840 |
|
|
$ovpnrule['statetype'] = "keep state";
|
1841 |
|
|
$ovpnrule['source'] = array();
|
1842 |
|
|
$ovpnrule['destination'] = array();
|
1843 |
|
|
$ovpnrule['source']['any'] = true;
|
1844 |
|
|
$ovpnrule['destination']['any'] = true;
|
1845 |
4d511e5b
|
Renato Botelho
|
$ovpnrule['descr'] = gettext("Auto added OpenVPN rule from config upgrade.");
|
1846 |
c73bd8f0
|
Ermal Lu?i
|
$config['filter']['rule'][] = $ovpnrule;
|
1847 |
|
|
}
|
1848 |
|
|
|
1849 |
791bcfd4
|
Bill Marquette
|
/*
|
1850 |
|
|
* FIXME: hack to keep things working with no installedpackages
|
1851 |
|
|
* or carp array in the configuration data.
|
1852 |
|
|
*/
|
1853 |
|
|
if (!is_array($config['installedpackages']))
|
1854 |
|
|
$config['installedpackages'] = array();
|
1855 |
|
|
if (!is_array($config['installedpackages']['carp']))
|
1856 |
|
|
$config['installedpackages']['carp'] = array();
|
1857 |
|
|
|
1858 |
|
|
}
|
1859 |
|
|
|
1860 |
|
|
|
1861 |
|
|
function upgrade_052_to_053() {
|
1862 |
|
|
global $config;
|
1863 |
9ad72e5e
|
jim-p
|
if (!is_array($config['ca']))
|
1864 |
|
|
$config['ca'] = array();
|
1865 |
|
|
if (!is_array($config['cert']))
|
1866 |
|
|
$config['cert'] = array();
|
1867 |
791bcfd4
|
Bill Marquette
|
|
1868 |
|
|
/* migrate advanced admin page webui ssl to certifcate mngr */
|
1869 |
|
|
if ($config['system']['webgui']['certificate'] &&
|
1870 |
|
|
$config['system']['webgui']['private-key']) {
|
1871 |
|
|
|
1872 |
|
|
/* create cert entry */
|
1873 |
|
|
$cert = array();
|
1874 |
|
|
$cert['refid'] = uniqid();
|
1875 |
f2a86ca9
|
jim-p
|
$cert['descr'] = "webConfigurator SSL Certificate";
|
1876 |
791bcfd4
|
Bill Marquette
|
$cert['crt'] = $config['system']['webgui']['certificate'];
|
1877 |
|
|
$cert['prv'] = $config['system']['webgui']['private-key'];
|
1878 |
9ad72e5e
|
jim-p
|
$config['cert'][] = $cert;
|
1879 |
791bcfd4
|
Bill Marquette
|
|
1880 |
|
|
/* create cert reference */
|
1881 |
|
|
unset($config['system']['webgui']['certificate']);
|
1882 |
|
|
unset($config['system']['webgui']['private-key']);
|
1883 |
|
|
$config['system']['webgui']['ssl-certref'] = $cert['refid'];
|
1884 |
|
|
}
|
1885 |
|
|
|
1886 |
|
|
/* migrate advanced admin page ssh keys to user manager */
|
1887 |
|
|
if ($config['system']['ssh']['authorizedkeys']) {
|
1888 |
|
|
$admin_user =& getUserEntryByUID(0);
|
1889 |
|
|
$admin_user['authorizedkeys'] = $config['system']['ssh']['authorizedkeys'];
|
1890 |
|
|
unset($config['system']['ssh']['authorizedkeys']);
|
1891 |
|
|
}
|
1892 |
|
|
}
|
1893 |
|
|
|
1894 |
|
|
|
1895 |
|
|
function upgrade_053_to_054() {
|
1896 |
|
|
global $config;
|
1897 |
38b5beaf
|
sullrich
|
if(is_array($config['load_balancer']['lbpool'])) {
|
1898 |
|
|
$lbpool_arr = $config['load_balancer']['lbpool'];
|
1899 |
791bcfd4
|
Bill Marquette
|
$lbpool_srv_arr = array();
|
1900 |
|
|
$gateway_group_arr = array();
|
1901 |
816a5aff
|
Seth Mos
|
$gateways = return_gateways_array();
|
1902 |
ce107ca5
|
jim-p
|
$group_name_changes = array();
|
1903 |
d827f9cc
|
smos
|
if (! is_array($config['gateways']['gateway_item']))
|
1904 |
bf02c784
|
Ermal
|
$config['gateways']['gateway_item'] = array();
|
1905 |
d827f9cc
|
smos
|
|
1906 |
bf02c784
|
Ermal
|
$a_gateways =& $config['gateways']['gateway_item'];
|
1907 |
791bcfd4
|
Bill Marquette
|
foreach($lbpool_arr as $lbpool) {
|
1908 |
|
|
if($lbpool['type'] == "gateway") {
|
1909 |
ce107ca5
|
jim-p
|
// Gateway Groups have to have valid names in pf, old lb pools did not. Clean them up.
|
1910 |
|
|
$group_name = ereg_replace("[^A-Za-z0-9]", "", $lbpool['name'] );
|
1911 |
|
|
// If we made and changes, check for collisions and note the change.
|
1912 |
|
|
if ($group_name != $lbpool['name']) {
|
1913 |
|
|
// Make sure the name isn't already in use.
|
1914 |
|
|
foreach ($gateway_group_arr as $gwg) {
|
1915 |
|
|
// If the name is in use, add some random bits to avoid collision.
|
1916 |
|
|
if ($gwg['name'] == $group_name)
|
1917 |
|
|
$group_name .= uniqid();
|
1918 |
|
|
}
|
1919 |
|
|
$group_name_changes[$lbpool['name']] = $group_name;
|
1920 |
|
|
}
|
1921 |
|
|
$gateway_group['name'] = $group_name;
|
1922 |
e988813d
|
jim-p
|
$gateway_group['descr'] = $lbpool['descr'];
|
1923 |
791bcfd4
|
Bill Marquette
|
$gateway_group['trigger'] = "down";
|
1924 |
|
|
$gateway_group['item'] = array();
|
1925 |
cb945ced
|
sullrich
|
$i = 0;
|
1926 |
791bcfd4
|
Bill Marquette
|
foreach($lbpool['servers'] as $member) {
|
1927 |
2ce660ad
|
smos
|
$split = explode("|", $member);
|
1928 |
791bcfd4
|
Bill Marquette
|
$interface = $split[0];
|
1929 |
d9d4c637
|
Seth Mos
|
$monitor = $split[1];
|
1930 |
2328dcc5
|
Seth Mos
|
/* on static upgraded configuration we automatically prepend GW_ */
|
1931 |
|
|
$static_name = "GW_" . strtoupper($interface);
|
1932 |
d2b20ab6
|
jim-p
|
if(is_ipaddr($monitor))
|
1933 |
|
|
foreach ($a_gateways as & $gw)
|
1934 |
|
|
if ($gw['name'] == $static_name)
|
1935 |
|
|
$gw['monitor'] = $monitor;
|
1936 |
|
|
|
1937 |
6ee1b7eb
|
Seth Mos
|
/* on failover increment tier. Else always assign 1 */
|
1938 |
|
|
if($lbpool['behaviour'] == "failover") {
|
1939 |
|
|
$i++;
|
1940 |
|
|
} else {
|
1941 |
|
|
$i = 1;
|
1942 |
|
|
}
|
1943 |
685a26fc
|
smos
|
$gateway_group['item'][] = "$static_name|$i";
|
1944 |
791bcfd4
|
Bill Marquette
|
}
|
1945 |
|
|
$gateway_group_arr[] = $gateway_group;
|
1946 |
|
|
} else {
|
1947 |
|
|
$lbpool_srv_arr[] = $lbpool;
|
1948 |
|
|
}
|
1949 |
|
|
}
|
1950 |
38b5beaf
|
sullrich
|
$config['load_balancer']['lbpool'] = $lbpool_srv_arr;
|
1951 |
791bcfd4
|
Bill Marquette
|
$config['gateways']['gateway_group'] = $gateway_group_arr;
|
1952 |
|
|
}
|
1953 |
|
|
// Unset lbpool if we no longer have any server pools
|
1954 |
|
|
if (count($lbpool_srv_arr) == 0) {
|
1955 |
416ae3d6
|
Seth Mos
|
if(empty($config['load_balancer'])) {
|
1956 |
0b5b4f32
|
Seth Mos
|
unset($config['load_balancer']);
|
1957 |
92a2ceae
|
Seth Mos
|
} else {
|
1958 |
|
|
unset($config['load_balancer']['lbpool']);
|
1959 |
0b5b4f32
|
Seth Mos
|
}
|
1960 |
791bcfd4
|
Bill Marquette
|
} else {
|
1961 |
|
|
$config['load_balancer']['lbpool'] = $lbpool_srv_arr;
|
1962 |
|
|
}
|
1963 |
|
|
// Only set the gateway group array if we converted any
|
1964 |
|
|
if (count($gateway_group_arr) != 0) {
|
1965 |
|
|
$config['gateways']['gateway_group'] = $gateway_group_arr;
|
1966 |
ce107ca5
|
jim-p
|
// Update any rules that had a gateway change, if any.
|
1967 |
|
|
if (count($group_name_changes) > 0)
|
1968 |
|
|
foreach ($config['filter']['rule'] as & $rule)
|
1969 |
|
|
if (!empty($rule["gateway"]) && array_key_exists($rule["gateway"], $group_name_changes))
|
1970 |
|
|
$rule["gateway"] = $group_name_changes[$rule["gateway"]];
|
1971 |
791bcfd4
|
Bill Marquette
|
}
|
1972 |
|
|
}
|
1973 |
|
|
|
1974 |
|
|
|
1975 |
|
|
function upgrade_054_to_055() {
|
1976 |
|
|
global $config;
|
1977 |
54f8bad0
|
Seth Mos
|
global $g;
|
1978 |
|
|
|
1979 |
791bcfd4
|
Bill Marquette
|
/* RRD files changed for quality, traffic and packets graphs */
|
1980 |
59cfe65d
|
Ermal
|
//ini_set("max_execution_time", "1800");
|
1981 |
791bcfd4
|
Bill Marquette
|
/* convert traffic RRD file */
|
1982 |
|
|
global $parsedcfg, $listtags;
|
1983 |
|
|
$listtags = array("ds", "v", "rra", "row");
|
1984 |
|
|
|
1985 |
|
|
$rrddbpath = "/var/db/rrd/";
|
1986 |
|
|
$rrdtool = "/usr/bin/nice -n20 /usr/local/bin/rrdtool";
|
1987 |
e34cf1f6
|
smos
|
if ($g['platform'] != "pfSense") {
|
1988 |
|
|
/* restore the databases, if we have one */
|
1989 |
8bdb6879
|
Darren Embry
|
if (restore_rrd()) {
|
1990 |
e34cf1f6
|
smos
|
/* Make sure to move the rrd backup out of the way. We will make a new one after converting. */
|
1991 |
8fa054b1
|
smos
|
exec("/bin/mv {$g['cf_conf_path']}/rrd.tgz {$g['cf_conf_path']}/backup");
|
1992 |
e34cf1f6
|
smos
|
}
|
1993 |
|
|
}
|
1994 |
791bcfd4
|
Bill Marquette
|
|
1995 |
|
|
$rrdinterval = 60;
|
1996 |
|
|
$valid = $rrdinterval * 2;
|
1997 |
|
|
|
1998 |
|
|
/* Asume GigE for now */
|
1999 |
|
|
$downstream = 125000000;
|
2000 |
|
|
$upstream = 125000000;
|
2001 |
|
|
|
2002 |
|
|
/* build a list of quality databases */
|
2003 |
|
|
/* roundtrip has become delay */
|
2004 |
|
|
function divide_delay($delayval) {
|
2005 |
|
|
$delayval = floatval($delayval);
|
2006 |
|
|
$delayval = ($delayval / 1000);
|
2007 |
|
|
$delayval = " ". sprintf("%1.10e", $delayval) ." ";
|
2008 |
|
|
return $delayval;
|
2009 |
|
|
}
|
2010 |
|
|
/* the roundtrip times need to be divided by 1000 to get seconds, really */
|
2011 |
|
|
$databases = array();
|
2012 |
af0b07d3
|
jim-p
|
if (!file_exists($rrddbpath))
|
2013 |
|
|
@mkdir($rrddbpath);
|
2014 |
4cb9abc3
|
jim-p
|
chdir($rrddbpath);
|
2015 |
|
|
$databases = glob("*-quality.rrd");
|
2016 |
791bcfd4
|
Bill Marquette
|
rsort($databases);
|
2017 |
|
|
foreach($databases as $database) {
|
2018 |
|
|
$xmldump = "{$database}.old.xml";
|
2019 |
|
|
$xmldumpnew = "{$database}.new.xml";
|
2020 |
|
|
|
2021 |
34834e7e
|
jim-p
|
if ($g['booting'])
|
2022 |
9bc8b6b6
|
Seth Mos
|
echo "Migrate RRD database {$database} to new format for IPv6 \n";
|
2023 |
791bcfd4
|
Bill Marquette
|
mwexec("$rrdtool tune {$rrddbpath}{$database} -r roundtrip:delay 2>&1");
|
2024 |
|
|
|
2025 |
|
|
dump_rrd_to_xml("{$rrddbpath}/{$database}", "{$g['tmp_path']}/{$xmldump}");
|
2026 |
1005d4bf
|
Seth Mos
|
$rrdold = xml2array(file_get_contents("{$g['tmp_path']}/{$xmldump}"), 1, "tag");
|
2027 |
791bcfd4
|
Bill Marquette
|
$rrdold = $rrdold['rrd'];
|
2028 |
|
|
|
2029 |
|
|
$i = 0;
|
2030 |
|
|
foreach($rrdold['rra'] as $rra) {
|
2031 |
|
|
$l = 0;
|
2032 |
|
|
foreach($rra['database']['row'] as $row) {
|
2033 |
|
|
$vnew = divide_delay($row['v'][1]);
|
2034 |
|
|
$rrdold['rra'][$i]['database']['row'][$l]['v'][1] = $vnew;
|
2035 |
|
|
$l++;
|
2036 |
|
|
}
|
2037 |
|
|
$i++;
|
2038 |
|
|
}
|
2039 |
|
|
|
2040 |
56ee96ed
|
smos
|
file_put_contents("{$g['tmp_path']}/{$xmldumpnew}", dump_xml_config_raw($rrdold, "rrd"));
|
2041 |
791bcfd4
|
Bill Marquette
|
mwexec("$rrdtool restore -f {$g['tmp_path']}/{$xmldumpnew} {$rrddbpath}/{$database} 2>&1");
|
2042 |
|
|
|
2043 |
1005d4bf
|
Seth Mos
|
unset($rrdold);
|
2044 |
791bcfd4
|
Bill Marquette
|
}
|
2045 |
|
|
/* let apinger recreate required files */
|
2046 |
|
|
setup_gateways_monitor();
|
2047 |
|
|
|
2048 |
|
|
/* build a list of traffic and packets databases */
|
2049 |
|
|
$databases = array();
|
2050 |
a87afa7c
|
Seth Mos
|
exec("cd $rrddbpath;/usr/bin/find *-traffic.rrd *-packets.rrd", $databases);
|
2051 |
791bcfd4
|
Bill Marquette
|
rsort($databases);
|
2052 |
|
|
foreach($databases as $database) {
|
2053 |
|
|
$databasetmp = "{$database}.tmp";
|
2054 |
|
|
$xmldump = "{$database}.old.xml";
|
2055 |
|
|
$xmldumptmp = "{$database}.tmp.xml";
|
2056 |
|
|
$xmldumpnew = "{$database}.new.xml";
|
2057 |
|
|
|
2058 |
34834e7e
|
jim-p
|
if ($g['booting'])
|
2059 |
|
|
echo "Migrate RRD database {$database} to new format \n";
|
2060 |
791bcfd4
|
Bill Marquette
|
/* rename DS source */
|
2061 |
|
|
mwexec("$rrdtool tune {$rrddbpath}/{$database} -r in:inpass 2>&1");
|
2062 |
|
|
mwexec("$rrdtool tune {$rrddbpath}/{$database} -r out:outpass 2>71");
|
2063 |
|
|
|
2064 |
|
|
/* dump contents to xml and move database out of the way */
|
2065 |
|
|
dump_rrd_to_xml("{$rrddbpath}/{$database}", "{$g['tmp_path']}/{$xmldump}");
|
2066 |
|
|
|
2067 |
|
|
/* create new rrd database file */
|
2068 |
|
|
$rrdcreate = "$rrdtool create {$g['tmp_path']}/{$databasetmp} --step $rrdinterval ";
|
2069 |
|
|
$rrdcreate .= "DS:inpass:COUNTER:$valid:0:$downstream ";
|
2070 |
|
|
$rrdcreate .= "DS:outpass:COUNTER:$valid:0:$upstream ";
|
2071 |
|
|
$rrdcreate .= "DS:inblock:COUNTER:$valid:0:$downstream ";
|
2072 |
|
|
$rrdcreate .= "DS:outblock:COUNTER:$valid:0:$upstream ";
|
2073 |
|
|
$rrdcreate .= "RRA:AVERAGE:0.5:1:1000 ";
|
2074 |
|
|
$rrdcreate .= "RRA:AVERAGE:0.5:5:1000 ";
|
2075 |
|
|
$rrdcreate .= "RRA:AVERAGE:0.5:60:1000 ";
|
2076 |
eb346e0b
|
Seth Mos
|
$rrdcreate .= "RRA:AVERAGE:0.5:720:1000 ";
|
2077 |
791bcfd4
|
Bill Marquette
|
|
2078 |
|
|
create_new_rrd("$rrdcreate");
|
2079 |
|
|
/* create temporary xml from new RRD */
|
2080 |
|
|
dump_rrd_to_xml("{$g['tmp_path']}/{$databasetmp}", "{$g['tmp_path']}/{$xmldumptmp}");
|
2081 |
|
|
|
2082 |
1005d4bf
|
Seth Mos
|
$rrdold = xml2array(file_get_contents("{$g['tmp_path']}/{$xmldump}"), 1, "tag");
|
2083 |
791bcfd4
|
Bill Marquette
|
$rrdold = $rrdold['rrd'];
|
2084 |
|
|
|
2085 |
1005d4bf
|
Seth Mos
|
$rrdnew = xml2array(file_get_contents("{$g['tmp_path']}/{$xmldumptmp}"), 1, "tag");
|
2086 |
791bcfd4
|
Bill Marquette
|
$rrdnew = $rrdnew['rrd'];
|
2087 |
|
|
|
2088 |
|
|
/* remove any MAX RRA's. Not needed for traffic. */
|
2089 |
|
|
$i = 0;
|
2090 |
|
|
foreach ($rrdold['rra'] as $rra) {
|
2091 |
|
|
if(trim($rra['cf']) == "MAX") {
|
2092 |
|
|
unset($rrdold['rra'][$i]);
|
2093 |
|
|
}
|
2094 |
|
|
$i++;
|
2095 |
|
|
}
|
2096 |
|
|
|
2097 |
56ee96ed
|
smos
|
file_put_contents("{$g['tmp_path']}/{$xmldumpnew}", dump_xml_config_raw(migrate_rrd_format($rrdold, $rrdnew), "rrd"));
|
2098 |
791bcfd4
|
Bill Marquette
|
mwexec("$rrdtool restore -f {$g['tmp_path']}/{$xmldumpnew} {$rrddbpath}/{$database} 2>&1");
|
2099 |
eb346e0b
|
Seth Mos
|
/* we now have the rrd with the new fields, adjust the size now. */
|
2100 |
|
|
/* RRA 2 is 60 minutes, RRA 3 is 720 minutes */
|
2101 |
|
|
mwexec("/bin/sync");
|
2102 |
12a2f395
|
Seth Mos
|
mwexec("$rrdtool resize {$rrddbpath}/{$database} 2 GROW 2000;/bin/mv resize.rrd {$rrddbpath}/{$database} 2>&1");
|
2103 |
eb346e0b
|
Seth Mos
|
mwexec("/bin/sync");
|
2104 |
12a2f395
|
Seth Mos
|
mwexec("$rrdtool resize {$rrddbpath}/{$database} 3 GROW 2000;/bin/mv resize.rrd {$rrddbpath}/{$database} 2>&1");
|
2105 |
1005d4bf
|
Seth Mos
|
unset($rrdxmlarray);
|
2106 |
791bcfd4
|
Bill Marquette
|
}
|
2107 |
|
|
enable_rrd_graphing();
|
2108 |
e34cf1f6
|
smos
|
/* Let's save the RRD graphs after we run enable RRD graphing */
|
2109 |
|
|
/* The function will restore the rrd.tgz so we will save it after */
|
2110 |
8bdb6879
|
Darren Embry
|
exec("cd /; LANG=C NO_REMOUNT=1 RRDDBPATH='{$rrddbpath}' CF_CONF_PATH='{$g['cf_conf_path']}' /etc/rc.backup_rrd.sh");
|
2111 |
34834e7e
|
jim-p
|
if ($g['booting'])
|
2112 |
|
|
echo "Updating configuration...";
|
2113 |
791bcfd4
|
Bill Marquette
|
}
|
2114 |
|
|
|
2115 |
|
|
|
2116 |
|
|
function upgrade_055_to_056() {
|
2117 |
|
|
global $config;
|
2118 |
|
|
|
2119 |
9ad72e5e
|
jim-p
|
if (!is_array($config['ca']))
|
2120 |
|
|
$config['ca'] = array();
|
2121 |
|
|
if (!is_array($config['cert']))
|
2122 |
|
|
$config['cert'] = array();
|
2123 |
791bcfd4
|
Bill Marquette
|
|
2124 |
|
|
/* migrate ipsec ca's to cert manager */
|
2125 |
|
|
if (is_array($config['ipsec']['cacert'])) {
|
2126 |
|
|
foreach($config['ipsec']['cacert'] as & $cacert) {
|
2127 |
|
|
$ca = array();
|
2128 |
|
|
$ca['refid'] = uniqid();
|
2129 |
|
|
if (is_array($cacert['cert']))
|
2130 |
|
|
$ca['crt'] = $cacert['cert'][0];
|
2131 |
|
|
else
|
2132 |
|
|
$ca['crt'] = $cacert['cert'];
|
2133 |
f2a86ca9
|
jim-p
|
$ca['descr'] = $cacert['ident'];
|
2134 |
9ad72e5e
|
jim-p
|
$config['ca'][] = $ca;
|
2135 |
791bcfd4
|
Bill Marquette
|
}
|
2136 |
|
|
unset($config['ipsec']['cacert']);
|
2137 |
|
|
}
|
2138 |
|
|
|
2139 |
|
|
/* migrate phase1 certificates to cert manager */
|
2140 |
|
|
if (is_array($config['ipsec']['phase1'])) {
|
2141 |
|
|
foreach($config['ipsec']['phase1'] as & $ph1ent) {
|
2142 |
|
|
$cert = array();
|
2143 |
|
|
$cert['refid'] = uniqid();
|
2144 |
f2a86ca9
|
jim-p
|
$cert['descr'] = "IPsec Peer {$ph1ent['remote-gateway']} Certificate";
|
2145 |
791bcfd4
|
Bill Marquette
|
if (is_array($ph1ent['cert']))
|
2146 |
|
|
$cert['crt'] = $ph1ent['cert'][0];
|
2147 |
|
|
else
|
2148 |
|
|
$cert['crt'] = $ph1ent['cert'];
|
2149 |
|
|
$cert['prv'] = $ph1ent['private-key'];
|
2150 |
9ad72e5e
|
jim-p
|
$config['cert'][] = $cert;
|
2151 |
791bcfd4
|
Bill Marquette
|
$ph1ent['certref'] = $cert['refid'];
|
2152 |
|
|
if ($ph1ent['cert'])
|
2153 |
|
|
unset($ph1ent['cert']);
|
2154 |
|
|
if ($ph1ent['private-key'])
|
2155 |
|
|
unset($ph1ent['private-key']);
|
2156 |
|
|
if ($ph1ent['peercert'])
|
2157 |
|
|
unset($ph1ent['peercert']);
|
2158 |
|
|
}
|
2159 |
|
|
}
|
2160 |
|
|
}
|
2161 |
|
|
|
2162 |
|
|
|
2163 |
|
|
function upgrade_056_to_057() {
|
2164 |
|
|
global $config;
|
2165 |
84924e76
|
Ermal
|
|
2166 |
4830e56a
|
Erik Fonnesbeck
|
if (!is_array($config['system']['user']))
|
2167 |
|
|
$config['system']['user'] = array();
|
2168 |
791bcfd4
|
Bill Marquette
|
/* migrate captivate portal to user manager */
|
2169 |
|
|
if (is_array($config['captiveportal']['user'])) {
|
2170 |
|
|
foreach($config['captiveportal']['user'] as $user) {
|
2171 |
|
|
// avoid user conflicts
|
2172 |
4830e56a
|
Erik Fonnesbeck
|
$found = false;
|
2173 |
|
|
foreach ($config['system']['user'] as $userent) {
|
2174 |
|
|
if ($userent['name'] == $user['name']) {
|
2175 |
|
|
$found = true;
|
2176 |
|
|
break;
|
2177 |
|
|
}
|
2178 |
|
|
}
|
2179 |
|
|
if ($found)
|
2180 |
791bcfd4
|
Bill Marquette
|
continue;
|
2181 |
|
|
$user['scope'] = "user";
|
2182 |
|
|
if (isset($user['expirationdate'])) {
|
2183 |
|
|
$user['expires'] = $user['expirationdate'];
|
2184 |
|
|
unset($user['expirationdate']);
|
2185 |
|
|
}
|
2186 |
|
|
if (isset($user['password'])) {
|
2187 |
|
|
$user['md5-hash'] = $user['password'];
|
2188 |
|
|
unset($user['password']);
|
2189 |
|
|
}
|
2190 |
4830e56a
|
Erik Fonnesbeck
|
$user['uid'] = $config['system']['nextuid']++;
|
2191 |
791bcfd4
|
Bill Marquette
|
$config['system']['user'][] = $user;
|
2192 |
|
|
}
|
2193 |
|
|
unset($config['captiveportal']['user']);
|
2194 |
|
|
}
|
2195 |
|
|
}
|
2196 |
4b96b367
|
mgrooms
|
|
2197 |
|
|
function upgrade_057_to_058() {
|
2198 |
|
|
global $config;
|
2199 |
|
|
/* set all phase2 entries to tunnel mode */
|
2200 |
|
|
if (is_array($config['ipsec']['phase2']))
|
2201 |
|
|
foreach($config['ipsec']['phase2'] as & $ph2ent)
|
2202 |
|
|
$ph2ent['mode'] = 'tunnel';
|
2203 |
|
|
}
|
2204 |
60120e37
|
Ermal Lu?i
|
|
2205 |
|
|
function upgrade_058_to_059() {
|
2206 |
|
|
global $config;
|
2207 |
|
|
|
2208 |
|
|
if (is_array($config['schedules']['schedule'])) {
|
2209 |
|
|
foreach ($config['schedules']['schedule'] as & $schedl)
|
2210 |
|
|
$schedl['schedlabel'] = uniqid();
|
2211 |
|
|
}
|
2212 |
|
|
}
|
2213 |
2523c923
|
Seth Mos
|
|
2214 |
|
|
function upgrade_059_to_060() {
|
2215 |
fcf5afa0
|
Seth Mos
|
global $config;
|
2216 |
a0588fad
|
Scott Ullrich
|
require_once("/etc/inc/certs.inc");
|
2217 |
9ad72e5e
|
jim-p
|
if (is_array($config['ca'])) {
|
2218 |
2cf6ddcb
|
Nigel Graham
|
/* Locate issuer for all CAs */
|
2219 |
9ad72e5e
|
jim-p
|
foreach ($config['ca'] as & $ca) {
|
2220 |
2cf6ddcb
|
Nigel Graham
|
$subject = cert_get_subject($ca['crt']);
|
2221 |
|
|
$issuer = cert_get_issuer($ca['crt']);
|
2222 |
|
|
if($issuer <> $subject) {
|
2223 |
|
|
$issuer_crt =& lookup_ca_by_subject($issuer);
|
2224 |
|
|
if($issuer_crt)
|
2225 |
|
|
$ca['caref'] = $issuer_crt['refid'];
|
2226 |
|
|
}
|
2227 |
|
|
}
|
2228 |
|
|
|
2229 |
|
|
/* Locate issuer for all certificates */
|
2230 |
9ad72e5e
|
jim-p
|
if (is_array($config['cert'])) {
|
2231 |
|
|
foreach ($config['cert'] as & $cert) {
|
2232 |
2cf6ddcb
|
Nigel Graham
|
$subject = cert_get_subject($cert['crt']);
|
2233 |
|
|
$issuer = cert_get_issuer($cert['crt']);
|
2234 |
|
|
if($issuer <> $subject) {
|
2235 |
|
|
$issuer_crt =& lookup_ca_by_subject($issuer);
|
2236 |
|
|
if($issuer_crt)
|
2237 |
|
|
$cert['caref'] = $issuer_crt['refid'];
|
2238 |
|
|
}
|
2239 |
|
|
}
|
2240 |
9d3dab70
|
Scott Ullrich
|
}
|
2241 |
2cf6ddcb
|
Nigel Graham
|
}
|
2242 |
|
|
}
|
2243 |
d43ad788
|
Scott Ullrich
|
|
2244 |
6a688547
|
Ermal
|
function upgrade_060_to_061() {
|
2245 |
|
|
global $config;
|
2246 |
3cfa11c2
|
Scott Ullrich
|
|
2247 |
6a688547
|
Ermal
|
if (is_array($config['interfaces']['wan']))
|
2248 |
|
|
$config['interfaces']['wan']['enable'] = true;
|
2249 |
|
|
if (is_array($config['interfaces']['lan']))
|
2250 |
|
|
$config['interfaces']['lan']['enable'] = true;
|
2251 |
1cad6f6c
|
jim-p
|
|
2252 |
|
|
/* On 1.2.3 the "mtu" field adjusted MSS.
|
2253 |
|
|
On 2.x the "mtu" field is actually the MTU. Rename accordingly.
|
2254 |
|
|
See redmine ticket #1886
|
2255 |
|
|
*/
|
2256 |
|
|
foreach ($config['interfaces'] as $ifr => &$intf) {
|
2257 |
|
|
if (isset($intf['mtu']) && is_numeric($intf['mtu'])) {
|
2258 |
|
|
$intf['mss'] = $intf['mtu'];
|
2259 |
|
|
unset($intf['mtu']);
|
2260 |
|
|
}
|
2261 |
|
|
}
|
2262 |
6a688547
|
Ermal
|
}
|
2263 |
3cfa11c2
|
Scott Ullrich
|
|
2264 |
59ecde49
|
Renato Botelho
|
function upgrade_061_to_062() {
|
2265 |
|
|
global $config;
|
2266 |
|
|
|
2267 |
|
|
/* Convert NAT port forwarding rules */
|
2268 |
|
|
if (is_array($config['nat']['rule'])) {
|
2269 |
|
|
$a_nat = &$config['nat']['rule'];
|
2270 |
|
|
|
2271 |
|
|
foreach ($a_nat as &$natent) {
|
2272 |
|
|
$natent['disabled'] = false;
|
2273 |
|
|
$natent['nordr'] = false;
|
2274 |
|
|
|
2275 |
|
|
$natent['source'] = array(
|
2276 |
|
|
"not" => false,
|
2277 |
|
|
"any" => true,
|
2278 |
|
|
"port" => ""
|
2279 |
|
|
);
|
2280 |
|
|
|
2281 |
|
|
$natent['destination'] = array(
|
2282 |
|
|
"not" => false,
|
2283 |
|
|
"address" => $natent['external-address'],
|
2284 |
|
|
"port" => $natent['external-port']
|
2285 |
|
|
);
|
2286 |
|
|
|
2287 |
743ce9f8
|
Erik Fonnesbeck
|
if (empty($natent['destination']['address'])) {
|
2288 |
fcf4e8cd
|
Erik Fonnesbeck
|
unset($natent['destination']['address']);
|
2289 |
|
|
$natent['destination']['network'] = $natent['interface'] . 'ip';
|
2290 |
743ce9f8
|
Erik Fonnesbeck
|
} else if ($natent['destination']['address'] == 'any') {
|
2291 |
|
|
unset($natent['destination']['address']);
|
2292 |
|
|
$natent['destination']['any'] = true;
|
2293 |
|
|
}
|
2294 |
|
|
|
2295 |
59ecde49
|
Renato Botelho
|
unset($natent['external-address']);
|
2296 |
|
|
unset($natent['external-port']);
|
2297 |
|
|
}
|
2298 |
|
|
|
2299 |
|
|
unset($natent);
|
2300 |
|
|
}
|
2301 |
|
|
}
|
2302 |
|
|
|
2303 |
0f8266ed
|
smos
|
function upgrade_062_to_063() {
|
2304 |
168a1e48
|
smos
|
/* Upgrade legacy Themes to the new pfsense_ng */
|
2305 |
|
|
global $config;
|
2306 |
|
|
|
2307 |
|
|
switch($config['theme']) {
|
2308 |
1852fef0
|
smos
|
case "nervecenter":
|
2309 |
168a1e48
|
smos
|
$config['theme'] = "pfsense_ng";
|
2310 |
|
|
break;
|
2311 |
|
|
}
|
2312 |
|
|
|
2313 |
|
|
}
|
2314 |
c2b2b571
|
gnhb
|
|
2315 |
|
|
function upgrade_063_to_064() {
|
2316 |
|
|
global $config;
|
2317 |
d09ca87e
|
gnhb
|
$j=0;
|
2318 |
|
|
$ifcfg = &$config['interfaces'];
|
2319 |
|
|
|
2320 |
f7480829
|
gnhb
|
if (is_array($config['ppps']['ppp']) && count($config['ppps']['ppp'])) {
|
2321 |
c2b2b571
|
gnhb
|
foreach ($config['ppps']['ppp'] as $pppid => $ppp) {
|
2322 |
d09ca87e
|
gnhb
|
$config['ppps']['ppp'][$pppid]['if'] = "ppp".$j;
|
2323 |
|
|
$config['ppps']['ppp'][$pppid]['ptpid'] = $j;
|
2324 |
|
|
$j++;
|
2325 |
c2b2b571
|
gnhb
|
if (isset($ppp['port'])){
|
2326 |
|
|
$config['ppps']['ppp'][$pppid]['ports'] = $ppp['port'];
|
2327 |
|
|
unset($config['ppps']['ppp'][$pppid]['port']);
|
2328 |
|
|
}
|
2329 |
|
|
if (!isset($ppp['type'])){
|
2330 |
|
|
$config['ppps']['ppp'][$pppid]['type'] = "ppp";
|
2331 |
|
|
}
|
2332 |
8256f324
|
gnhb
|
if (isset($ppp['defaultgw']))
|
2333 |
6fdfa8fb
|
gnhb
|
unset($config['ppps']['ppp'][$pppid]['defaultgw']);
|
2334 |
c2b2b571
|
gnhb
|
}
|
2335 |
|
|
}
|
2336 |
|
|
|
2337 |
|
|
if (!is_array($config['ppps']['ppp']))
|
2338 |
|
|
$config['ppps']['ppp'] = array();
|
2339 |
|
|
$a_ppps = &$config['ppps']['ppp'];
|
2340 |
|
|
|
2341 |
|
|
foreach ($ifcfg as $ifname => $ifinfo) {
|
2342 |
|
|
$ppp = array();
|
2343 |
|
|
// For pppoe conversion
|
2344 |
|
|
if ($ifinfo['ipaddr'] == "pppoe" || $ifinfo['ipaddr'] == "pptp"){
|
2345 |
|
|
if (isset($ifinfo['ptpid']))
|
2346 |
|
|
continue;
|
2347 |
d09ca87e
|
gnhb
|
$ppp['ptpid'] = $j;
|
2348 |
c2b2b571
|
gnhb
|
$ppp['type'] = $ifinfo['ipaddr'];
|
2349 |
d09ca87e
|
gnhb
|
$ppp['if'] = $ifinfo['ipaddr'].$j;
|
2350 |
c2b2b571
|
gnhb
|
$ppp['ports'] = $ifinfo['if'];
|
2351 |
|
|
if ($ifinfo['ipaddr'] == "pppoe"){
|
2352 |
|
|
$ppp['username'] = $ifinfo['pppoe_username'];
|
2353 |
|
|
$ppp['password'] = base64_encode($ifinfo['pppoe_password']);
|
2354 |
|
|
}
|
2355 |
|
|
if ($ifinfo['ipaddr'] == "pptp"){
|
2356 |
|
|
$ppp['username'] = $ifinfo['pptp_username'];
|
2357 |
|
|
$ppp['password'] = base64_encode($ifinfo['pptp_password']);
|
2358 |
|
|
}
|
2359 |
|
|
|
2360 |
|
|
if (isset($ifinfo['provider']))
|
2361 |
|
|
$ppp['provider'] = $ifinfo['provider'];
|
2362 |
|
|
if (isset($ifinfo['ondemand']))
|
2363 |
|
|
$ppp['ondemand'] = true;
|
2364 |
|
|
if (isset($ifinfo['timeout']))
|
2365 |
|
|
$ppp['idletimeout'] = $ifinfo['timeout'];
|
2366 |
|
|
if (isset($ifinfo['pppoe']['pppoe-reset-type'])){
|
2367 |
|
|
$ppp['pppoe-reset-type'] = $ifinfo['pppoe']['pppoe-reset-type'];
|
2368 |
|
|
if (is_array($config['cron']['item'])) {
|
2369 |
|
|
for ($i = 0; $i < count($config['cron']['item']); $i++) {
|
2370 |
|
|
$item = $config['cron']['item'][$i];
|
2371 |
|
|
if (strpos($item['command'], "/conf/pppoe{$ifname}restart") !== false)
|
2372 |
f7480829
|
gnhb
|
$config['cron']['item'][$i]['command'] = "/var/etc/pppoe_restart_" . $ppp['if'];
|
2373 |
c2b2b571
|
gnhb
|
}
|
2374 |
|
|
}
|
2375 |
|
|
}
|
2376 |
|
|
if (isset($ifinfo['local']))
|
2377 |
|
|
$ppp['localip'] = $ifinfo['local'];
|
2378 |
|
|
if (isset($ifinfo['subnet']))
|
2379 |
|
|
$ppp['subnet'] = $ifinfo['subnet'];
|
2380 |
|
|
if (isset($ifinfo['remote']))
|
2381 |
|
|
$ppp['gateway'] = $ifinfo['remote'];
|
2382 |
f7480829
|
gnhb
|
|
2383 |
d09ca87e
|
gnhb
|
$ifcfg[$ifname]['if'] = $ifinfo['ipaddr'].$j;
|
2384 |
|
|
$j++;
|
2385 |
f7480829
|
gnhb
|
|
2386 |
c2b2b571
|
gnhb
|
unset($ifcfg[$ifname]['pppoe_username']);
|
2387 |
|
|
unset($ifcfg[$ifname]['pppoe_password']);
|
2388 |
|
|
unset($ifcfg[$ifname]['provider']);
|
2389 |
|
|
unset($ifcfg[$ifname]['ondemand']);
|
2390 |
|
|
unset($ifcfg[$ifname]['timeout']);
|
2391 |
|
|
unset($ifcfg[$ifname]['pppoe_reset']);
|
2392 |
|
|
unset($ifcfg[$ifname]['pppoe_preset']);
|
2393 |
|
|
unset($ifcfg[$ifname]['pppoe']);
|
2394 |
|
|
unset($ifcfg[$ifname]['pptp_username']);
|
2395 |
|
|
unset($ifcfg[$ifname]['pptp_password']);
|
2396 |
|
|
unset($ifcfg[$ifname]['local']);
|
2397 |
|
|
unset($ifcfg[$ifname]['subnet']);
|
2398 |
|
|
unset($ifcfg[$ifname]['remote']);
|
2399 |
|
|
|
2400 |
|
|
$a_ppps[] = $ppp;
|
2401 |
|
|
|
2402 |
|
|
}
|
2403 |
|
|
}
|
2404 |
|
|
}
|
2405 |
|
|
|
2406 |
56a5a0ab
|
jim-p
|
function upgrade_064_to_065() {
|
2407 |
|
|
/* Disable TSO and LRO in upgraded configs */
|
2408 |
|
|
global $config;
|
2409 |
|
|
$config['system']['disablesegmentationoffloading'] = true;
|
2410 |
|
|
$config['system']['disablelargereceiveoffloading'] = true;
|
2411 |
|
|
}
|
2412 |
|
|
|
2413 |
2f06cc3f
|
Ermal
|
function upgrade_065_to_066() {
|
2414 |
|
|
global $config;
|
2415 |
|
|
|
2416 |
|
|
$dhcrelaycfg =& $config['dhcrelay'];
|
2417 |
|
|
|
2418 |
|
|
if (is_array($dhcrelaycfg)) {
|
2419 |
|
|
$dhcrelayifs = array();
|
2420 |
|
|
$foundifs = false;
|
2421 |
|
|
/* DHCPRelay enabled on any interfaces? */
|
2422 |
|
|
foreach ($dhcrelaycfg as $dhcrelayif => $dhcrelayifconf) {
|
2423 |
|
|
if (isset($dhcrelayifconf['enable'])) {
|
2424 |
|
|
$dhcrelayifs[] = $dhcrelayif;
|
2425 |
|
|
unset($dhcrelaycfg['dhcrelayif']);
|
2426 |
|
|
$foundifs = true;
|
2427 |
|
|
}
|
2428 |
|
|
}
|
2429 |
|
|
if ($foundifs == true)
|
2430 |
|
|
$dhcrelaycfg['interface'] = implode(",", $dhcrelayifs);
|
2431 |
|
|
}
|
2432 |
|
|
}
|
2433 |
|
|
|
2434 |
9ad72e5e
|
jim-p
|
function upgrade_066_to_067() {
|
2435 |
|
|
global $config;
|
2436 |
|
|
if (isset($config['system']['ca'])) {
|
2437 |
|
|
$config['ca'] = $config['system']['ca'];
|
2438 |
|
|
}
|
2439 |
|
|
if (isset($config['system']['cert'])) {
|
2440 |
|
|
$config['cert'] = $config['system']['cert'];
|
2441 |
|
|
}
|
2442 |
|
|
}
|
2443 |
|
|
|
2444 |
6ae9f9b7
|
Ermal
|
function upgrade_067_to_068() {
|
2445 |
|
|
global $config;
|
2446 |
|
|
|
2447 |
|
|
if (!empty($config['pppoe'])) {
|
2448 |
|
|
$config['pppoes'] = array();
|
2449 |
|
|
$config['pppoes']['pppoe'] = array();
|
2450 |
|
|
$config['pppoes']['pppoe'][] = $config['pppoe'][0];
|
2451 |
ce968051
|
Ermal
|
|
2452 |
|
|
if (is_array($config['pppoe']['user'])) {
|
2453 |
|
|
$username = array();
|
2454 |
|
|
foreach ($config['pppoe']['user'] as $user) {
|
2455 |
2fc29020
|
Ermal
|
$usr = $user['name'] . ":" . base64_encode($user['password']);
|
2456 |
ce968051
|
Ermal
|
if ($user['ip'])
|
2457 |
|
|
$usr .= ":{$user['ip']}";
|
2458 |
|
|
$username[] = $usr;
|
2459 |
|
|
}
|
2460 |
|
|
$config['pppoes']['pppoe'][0]['username'] = implode(" ", $username);
|
2461 |
|
|
}
|
2462 |
6ae9f9b7
|
Ermal
|
unset($config['pppoe']);
|
2463 |
|
|
}
|
2464 |
|
|
}
|
2465 |
|
|
|
2466 |
18de0728
|
Ermal
|
function upgrade_068_to_069() {
|
2467 |
8fefb9dd
|
jim-p
|
global $config;
|
2468 |
|
|
if (!is_array($config['system']['user']))
|
2469 |
|
|
return;
|
2470 |
|
|
foreach ($config['system']['user'] as & $user) {
|
2471 |
|
|
if (!is_array($user['cert']))
|
2472 |
|
|
continue;
|
2473 |
|
|
$rids = array();
|
2474 |
|
|
foreach ($user['cert'] as $id => $cert) {
|
2475 |
f2a86ca9
|
jim-p
|
if (!isset($cert['descr']))
|
2476 |
8fefb9dd
|
jim-p
|
continue;
|
2477 |
|
|
$tcert = $cert;
|
2478 |
|
|
// Make sure each cert gets a refid
|
2479 |
|
|
if (!isset($tcert['refid']))
|
2480 |
|
|
$tcert['refid'] = uniqid();
|
2481 |
|
|
// Keep the cert references for this user
|
2482 |
|
|
$rids[] = $tcert['refid'];
|
2483 |
|
|
$config['cert'][] = $tcert;
|
2484 |
|
|
}
|
2485 |
|
|
// Replace user certs with cert references instead.
|
2486 |
|
|
if (count($rids) > 0)
|
2487 |
|
|
$user['cert'] = $rids;
|
2488 |
|
|
}
|
2489 |
|
|
}
|
2490 |
|
|
|
2491 |
4c5b8653
|
Erik Fonnesbeck
|
function upgrade_069_to_070() {
|
2492 |
|
|
global $config;
|
2493 |
|
|
|
2494 |
|
|
/* Convert NAT 1:1 rules */
|
2495 |
|
|
if (is_array($config['nat']['onetoone'])) {
|
2496 |
a3bac4ce
|
Ermal
|
foreach ($config['nat']['onetoone'] as $nidx => $natent) {
|
2497 |
4c5b8653
|
Erik Fonnesbeck
|
if ($natent['subnet'] == 32)
|
2498 |
a3bac4ce
|
Ermal
|
$config['nat']['onetoone'][$nidx]['source'] = array("address" => $natent['internal']);
|
2499 |
4c5b8653
|
Erik Fonnesbeck
|
else
|
2500 |
a3bac4ce
|
Ermal
|
$config['nat']['onetoone'][$nidx]['source'] = array("address" => $natent['internal'] . "/" . $natent['subnet']);
|
2501 |
4c5b8653
|
Erik Fonnesbeck
|
|
2502 |
a3bac4ce
|
Ermal
|
$config['nat']['onetoone'][$nidx]['destination'] = array("any" => true);
|
2503 |
4c5b8653
|
Erik Fonnesbeck
|
|
2504 |
a3bac4ce
|
Ermal
|
unset($config['nat']['onetoone'][$nidx]['internal']);
|
2505 |
|
|
unset($config['nat']['onetoone'][$nidx]['subnet']);
|
2506 |
4c5b8653
|
Erik Fonnesbeck
|
}
|
2507 |
|
|
|
2508 |
|
|
unset($natent);
|
2509 |
|
|
}
|
2510 |
|
|
}
|
2511 |
|
|
|
2512 |
65167fcc
|
Ermal
|
function upgrade_070_to_071() {
|
2513 |
|
|
global $config;
|
2514 |
|
|
|
2515 |
|
|
if (is_array($config['cron']['item'])) {
|
2516 |
|
|
foreach($config['cron']['item'] as $idx => $cronitem) {
|
2517 |
f21c7979
|
Ermal
|
if(stristr($cronitem['command'], "checkreload.sh")) {
|
2518 |
65167fcc
|
Ermal
|
unset($config['cron']['item'][$idx]);
|
2519 |
|
|
break;
|
2520 |
|
|
}
|
2521 |
|
|
}
|
2522 |
|
|
}
|
2523 |
|
|
}
|
2524 |
15864861
|
jim-p
|
|
2525 |
6751b3e7
|
jim-p
|
function rename_field(& $section, $oldname, $newname) {
|
2526 |
e988813d
|
jim-p
|
if (is_array($section)) {
|
2527 |
|
|
foreach($section as & $item) {
|
2528 |
5962f766
|
jim-p
|
if (is_array($item) && !empty($item[$oldname]))
|
2529 |
6751b3e7
|
jim-p
|
$item[$newname] = $item[$oldname];
|
2530 |
5962f766
|
jim-p
|
if (is_array($item) && isset($item[$oldname]))
|
2531 |
6751b3e7
|
jim-p
|
unset($item[$oldname]);
|
2532 |
e988813d
|
jim-p
|
}
|
2533 |
|
|
}
|
2534 |
|
|
}
|
2535 |
|
|
|
2536 |
6751b3e7
|
jim-p
|
function upgrade_071_to_072() {
|
2537 |
|
|
global $config;
|
2538 |
6bef0554
|
jim-p
|
if (is_array($config['sysctl']) && is_array($config['sysctl']['item']))
|
2539 |
|
|
rename_field($config['sysctl']['item'], 'desc', 'descr');
|
2540 |
6751b3e7
|
jim-p
|
}
|
2541 |
|
|
|
2542 |
e988813d
|
jim-p
|
function upgrade_072_to_073() {
|
2543 |
|
|
global $config;
|
2544 |
6bef0554
|
jim-p
|
if (!is_array($config['load_balancer']))
|
2545 |
|
|
return;
|
2546 |
|
|
if (is_array($config['load_balancer']['monitor_type']))
|
2547 |
|
|
rename_field($config['load_balancer']['monitor_type'], 'desc', 'descr');
|
2548 |
|
|
if (is_array($config['load_balancer']['lbpool']))
|
2549 |
|
|
rename_field($config['load_balancer']['lbpool'], 'desc', 'descr');
|
2550 |
|
|
if (is_array($config['load_balancer']['lbaction']))
|
2551 |
|
|
rename_field($config['load_balancer']['lbaction'], 'desc', 'descr');
|
2552 |
|
|
if (is_array($config['load_balancer']['lbprotocol']))
|
2553 |
|
|
rename_field($config['load_balancer']['lbprotocol'], 'desc', 'descr');
|
2554 |
|
|
if (is_array($config['load_balancer']['virtual_server']))
|
2555 |
|
|
rename_field($config['load_balancer']['virtual_server'], 'desc', 'descr');
|
2556 |
e988813d
|
jim-p
|
}
|
2557 |
9ff73b79
|
jim-p
|
|
2558 |
|
|
function upgrade_073_to_074() {
|
2559 |
|
|
global $config;
|
2560 |
6751b3e7
|
jim-p
|
rename_field($config['system']['user'], 'fullname', 'descr');
|
2561 |
9ff73b79
|
jim-p
|
}
|
2562 |
f2a86ca9
|
jim-p
|
|
2563 |
|
|
function upgrade_074_to_075() {
|
2564 |
|
|
global $config;
|
2565 |
6bef0554
|
jim-p
|
if (is_array($config['ca']))
|
2566 |
|
|
rename_field($config['ca'], 'name', 'descr');
|
2567 |
|
|
if (is_array($config['cert']))
|
2568 |
|
|
rename_field($config['cert'], 'name', 'descr');
|
2569 |
|
|
if (is_array($config['crl']))
|
2570 |
|
|
rename_field($config['crl'], 'name', 'descr');
|
2571 |
f2a86ca9
|
jim-p
|
}
|
2572 |
9734b054
|
Scott Ullrich
|
|
2573 |
d0dc2fd1
|
jim-p
|
function upgrade_075_to_076() {
|
2574 |
7d9b3d5e
|
jim-p
|
global $config;
|
2575 |
|
|
$cron_item = array();
|
2576 |
|
|
$cron_item['minute'] = "30";
|
2577 |
|
|
$cron_item['hour'] = "12";
|
2578 |
|
|
$cron_item['mday'] = "*";
|
2579 |
|
|
$cron_item['month'] = "*";
|
2580 |
|
|
$cron_item['wday'] = "*";
|
2581 |
|
|
$cron_item['who'] = "root";
|
2582 |
|
|
$cron_item['command'] = "/usr/bin/nice -n20 /etc/rc.update_urltables";
|
2583 |
|
|
$config['cron']['item'][] = $cron_item;
|
2584 |
d0dc2fd1
|
jim-p
|
}
|
2585 |
|
|
|
2586 |
9bc8b6b6
|
Seth Mos
|
function upgrade_076_to_077() {
|
2587 |
9956b38a
|
Seth Mos
|
global $config;
|
2588 |
|
|
foreach($config['filter']['rule'] as & $rule) {
|
2589 |
|
|
if (isset($rule['protocol']) && !empty($rule['protocol']))
|
2590 |
|
|
$rule['protocol'] = strtolower($rule['protocol']);
|
2591 |
|
|
}
|
2592 |
|
|
}
|
2593 |
|
|
|
2594 |
|
|
function upgrade_077_to_078() {
|
2595 |
f33030aa
|
jim-p
|
global $config;
|
2596 |
7171b7b6
|
jim-p
|
if (is_array($config['pptpd']) && is_array($config['pptpd']['radius'])
|
2597 |
|
|
&& !is_array($config['pptpd']['radius']['server'])) {
|
2598 |
|
|
$radarr = array();
|
2599 |
|
|
$radsvr = array();
|
2600 |
|
|
$radsvr['ip'] = $config['pptpd']['radius']['server'];
|
2601 |
|
|
$radsvr['secret'] = $config['pptpd']['radius']['secret'];
|
2602 |
|
|
$radsvr['port'] = 1812;
|
2603 |
|
|
$radsvr['acctport'] = 1813;
|
2604 |
|
|
$radsvr['enable'] = isset($config['pptpd']['radius']['enable']);
|
2605 |
|
|
$radarr['accounting'] = isset($config['pptpd']['radius']['accounting']);
|
2606 |
|
|
if ($radarr['accounting'])
|
2607 |
|
|
$radarr['acct_update'] = $radsvr['ip'];
|
2608 |
|
|
$radarr['server'] = $radsvr;
|
2609 |
|
|
$config['pptpd']['radius'] = $radarr;
|
2610 |
|
|
}
|
2611 |
|
|
}
|
2612 |
27d0722d
|
jim-p
|
function upgrade_078_to_079() {
|
2613 |
838e4eb8
|
Warren Baker
|
global $g;
|
2614 |
5c723d9f
|
Warren Baker
|
/* Delete old and unused RRD file */
|
2615 |
838e4eb8
|
Warren Baker
|
unlink_if_exists("{$g['vardb_path']}/rrd/captiveportal-totalusers.rrd");
|
2616 |
5c723d9f
|
Warren Baker
|
}
|
2617 |
|
|
|
2618 |
58005e52
|
jim-p
|
function upgrade_079_to_080() {
|
2619 |
9bc8b6b6
|
Seth Mos
|
global $config;
|
2620 |
e6ee8fc6
|
Ermal
|
|
2621 |
|
|
/* Upgrade config in 1.2.3 specifying a username other than admin for synching. */
|
2622 |
|
|
if (!empty($config['system']['username']) && is_array($config['installedpackages']['carpsettings']) &&
|
2623 |
|
|
is_array($config['installedpackages']['carpsettings']['config'])) {
|
2624 |
|
|
$config['installedpackages']['carpsettings']['config'][0]['username'] = $config['system']['username'];
|
2625 |
|
|
unset($config['system']['username']);
|
2626 |
|
|
}
|
2627 |
|
|
}
|
2628 |
|
|
|
2629 |
e49d4564
|
jim-p
|
function upgrade_080_to_081() {
|
2630 |
|
|
global $config;
|
2631 |
9bc8b6b6
|
Seth Mos
|
global $g;
|
2632 |
|
|
|
2633 |
|
|
/* RRD files changed for quality, traffic and packets graphs */
|
2634 |
|
|
/* convert traffic RRD file */
|
2635 |
|
|
global $parsedcfg, $listtags;
|
2636 |
|
|
$listtags = array("ds", "v", "rra", "row");
|
2637 |
|
|
|
2638 |
|
|
$rrddbpath = "/var/db/rrd/";
|
2639 |
|
|
$rrdtool = "/usr/bin/nice -n20 /usr/local/bin/rrdtool";
|
2640 |
|
|
|
2641 |
|
|
$rrdinterval = 60;
|
2642 |
|
|
$valid = $rrdinterval * 2;
|
2643 |
|
|
|
2644 |
|
|
/* Asume GigE for now */
|
2645 |
|
|
$downstream = 125000000;
|
2646 |
|
|
$upstream = 125000000;
|
2647 |
|
|
|
2648 |
|
|
/* build a list of traffic and packets databases */
|
2649 |
|
|
$databases = array();
|
2650 |
|
|
exec("cd $rrddbpath;/usr/bin/find *-traffic.rrd *-packets.rrd", $databases);
|
2651 |
|
|
rsort($databases);
|
2652 |
|
|
foreach($databases as $database) {
|
2653 |
|
|
$databasetmp = "{$database}.tmp";
|
2654 |
|
|
$xmldump = "{$database}.old.xml";
|
2655 |
|
|
$xmldumptmp = "{$database}.tmp.xml";
|
2656 |
|
|
$xmldumpnew = "{$database}.new.xml";
|
2657 |
|
|
|
2658 |
|
|
if ($g['booting'])
|
2659 |
d55ea970
|
Seth Mos
|
echo "Migrate RRD database {$database} to new format for IPv6.\n";
|
2660 |
9bc8b6b6
|
Seth Mos
|
|
2661 |
|
|
/* dump contents to xml and move database out of the way */
|
2662 |
|
|
dump_rrd_to_xml("{$rrddbpath}/{$database}", "{$g['tmp_path']}/{$xmldump}");
|
2663 |
|
|
|
2664 |
|
|
/* create new rrd database file */
|
2665 |
|
|
$rrdcreate = "$rrdtool create {$g['tmp_path']}/{$databasetmp} --step $rrdinterval ";
|
2666 |
|
|
$rrdcreate .= "DS:inpass:COUNTER:$valid:0:$downstream ";
|
2667 |
|
|
$rrdcreate .= "DS:outpass:COUNTER:$valid:0:$upstream ";
|
2668 |
|
|
$rrdcreate .= "DS:inblock:COUNTER:$valid:0:$downstream ";
|
2669 |
|
|
$rrdcreate .= "DS:outblock:COUNTER:$valid:0:$upstream ";
|
2670 |
|
|
$rrdcreate .= "DS:inpass6:COUNTER:$valid:0:$downstream ";
|
2671 |
|
|
$rrdcreate .= "DS:outpass6:COUNTER:$valid:0:$upstream ";
|
2672 |
|
|
$rrdcreate .= "DS:inblock6:COUNTER:$valid:0:$downstream ";
|
2673 |
|
|
$rrdcreate .= "DS:outblock6:COUNTER:$valid:0:$upstream ";
|
2674 |
|
|
$rrdcreate .= "RRA:AVERAGE:0.5:1:1000 ";
|
2675 |
|
|
$rrdcreate .= "RRA:AVERAGE:0.5:5:1000 ";
|
2676 |
|
|
$rrdcreate .= "RRA:AVERAGE:0.5:60:1000 ";
|
2677 |
|
|
$rrdcreate .= "RRA:AVERAGE:0.5:720:3000 ";
|
2678 |
|
|
|
2679 |
|
|
create_new_rrd("$rrdcreate");
|
2680 |
|
|
/* create temporary xml from new RRD */
|
2681 |
|
|
dump_rrd_to_xml("{$g['tmp_path']}/{$databasetmp}", "{$g['tmp_path']}/{$xmldumptmp}");
|
2682 |
|
|
|
2683 |
d6425f75
|
smos
|
$rrdold = xml2array(file_get_contents("{$g['tmp_path']}/{$xmldump}"), 1, "tag");
|
2684 |
9bc8b6b6
|
Seth Mos
|
$rrdold = $rrdold['rrd'];
|
2685 |
|
|
|
2686 |
d6425f75
|
smos
|
$rrdnew = xml2array(file_get_contents("{$g['tmp_path']}/{$xmldumptmp}"), 1, "tag");
|
2687 |
9bc8b6b6
|
Seth Mos
|
$rrdnew = $rrdnew['rrd'];
|
2688 |
|
|
|
2689 |
|
|
/* remove any MAX RRA's. Not needed for traffic. */
|
2690 |
|
|
$i = 0;
|
2691 |
|
|
foreach ($rrdold['rra'] as $rra) {
|
2692 |
|
|
if(trim($rra['cf']) == "MAX") {
|
2693 |
|
|
unset($rrdold['rra'][$i]);
|
2694 |
|
|
}
|
2695 |
|
|
$i++;
|
2696 |
|
|
}
|
2697 |
|
|
|
2698 |
ca320457
|
smos
|
file_put_contents("{$g['tmp_path']}/{$xmldumpnew}", dump_xml_config_raw(migrate_rrd_format($rrdold, $rrdnew), "rrd"));
|
2699 |
9bc8b6b6
|
Seth Mos
|
mwexec("$rrdtool restore -f {$g['tmp_path']}/{$xmldumpnew} {$rrddbpath}/{$database} 2>&1");
|
2700 |
|
|
|
2701 |
|
|
}
|
2702 |
|
|
enable_rrd_graphing();
|
2703 |
|
|
if ($g['booting'])
|
2704 |
|
|
echo "Updating configuration...";
|
2705 |
7ec0e6e2
|
jim-p
|
foreach($config['filter']['rule'] as & $rule) {
|
2706 |
1c1a74fa
|
jim-p
|
if (isset($rule['protocol']) && !empty($rule['protocol']))
|
2707 |
|
|
$rule['protocol'] = strtolower($rule['protocol']);
|
2708 |
7ec0e6e2
|
jim-p
|
}
|
2709 |
9bc8b6b6
|
Seth Mos
|
}
|
2710 |
|
|
|
2711 |
e49d4564
|
jim-p
|
function upgrade_081_to_082() {
|
2712 |
7b47bd4c
|
Ermal
|
global $config, $g;
|
2713 |
1f116988
|
Seth Mos
|
/* enable the allow IPv6 toggle */
|
2714 |
|
|
$config['system']['ipv6allow'] = true;
|
2715 |
7b47bd4c
|
Ermal
|
|
2716 |
|
|
/* XXX: Gross hacks in sight */
|
2717 |
|
|
write_config();
|
2718 |
|
|
if (is_array($config['virtualips']['vip'])) {
|
2719 |
|
|
$vipchg = array();
|
2720 |
|
|
foreach ($config['virtualips']['vip'] as $vip) {
|
2721 |
617244c7
|
Ermal
|
file_put_contents("{$g['tmp_path']}/vipreplace", "s/vip{$vip['vhid']}/{$vip['interface']}_vip{$vip['vhid']}/g\n");
|
2722 |
7b47bd4c
|
Ermal
|
}
|
2723 |
35b71459
|
Ermal
|
mwexec("/usr/bin/sed -I \"\" -f {$g['tmp_path']}/vipreplace /conf/config.xml");
|
2724 |
7b47bd4c
|
Ermal
|
require_once("config.lib.inc");
|
2725 |
|
|
$config = parse_config(true);
|
2726 |
|
|
}
|
2727 |
1f116988
|
Seth Mos
|
}
|
2728 |
b4792bf8
|
Ermal
|
|
2729 |
|
|
function upgrade_082_to_083() {
|
2730 |
|
|
global $config;
|
2731 |
7b47bd4c
|
Ermal
|
|
2732 |
|
|
/* enable the allow IPv6 toggle if coming from 2.0.x where x > 1 */
|
2733 |
|
|
$config['system']['ipv6allow'] = true;
|
2734 |
|
|
|
2735 |
b4792bf8
|
Ermal
|
/* Upgrade captiveportal config */
|
2736 |
|
|
if (!empty($config['captiveportal'])) {
|
2737 |
|
|
$tmpcp = $config['captiveportal'];
|
2738 |
|
|
$config['captiveportal'] = array();
|
2739 |
|
|
$config['captiveportal']['cpZone'] = array();
|
2740 |
|
|
$config['captiveportal']['cpZone'] = $tmpcp;
|
2741 |
|
|
$config['captiveportal']['cpZone']['zoneid'] = 8000;
|
2742 |
|
|
}
|
2743 |
67e73dcd
|
Ermal
|
if (!empty($config['voucher'])) {
|
2744 |
|
|
$tmpcp = $config['voucher'];
|
2745 |
|
|
$config['voucher'] = array();
|
2746 |
|
|
$config['voucher']['cpZone'] = array();
|
2747 |
|
|
$config['voucher']['cpZone'] = $tmpcp;
|
2748 |
|
|
}
|
2749 |
b4792bf8
|
Ermal
|
}
|
2750 |
67e73dcd
|
Ermal
|
|
2751 |
f97a5b04
|
Darren Embry
|
function upgrade_083_to_084() {
|
2752 |
|
|
global $config;
|
2753 |
|
|
if (!isset($config['hasync'])) {
|
2754 |
|
|
if (!empty($config['installedpackages']) &&
|
2755 |
|
|
!empty($config['installedpackages']['carpsettings']) &&
|
2756 |
|
|
!empty($config['installedpackages']['carpsettings']['config'])) {
|
2757 |
|
|
$config['hasync'] = $config['installedpackages']['carpsettings']['config'][0];
|
2758 |
|
|
unset($config['installedpackages']['carpsettings']);
|
2759 |
|
|
}
|
2760 |
|
|
if (empty($config['installedpackages']['carpsettings'])) {
|
2761 |
|
|
unset($config['installedpackages']['carpsettings']);
|
2762 |
|
|
}
|
2763 |
|
|
if (empty($config['installedpackages'])) {
|
2764 |
|
|
unset($config['installedpackages']);
|
2765 |
|
|
}
|
2766 |
|
|
}
|
2767 |
|
|
}
|
2768 |
|
|
|
2769 |
c3ce2ece
|
smos
|
function upgrade_084_to_085() {
|
2770 |
|
|
global $config;
|
2771 |
|
|
|
2772 |
|
|
$gateway_group_arr = array();
|
2773 |
|
|
$gateways = return_gateways_array();
|
2774 |
|
|
$oldnames = array();
|
2775 |
|
|
/* setup translation array */
|
2776 |
|
|
foreach($gateways as $name => $gw) {
|
2777 |
|
|
if(isset($gw['dynamic'])){
|
2778 |
|
|
$oldname = strtoupper($config['interfaces'][$gw['friendlyiface']]['descr']);
|
2779 |
|
|
$oldnames[$oldname] = $name;
|
2780 |
|
|
} else {
|
2781 |
|
|
$oldnames[$name] = $name;
|
2782 |
|
|
}
|
2783 |
|
|
}
|
2784 |
|
|
|
2785 |
|
|
/* process the old array */
|
2786 |
|
|
if(is_array($config['gateways']['gateway_group'])) {
|
2787 |
|
|
$group_array_new = array();
|
2788 |
|
|
foreach($config['gateways']['gateway_group'] as $name => $group) {
|
2789 |
|
|
if(is_array($group['item'])) {
|
2790 |
|
|
$newlist = array();
|
2791 |
|
|
foreach($group['item'] as $entry) {
|
2792 |
|
|
$elements = explode("|", $entry);
|
2793 |
|
|
if($oldnames[$elements[0]] <> "") {
|
2794 |
|
|
$newlist[] = "{$oldnames[$elements[0]]}|{$elements[1]}";
|
2795 |
da12a8a4
|
smos
|
} else {
|
2796 |
|
|
$newlist[] = "{$elements[0]}|{$elements[1]}";
|
2797 |
c3ce2ece
|
smos
|
}
|
2798 |
|
|
}
|
2799 |
|
|
$group['item'] = $newlist;
|
2800 |
|
|
$group_array_new[$name] = $group;
|
2801 |
|
|
}
|
2802 |
|
|
}
|
2803 |
|
|
$config['gateways']['gateway_group'] = $group_array_new;
|
2804 |
|
|
}
|
2805 |
|
|
}
|
2806 |
|
|
|
2807 |
1916d34a
|
Ermal
|
?>
|