Project

General

Profile

Download (106 KB) Statistics
| Branch: | Tag: | Revision:
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 2d563280 Renato Botelho
if(!function_exists("dump_rrd_to_xml"))
38 901aa044 Scott Ullrich
	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 879f7db7 Erik Fonnesbeck
	global $config, $g;
579 791bcfd4 Bill Marquette
	$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 2d563280 Renato Botelho
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 2d563280 Renato Botelho
			$config['gateways']['gateway_item'][$i]['defaultgw'] = true;
752 2328dcc5 Seth Mos
		}
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 2d563280 Renato Botelho
			}
804
805 a842e988 Ermal
			if ($found == false) {
806
				$gateway = array();
807 323f3f9c smos
				$gateway['name'] = "SROUTE{$i}";
808
				$gwmap[$sroute['gateway']] = $gateway['name'];
809 a842e988 Ermal
				$gateway['gateway'] = $sroute['gateway'];
810
				$gateway['interface'] = $sroute['interface'];
811 4d511e5b Renato Botelho
				$gateway['descr'] = sprintf(gettext("Upgraded static route for %s"), $sroute['network']);
812 a842e988 Ermal
				if (!is_array($config['gateways']['gateway_item']))
813
					$config['gateways']['gateway_item'] = array();
814
				$config['gateways']['gateway_item'][] = $gateway;
815
				$config['staticroutes']['route'][$idx]['gateway'] = $gateway['name'];
816 6cae2c44 Ermal
				$i++;
817 a842e988 Ermal
			}
818
		}
819
	}
820 791bcfd4 Bill Marquette
}
821
822
823
function upgrade_044_to_045() {
824
	global $config;
825 da74e673 Seth Mos
	$iflist = get_configured_interface_list(false, true);
826 791bcfd4 Bill Marquette
	if (is_array($config['vlans']['vlan']) && count($config['vlans']['vlan'])) {
827 3d039701 smos
		$i = 0;
828 da74e673 Seth Mos
		foreach ($config['vlans']['vlan'] as $id => $vlan) {
829
			/* Make sure to update the interfaces section with the right name */
830 62958eae smos
			$vlan_name = "{$vlan['if']}_vlan{$vlan['tag']}";
831 da74e673 Seth Mos
			foreach($iflist as $ifname) {
832 3d039701 smos
				if($config['interfaces'][$ifname]['if'] == "vlan{$i}") {
833 62958eae smos
					$config['interfaces'][$ifname]['if'] = $vlan_name;
834
					continue;
835 da74e673 Seth Mos
				}
836
			}
837 62958eae smos
			$config['vlans']['vlan'][$i]['vlanif'] = "{$vlan_name}";
838 2d563280 Renato Botelho
			$i++;
839 da74e673 Seth Mos
		}
840 791bcfd4 Bill Marquette
	}
841
}
842
843
844
function upgrade_045_to_046() {
845
	global $config;
846 2d563280 Renato Botelho
	/* Load up monitors that are in the default config for 2.0 but not in 1.2.3
847 506514e7 jim-p
		thus wouldn't be in an upgraded config. */
848
	$config['load_balancer']['monitor_type'] = array (
849
		array ( 'name' => 'ICMP',
850
			'type' => 'icmp',
851
			'descr' => 'ICMP',
852
			'options' => '',
853
		),
854
		array ( 'name' => 'TCP',
855
			'type' => 'tcp',
856
			'descr' => 'Generic TCP',
857
			'options' => '',
858
		),
859
		array ( 'name' => 'HTTP',
860
			'type' => 'http',
861
			'descr' => 'Generic HTTP',
862
			'options' =>
863
			array ( 'path' => '/',
864
				'host' => '',
865
				'code' => '200',
866
			),
867
		),
868
		array ( 'name' => 'HTTPS',
869
			'type' => 'https',
870
			'descr' => 'Generic HTTPS',
871
			'options' =>
872
			array ( 'path' => '/',
873
				'host' => '',
874
				'code' => '200',
875
			),
876
		),
877
		array ( 'name' => 'SMTP',
878
			'type' => 'send',
879
			'descr' => 'Generic SMTP',
880
			'options' =>
881 520d4137 jim-p
			array ( 'send' => '',
882
				'expect' => '220 *',
883 506514e7 jim-p
			),
884
		),
885
	);
886 791bcfd4 Bill Marquette
	/* Upgrade load balancer from slb to relayd */
887
	if (is_array($config['load_balancer']['virtual_server']) && count($config['load_balancer']['virtual_server'])) {
888
		$vs_a = &$config['load_balancer']['virtual_server'];
889
		$pool_a = &$config['load_balancer']['lbpool'];
890
		$pools = array();
891 25753b5b sullrich
		/* Index pools by name */
892 791bcfd4 Bill Marquette
		if(is_array($pool_a)) {
893
			for ($i = 0; isset($pool_a[$i]); $i++) {
894 cb945ced sullrich
				if($pool_a[$i]['type'] == "server") {
895 791bcfd4 Bill Marquette
					$pools[$pool_a[$i]['name']] = $pool_a[$i];
896
				}
897
			}
898
		}
899
		/* Convert sitedown entries to pools and re-attach */
900
		for ($i = 0; isset($vs_a[$i]); $i++) {
901 d30afa60 jim-p
			/* Set mode while we're here. */
902
			$vs_a[$i]['mode'] = "redirect_mode";
903 791bcfd4 Bill Marquette
			if (isset($vs_a[$i]['sitedown'])) {
904
				$pool = array();
905
				$pool['type'] = 'server';
906
				$pool['behaviour'] = 'balance';
907
				$pool['name'] = "{$vs_a[$i]['name']}-sitedown";
908 4816e5ca Renato Botelho
				$pool['descr'] = sprintf(gettext("Sitedown pool for VS: %s"), $vs_a[$i]['name']);
909 6e9b046e jim-p
				if (is_array($vs_a[$i]['pool']))
910
					$vs_a[$i]['pool'] = $vs_a[$i]['pool'][0];
911 791bcfd4 Bill Marquette
				$pool['port'] = $pools[$vs_a[$i]['pool']]['port'];
912
				$pool['servers'] = array();
913
				$pool['servers'][] = $vs_a[$i]['sitedown'];
914
				$pool['monitor'] = $pools[$vs_a[$i]['pool']]['monitor'];
915
				$pool_a[] = $pool;
916
				$vs_a[$i]['sitedown'] = $pool['name'];
917
			}
918
		}
919
	}
920 0b5b4f32 Seth Mos
	if(count($config['load_balancer']) == 0) {
921
		unset($config['load_balancer']);
922
	}
923 a09d8bfc jim-p
	mwexec('/usr/sbin/pw groupadd -n _relayd -g 913');
924
	mwexec('/usr/sbin/pw useradd -n _relayd -c "Relay Daemon" -d /var/empty -s /usr/sbin/nologin -u 913 -g 913');
925 791bcfd4 Bill Marquette
}
926
927
928
function upgrade_046_to_047() {
929
	global $config;
930
	/* Upgrade IPsec from tunnel to phase1/phase2 */
931
932
	if(is_array($config['ipsec']['tunnel'])) {
933
934
		$a_phase1 = array();
935
		$a_phase2 = array();
936
		$ikeid = 0;
937
938
		foreach ($config['ipsec']['tunnel'] as $tunnel) {
939
940
			unset($ph1ent);
941
			unset($ph2ent);
942
943
			/*
944
				*  attempt to locate an enabled phase1
945
				*  entry that matches the peer gateway
946
				*/
947
948
			if (!isset($tunnel['disabled'])) {
949
950
				$remote_gateway = $tunnel['remote-gateway'];
951
952
				foreach ($a_phase1 as $ph1tmp) {
953
					if ($ph1tmp['remote-gateway'] == $remote_gateway) {
954
						$ph1ent = $ph1tmp;
955
						break;
956
					}
957
				}
958
			}
959
960
			/* none found, create a new one */
961
962
			if (!isset( $ph1ent )) {
963
964
				/* build new phase1 entry */
965
966
				$ph1ent = array();
967
968
				$ph1ent['ikeid'] = ++$ikeid;
969
970
				if (isset($tunnel['disabled']))
971
					$ph1ent['disabled'] = $tunnel['disabled'];
972
973 443f2e6e smos
				/* convert to the new vip[$vhid] name */
974
				if(preg_match("/^carp/", $tunnel['interface'])) {
975 bc75a430 smos
					$carpid = str_replace("carp", "", $tunnel['interface']);
976 4aa58d46 smos
					$tunnel['interface'] = "vip" . $config['virtualip']['vip'][$carpid]['vhid'];
977 443f2e6e smos
				}
978 791bcfd4 Bill Marquette
				$ph1ent['interface'] = $tunnel['interface'];
979
				$ph1ent['remote-gateway'] = $tunnel['remote-gateway'];
980
				$ph1ent['descr'] = $tunnel['descr'];
981
982
				$ph1ent['mode'] = $tunnel['p1']['mode'];
983
984
				if (isset($tunnel['p1']['myident']['myaddress']))
985
					$ph1ent['myid_type'] = "myaddress";
986
				if (isset($tunnel['p1']['myident']['address'])) {
987
					$ph1ent['myid_type'] = "address";
988
					$ph1ent['myid_data'] = $tunnel['p1']['myident']['address'];
989
				}
990
				if (isset($tunnel['p1']['myident']['fqdn'])) {
991
					$ph1ent['myid_type'] = "fqdn";
992
					$ph1ent['myid_data'] = $tunnel['p1']['myident']['fqdn'];
993
				}
994 dfa11031 jim-p
				if (isset($tunnel['p1']['myident']['ufqdn'])) {
995 791bcfd4 Bill Marquette
					$ph1ent['myid_type'] = "user_fqdn";
996 dfa11031 jim-p
					$ph1ent['myid_data'] = $tunnel['p1']['myident']['ufqdn'];
997 791bcfd4 Bill Marquette
				}
998
				if (isset($tunnel['p1']['myident']['asn1dn'])) {
999
					$ph1ent['myid_type'] = "asn1dn";
1000
					$ph1ent['myid_data'] = $tunnel['p1']['myident']['asn1dn'];
1001
				}
1002
				if (isset($tunnel['p1']['myident']['dyn_dns'])) {
1003
					$ph1ent['myid_type'] = "dyn_dns";
1004
					$ph1ent['myid_data'] = $tunnel['p1']['myident']['dyn_dns'];
1005
				}
1006
1007
				$ph1ent['peerid_type'] = "peeraddress";
1008
1009
				switch ($tunnel['p1']['encryption-algorithm']) {
1010
					case "des":
1011
					$ph1alg = array( 'name' => 'des' );
1012
					break;
1013
					case "3des":
1014
					$ph1alg = array( 'name' => '3des' );
1015
					break;
1016
					case "blowfish":
1017
					$ph1alg = array( 'name' => 'blowfish', 'keylen' => '128'  );
1018
					break;
1019
					case "cast128":
1020
					$ph1alg = array( 'name' => 'cast128' );
1021
					break;
1022
					case "rijndael":
1023
					$ph1alg = array( 'name' => 'aes', 'keylen' => '128' );
1024
					break;
1025
					case "rijndael 256":
1026 a5187d43 jim-p
					case "aes 256":
1027 791bcfd4 Bill Marquette
					$ph1alg = array( 'name' => 'aes', 'keylen' => '256' );
1028
					break;
1029
				}
1030
1031
				$ph1ent['encryption-algorithm'] = $ph1alg;
1032
				$ph1ent['hash-algorithm'] = $tunnel['p1']['hash-algorithm'];
1033
				$ph1ent['dhgroup'] = $tunnel['p1']['dhgroup'];
1034
				$ph1ent['lifetime'] = $tunnel['p1']['lifetime'];
1035
				$ph1ent['authentication_method'] = $tunnel['p1']['authentication_method'];
1036
1037
				if (isset($tunnel['p1']['pre-shared-key']))
1038
					$ph1ent['pre-shared-key'] = $tunnel['p1']['pre-shared-key'];
1039
				if (isset($tunnel['p1']['cert']))
1040
					$ph1ent['cert'] = $tunnel['p1']['cert'];
1041
				if (isset($tunnel['p1']['peercert']))
1042
					$ph1ent['peercert'] = $tunnel['p1']['peercert'];
1043
				if (isset($tunnel['p1']['private-key']))
1044
					$ph1ent['private-key'] = $tunnel['p1']['private-key'];
1045
1046
				$ph1ent['nat_traversal'] = "on";
1047
				$ph1ent['dpd_enable'] = 1;
1048
				$ph1ent['dpd_delay'] = 10;
1049
				$ph1ent['dpd_maxfail'] = 5;
1050
1051
				$a_phase1[] = $ph1ent;
1052
			}
1053
1054
			/* build new phase2 entry */
1055
1056
			$ph2ent = array();
1057
1058
			$ph2ent['ikeid'] = $ph1ent['ikeid'];
1059
1060
			if (isset($tunnel['disabled']))
1061
				$ph1ent['disabled'] = $tunnel['disabled'];
1062
1063 4d511e5b Renato Botelho
			$ph2ent['descr'] = sprintf(gettext("phase2 for %s"), $tunnel['descr']);
1064 791bcfd4 Bill Marquette
1065
			$type = "lan";
1066
			if ($tunnel['local-subnet']['network'])
1067
				$type = $tunnel['local-subnet']['network'];
1068
			if ($tunnel['local-subnet']['address']) {
1069
				list($address,$netbits) = explode("/",$tunnel['local-subnet']['address']);
1070
				if (is_null($netbits))
1071
					$type = "address";
1072
				else
1073
					$type = "network";
1074
			}
1075
1076
			switch ($type) {
1077
				case "address":
1078
				$ph2ent['localid'] = array('type' => $type,'address' => $address);
1079
				break;
1080
				case "network":
1081
				$ph2ent['localid'] = array('type' => $type,'address' => $address,'netbits' => $netbits);
1082
				break;
1083
				default:
1084
				$ph2ent['localid'] = array('type' => $type);
1085
				break;
1086
			}
1087
1088
			list($address,$netbits) = explode("/",$tunnel['remote-subnet']);
1089
			$ph2ent['remoteid'] = array('type' => 'network','address' => $address,'netbits' => $netbits);
1090
1091
			$ph2ent['protocol'] = $tunnel['p2']['protocol'];
1092
1093
			$aes_count = 0;
1094
			foreach( $tunnel['p2']['encryption-algorithm-option'] as $tunalg ) {
1095
				$aes_found = false;
1096
				switch ($tunalg) {
1097
					case "des":
1098
					$ph2alg = array( 'name' => 'des' );
1099
					break;
1100
					case "3des":
1101
					$ph2alg = array( 'name' => '3des' );
1102
					break;
1103
					case "blowfish":
1104
					$ph2alg = array( 'name' => 'blowfish', 'keylen' => 'auto'  );
1105
					break;
1106
					case "cast128":
1107
					$ph2alg = array( 'name' => 'cast128' );
1108
					break;
1109
					case "rijndael":
1110
					case "rijndael 256":
1111 a5187d43 jim-p
					case "aes 256":
1112 791bcfd4 Bill Marquette
					$ph2alg = array( 'name' => 'aes', 'keylen' => 'auto' );
1113
					$aes_found = true;
1114
					$aes_count++;
1115
					break;
1116
				}
1117
1118
				if( !$aes_found || ($aes_count < 2))
1119
					$ph2ent['encryption-algorithm-option'][] = $ph2alg;
1120
			}
1121
1122
			$ph2ent['hash-algorithm-option'] = $tunnel['p2']['hash-algorithm-option'];
1123
			$ph2ent['pfsgroup'] = $tunnel['p2']['pfsgroup'];
1124
			$ph2ent['lifetime'] = $tunnel['p2']['lifetime'];
1125
1126 87e07f52 mgrooms
			if (isset($tunnel['pinghost']['pinghost']))
1127
				$ph2ent['pinghost'] = $tunnel['pinghost'];
1128
1129 791bcfd4 Bill Marquette
			$a_phase2[] = $ph2ent;
1130
		}
1131
1132
		unset($config['ipsec']['tunnel']);
1133
		$config['ipsec']['phase1'] = $a_phase1;
1134
		$config['ipsec']['phase2'] = $a_phase2;
1135
	}
1136 49bb5c07 jim-p
1137
	/* Upgrade Mobile IPsec */
1138
	if (isset($config['ipsec']['mobileclients'])
1139
		&& is_array($config['ipsec']['mobileclients'])
1140
		&& is_array($config['ipsec']['mobileclients']['p1'])
1141
		&& is_array($config['ipsec']['mobileclients']['p2'])) {
1142
1143
		if (isset($config['ipsec']['mobileclients']['enable'])) {
1144
			$config['ipsec']['client']['enable'] = true;
1145
			$config['ipsec']['client']['user_source'] = 'system';
1146
			$config['ipsec']['client']['group_source'] = 'system';
1147
		}
1148
1149
		$mobilecfg = $config['ipsec']['mobileclients'];
1150
1151
		$ph1ent = array();
1152
		$ph1ent['ikeid'] = ++$ikeid;
1153
1154
		if (!isset($mobilecfg['enable']))
1155
			$ph1ent['disabled'] = true;
1156
1157
		/* Assume WAN since mobile tunnels couldn't be on a separate interface on 1.2.x */
1158
		$ph1ent['interface'] = 'wan';
1159
		$ph1ent['descr'] = "Mobile Clients (upgraded)";
1160
		$ph1ent['mode'] = $mobilecfg['p1']['mode'];
1161
1162
		if (isset($mobilecfg['p1']['myident']['myaddress']))
1163
			$ph1ent['myid_type'] = "myaddress";
1164
		if (isset($mobilecfg['p1']['myident']['address'])) {
1165
			$ph1ent['myid_type'] = "address";
1166
			$ph1ent['myid_data'] = $mobilecfg['p1']['myident']['address'];
1167
		}
1168
		if (isset($mobilecfg['p1']['myident']['fqdn'])) {
1169
			$ph1ent['myid_type'] = "fqdn";
1170
			$ph1ent['myid_data'] = $mobilecfg['p1']['myident']['fqdn'];
1171
		}
1172
		if (isset($mobilecfg['p1']['myident']['ufqdn'])) {
1173
			$ph1ent['myid_type'] = "user_fqdn";
1174
			$ph1ent['myid_data'] = $mobilecfg['p1']['myident']['ufqdn'];
1175
		}
1176
		if (isset($mobilecfg['p1']['myident']['asn1dn'])) {
1177
			$ph1ent['myid_type'] = "asn1dn";
1178
			$ph1ent['myid_data'] = $mobilecfg['p1']['myident']['asn1dn'];
1179
		}
1180
		if (isset($mobilecfg['p1']['myident']['dyn_dns'])) {
1181
			$ph1ent['myid_type'] = "dyn_dns";
1182
			$ph1ent['myid_data'] = $mobilecfg['p1']['myident']['dyn_dns'];
1183
		}
1184
		$ph1ent['peerid_type'] = "fqdn";
1185
		$ph1ent['peerid_data'] = "";
1186
1187
		switch ($mobilecfg['p1']['encryption-algorithm']) {
1188
			case "des":
1189
			$ph1alg = array( 'name' => 'des' );
1190
			break;
1191
			case "3des":
1192
			$ph1alg = array( 'name' => '3des' );
1193
			break;
1194
			case "blowfish":
1195
			$ph1alg = array( 'name' => 'blowfish', 'keylen' => '128'  );
1196
			break;
1197
			case "cast128":
1198
			$ph1alg = array( 'name' => 'cast128' );
1199
			break;
1200
			case "rijndael":
1201
			$ph1alg = array( 'name' => 'aes', 'keylen' => '128' );
1202
			break;
1203
			case "rijndael 256":
1204 a5187d43 jim-p
			case "aes 256":
1205 49bb5c07 jim-p
			$ph1alg = array( 'name' => 'aes', 'keylen' => '256' );
1206
			break;
1207
		}
1208
1209
		$ph1ent['encryption-algorithm'] = $ph1alg;
1210
		$ph1ent['hash-algorithm'] = $mobilecfg['p1']['hash-algorithm'];
1211
		$ph1ent['dhgroup'] = $mobilecfg['p1']['dhgroup'];
1212
		$ph1ent['lifetime'] = $mobilecfg['p1']['lifetime'];
1213
		$ph1ent['authentication_method'] = $mobilecfg['p1']['authentication_method'];
1214
1215
		if (isset($mobilecfg['p1']['cert']))
1216
			$ph1ent['cert'] = $mobilecfg['p1']['cert'];
1217
		if (isset($mobilecfg['p1']['peercert']))
1218
			$ph1ent['peercert'] = $mobilecfg['p1']['peercert'];
1219
		if (isset($mobilecfg['p1']['private-key']))
1220
			$ph1ent['private-key'] = $mobilecfg['p1']['private-key'];
1221
1222
		$ph1ent['nat_traversal'] = "on";
1223
		$ph1ent['dpd_enable'] = 1;
1224
		$ph1ent['dpd_delay'] = 10;
1225
		$ph1ent['dpd_maxfail'] = 5;
1226
		$ph1ent['mobile'] = true;
1227
1228
		$ph2ent = array();
1229
		$ph2ent['ikeid'] = $ph1ent['ikeid'];
1230
		$ph2ent['descr'] = "phase2 for ".$mobilecfg['descr'];
1231
		$ph2ent['localid'] = array('type' => 'none');
1232
		$ph2ent['remoteid'] = array('type' => 'mobile');
1233
		$ph2ent['protocol'] = $mobilecfg['p2']['protocol'];
1234
1235
		$aes_count = 0;
1236
		foreach( $mobilecfg['p2']['encryption-algorithm-option'] as $tunalg ) {
1237
			$aes_found = false;
1238
			switch ($tunalg) {
1239
				case "des":
1240
				$ph2alg = array( 'name' => 'des' );
1241
				break;
1242
				case "3des":
1243
				$ph2alg = array( 'name' => '3des' );
1244
				break;
1245
				case "blowfish":
1246
				$ph2alg = array( 'name' => 'blowfish', 'keylen' => 'auto'  );
1247
				break;
1248
				case "cast128":
1249
				$ph2alg = array( 'name' => 'cast128' );
1250
				break;
1251
				case "rijndael":
1252
				case "rijndael 256":
1253 a5187d43 jim-p
				case "aes 256":
1254 49bb5c07 jim-p
				$ph2alg = array( 'name' => 'aes', 'keylen' => 'auto' );
1255
				$aes_found = true;
1256
				$aes_count++;
1257
				break;
1258
			}
1259
1260
			if( !$aes_found || ($aes_count < 2))
1261
				$ph2ent['encryption-algorithm-option'][] = $ph2alg;
1262
		}
1263
		$ph2ent['hash-algorithm-option'] = $mobilecfg['p2']['hash-algorithm-option'];
1264
		$ph2ent['pfsgroup'] = $mobilecfg['p2']['pfsgroup'];
1265
		$ph2ent['lifetime'] = $mobilecfg['p2']['lifetime'];
1266
		$ph2ent['mobile'] = true;
1267
1268
		$config['ipsec']['phase1'][] = $ph1ent;
1269
		$config['ipsec']['phase2'][] = $ph2ent;
1270
		unset($config['ipsec']['mobileclients']);
1271
	}
1272 791bcfd4 Bill Marquette
}
1273
1274
1275
function upgrade_047_to_048() {
1276
	global $config;
1277 e31c90fc Ermal
	if (!empty($config['dyndns'])) {
1278
		$config['dyndnses'] = array();
1279
		$config['dyndnses']['dyndns'] = array();
1280 c9e13418 Ermal
		if(isset($config['dyndns'][0]['host'])) {
1281 246aceaa smos
			$tempdyn = array();
1282
			$tempdyn['enable'] = isset($config['dyndns'][0]['enable']);
1283
			$tempdyn['type'] = $config['dyndns'][0]['type'];
1284
			$tempdyn['wildcard'] = isset($config['dyndns'][0]['wildcard']);
1285 7d62c4c8 Ermal
			$tempdyn['username'] = $config['dyndns'][0]['username'];
1286
			$tempdyn['password'] = $config['dyndns'][0]['password'];
1287 246aceaa smos
			$tempdyn['host'] = $config['dyndns'][0]['host'];
1288 2d563280 Renato Botelho
			$tempdyn['mx'] = $config['dyndns'][0]['mx'];
1289 246aceaa smos
			$tempdyn['interface'] = "wan";
1290 4d511e5b Renato Botelho
			$tempdyn['descr'] = sprintf(gettext("Upgraded Dyndns %s"), $tempdyn['type']);
1291 246aceaa smos
			$config['dyndnses']['dyndns'][] = $tempdyn;
1292
		}
1293 791bcfd4 Bill Marquette
		unset($config['dyndns']);
1294 2d563280 Renato Botelho
	}
1295 e31c90fc Ermal
	if (!empty($config['dnsupdate'])) {
1296 2b1b78e6 jim-p
		$pconfig = $config['dnsupdate'][0];
1297
		if (!$pconfig['ttl'])
1298
			$pconfig['ttl'] = 60;
1299
		if (!$pconfig['keytype'])
1300
			$pconfig['keytype'] = "zone";
1301 e31c90fc Ermal
		$pconfig['interface'] = "wan";
1302 791bcfd4 Bill Marquette
		$config['dnsupdates']['dnsupdate'][] = $pconfig;
1303
		unset($config['dnsupdate']);
1304
	}
1305
1306 1f0c76cf jim-p
	if (is_array($config['pppoe']) && is_array($config['pppoe'][0])) {
1307 791bcfd4 Bill Marquette
		$pconfig = array();
1308 1f0c76cf jim-p
		$pconfig['username'] = $config['pppoe'][0]['username'];
1309
		$pconfig['password'] = $config['pppoe'][0]['password'];
1310
		$pconfig['provider'] = $config['pppoe'][0]['provider'];
1311
		$pconfig['ondemand'] = isset($config['pppoe'][0]['ondemand']);
1312
		$pconfig['timeout'] = $config['pppoe'][0]['timeout'];
1313 791bcfd4 Bill Marquette
		unset($config['pppoe']);
1314
		$config['interfaces']['wan']['pppoe_username'] = $pconfig['username'];
1315
		$config['interfaces']['wan']['pppoe_password'] = $pconfig['password'];
1316
		$config['interfaces']['wan']['provider'] = $pconfig['provider'];
1317
		$config['interfaces']['wan']['ondemand'] = isset($pconfig['ondemand']);
1318
		$config['interfaces']['wan']['timeout'] = $pconfig['timeout'];
1319
	}
1320
	if (is_array($config['pptp'])) {
1321
		$pconfig = array();
1322
		$pconfig['username'] = $config['pptp']['username'];
1323
		$pconfig['password'] = $config['pptp']['password'];
1324
		$pconfig['provider'] = $config['pptp']['provider'];
1325
		$pconfig['ondemand'] = isset($config['pptp']['ondemand']);
1326
		$pconfig['timeout'] = $config['pptp']['timeout'];
1327
		unset($config['pptp']);
1328
		$config['interfaces']['wan']['pptp_username'] = $pconfig['username'];
1329
		$config['interfaces']['wan']['pptp_password'] = $pconfig['password'];
1330
		$config['interfaces']['wan']['provider'] = $pconfig['provider'];
1331
		$config['interfaces']['wan']['ondemand'] = isset($pconfig['ondemand'] );
1332
		$config['interfaces']['wan']['timeout'] = $pconfig['timeout'];
1333
	}
1334
}
1335
1336
1337
function upgrade_048_to_049() {
1338
	global $config;
1339
	/* setup new all users group */
1340
	$all = array();
1341
	$all['name'] = "all";
1342 4d511e5b Renato Botelho
	$all['description'] = gettext("All Users");
1343 791bcfd4 Bill Marquette
	$all['scope'] = "system";
1344
	$all['gid'] = 1998;
1345
	$all['member'] = array();
1346
1347 84924e76 Ermal
	if (!is_array($config['system']['user']))
1348
		$config['system']['user'] = array();
1349 791bcfd4 Bill Marquette
	if (!is_array($config['system']['group']))
1350
		$config['system']['group'] = array();
1351
1352
	/* work around broken uid assignments */
1353
	$config['system']['nextuid'] = 2000;
1354
	foreach ($config['system']['user'] as & $user) {
1355
		if (isset($user['uid']) && !$user['uid'])
1356
			continue;
1357
		$user['uid'] = $config['system']['nextuid']++;
1358
	}
1359
1360
	/* work around broken gid assignments */
1361
	$config['system']['nextgid'] = 2000;
1362
	foreach ($config['system']['group'] as & $group) {
1363
		if ($group['name'] == $g['admin_group'])
1364
			$group['gid'] = 1999;
1365
		else
1366
			$group['gid'] = $config['system']['nextgid']++;
1367
	}
1368
1369
	/* build group membership information */
1370
	foreach ($config['system']['group'] as & $group) {
1371
		$group['member'] = array();
1372
		foreach ($config['system']['user'] as & $user) {
1373
			$groupnames = explode(",", $user['groupname']);
1374
			if (in_array($group['name'],$groupnames))
1375
				$group['member'][] = $user['uid'];
1376
		}
1377
	}
1378
1379
	/* reset user group information */
1380
	foreach ($config['system']['user'] as & $user) {
1381
		unset($user['groupname']);
1382
		$all['member'][] = $user['uid'];
1383
	}
1384
1385
	/* reset group scope information */
1386
	foreach ($config['system']['group'] as & $group)
1387
		if ($group['name'] != $g['admin_group'])
1388
		$group['scope'] = "user";
1389
1390
	/* insert new all group */
1391
	$groups = Array();
1392
	$groups[] = $all;
1393
	$groups = array_merge($config['system']['group'],$groups);
1394
	$config['system']['group'] = $groups;
1395
}
1396
1397
1398
function upgrade_049_to_050() {
1399
	global $config;
1400 84924e76 Ermal
1401
	if (!is_array($config['system']['user']))
1402
		$config['system']['user'] = array();
1403 791bcfd4 Bill Marquette
	/* update user privileges */
1404
	foreach ($config['system']['user'] as & $user) {
1405
		$privs = array();
1406
		if (!is_array($user['priv'])) {
1407
			unset($user['priv']);
1408
			continue;
1409
		}
1410
		foreach ($user['priv'] as $priv) {
1411
			switch($priv['id']) {
1412
				case "hasshell":
1413
				$privs[] = "user-shell-access";
1414
				break;
1415
				case "copyfiles":
1416
				$privs[] = "user-copy-files";
1417
				break;
1418
			}
1419
		}
1420
		$user['priv'] = $privs;
1421
	}
1422
1423
	/* update group privileges */
1424
	foreach ($config['system']['group'] as & $group) {
1425
		$privs = array();
1426
		if (!is_array($group['pages'])) {
1427
			unset($group['pages']);
1428
			continue;
1429
		}
1430
		foreach ($group['pages'] as $page) {
1431
			$priv = map_page_privname($page);
1432
			if ($priv)
1433
				$privs[] = $priv;
1434
		}
1435
		unset($group['pages']);
1436
		$group['priv'] = $privs;
1437
	}
1438
1439
	/* sync all local account information */
1440
	local_sync_accounts();
1441
}
1442
1443
1444
function upgrade_050_to_051() {
1445
	global $config;
1446
	$pconfig = array();
1447 15864861 jim-p
	$pconfig['descr'] = "Set to 0 to disable filtering on the incoming and outgoing member interfaces.";
1448 791bcfd4 Bill Marquette
	$pconfig['tunable'] = "net.link.bridge.pfil_member";
1449
	$pconfig['value'] = "1";
1450
	$config['sysctl']['item'][] = $pconfig;
1451
	$pconfig = array();
1452 15864861 jim-p
	$pconfig['descr'] = "Set to 1 to enable filtering on the bridge interface";
1453 791bcfd4 Bill Marquette
	$pconfig['tunable'] = "net.link.bridge.pfil_bridge";
1454
	$pconfig['value'] = "0";
1455
	$config['sysctl']['item'][] = $pconfig;
1456
1457
	unset($config['bridge']);
1458
1459
	$convert_bridges = false;
1460
	foreach($config['interfaces'] as $intf) {
1461
		if (isset($intf['bridge']) && $intf['bridge'] <> "") {
1462
			$config['bridges'] = array();
1463
			$config['bridges']['bridged'] = array();
1464
			$convert_bridges = true;
1465
			break;
1466
		}
1467
	}
1468
	if ($convert_bridges == true) {
1469
		$i = 0;
1470
		foreach ($config['interfaces'] as $ifr => &$intf) {
1471
			if (isset($intf['bridge']) && $intf['bridge'] <> "") {
1472
				$nbridge = array();
1473
				$nbridge['members'] = "{$ifr},{$intf['bridge']}";
1474 4d511e5b Renato Botelho
				$nbridge['descr'] = sprintf(gettext("Converted bridged %s"), $ifr);
1475 791bcfd4 Bill Marquette
				$nbridge['bridgeif'] = "bridge{$i}";
1476
				$config['bridges']['bridged'][] = $nbridge;
1477
				unset($intf['bridge']);
1478
				$i++;
1479
			}
1480
		}
1481
	}
1482
}
1483
1484
1485
function upgrade_051_to_052() {
1486
	global $config;
1487
	$config['openvpn'] = array();
1488 9ad72e5e jim-p
	if (!is_array($config['ca']))
1489
		$config['ca'] = array();
1490
	if (!is_array($config['cert']))
1491
		$config['cert'] = array();
1492 791bcfd4 Bill Marquette
1493
	$vpnid = 1;
1494
1495
	/* openvpn server configurations */
1496
	if (is_array($config['installedpackages']['openvpnserver'])) {
1497
		$config['openvpn']['openvpn-server'] = array();
1498
1499
		$index = 1;
1500
		foreach($config['installedpackages']['openvpnserver']['config'] as $server) {
1501
1502
			if (!is_array($server))
1503
				continue;
1504
1505
			if ($server['auth_method'] == "pki") {
1506
1507
				/* create ca entry */
1508
				$ca = array();
1509
				$ca['refid'] = uniqid();
1510 f2a86ca9 jim-p
				$ca['descr'] = "OpenVPN Server CA #{$index}";
1511 791bcfd4 Bill Marquette
				$ca['crt'] = $server['ca_cert'];
1512 9ad72e5e jim-p
				$config['ca'][] = $ca;
1513 791bcfd4 Bill Marquette
1514
				/* create ca reference */
1515
				unset($server['ca_cert']);
1516
				$server['caref'] = $ca['refid'];
1517
1518 47319bfb jim-p
				/* create a crl entry if needed */
1519 ab75b4ee jim-p
				if (!empty($server['crl'][0])) {
1520 47319bfb jim-p
					$crl = array();
1521
					$crl['refid'] = uniqid();
1522
					$crl['descr'] = "Imported OpenVPN CRL #{$index}";
1523
					$crl['caref'] = $ca['refid'];
1524 ab75b4ee jim-p
					$crl['text'] = $server['crl'][0];
1525 90e64fad Warren Baker
					if(!is_array($config['crl']))
1526
						$config['crl'] = array();
1527 fc3e88f1 jim-p
					$config['crl'][] = $crl;
1528 47319bfb jim-p
					$server['crlref'] = $crl['refid'];
1529
				}
1530
				unset($server['crl']);
1531
1532 791bcfd4 Bill Marquette
				/* create cert entry */
1533
				$cert = array();
1534
				$cert['refid'] = uniqid();
1535 f2a86ca9 jim-p
				$cert['descr'] = "OpenVPN Server Certificate #{$index}";
1536 791bcfd4 Bill Marquette
				$cert['crt'] = $server['server_cert'];
1537
				$cert['prv'] = $server['server_key'];
1538 9ad72e5e jim-p
				$config['cert'][] = $cert;
1539 791bcfd4 Bill Marquette
1540
				/* create cert reference */
1541
				unset($server['server_cert']);
1542
				unset($server['server_key']);
1543
				$server['certref'] = $cert['refid'];
1544
1545
				$index++;
1546
			}
1547
1548
			/* determine operational mode */
1549
			if ($server['auth_method'] == 'pki') {
1550
				if($server['nopool']) {
1551
					$server['mode'] = "p2p_tls";
1552
				} else {
1553
					$server['mode'] = "server_tls";
1554
				}
1555
			} else {
1556
				$server['mode'] = "p2p_shared_key";
1557
			}
1558
			unset($server['auth_method']);
1559
1560
			/* modify configuration values */
1561
			$server['dh_length'] = 1024;
1562
			unset($server['dh_params']);
1563
			if (!$server['interface'])
1564 a15a7738 jim-p
				$server['interface'] = 'any';
1565 791bcfd4 Bill Marquette
			$server['tunnel_network'] = $server['addresspool'];
1566
			unset($server['addresspool']);
1567 a843870d jim-p
			if (isset($server['use_lzo']) && ($server['use_lzo'] == "on")) {
1568 8b666514 jim-p
				$server['compression'] = "on";
1569 da831323 Ermal Lu?i
				unset($server['use_lzo']);
1570
			}
1571 791bcfd4 Bill Marquette
			if ($server['nopool'])
1572
				$server['pool_enable'] = false;
1573
			else
1574
				$server['pool_enable'] = "yes";
1575
			unset($server['nopool']);
1576
			$server['dns_domain'] = $server['dhcp_domainname'];
1577
			unset($server['dhcp_domainname']);
1578 c3ae41e6 jim-p
1579
			$tmparr = explode(";", $server['dhcp_dns'], 4);
1580
			$d=1;
1581
			foreach ($tmparr as $tmpa) {
1582
				$server["dns_server{$d}"] = $tmpa;
1583
				$d++;
1584
			}
1585 791bcfd4 Bill Marquette
			unset($server['dhcp_dns']);
1586 c3ae41e6 jim-p
1587
			$tmparr = explode(";", $server['dhcp_ntp'], 2);
1588
			$d=1;
1589
			foreach ($tmparr as $tmpa) {
1590
				$server["ntp_server{$d}"] = $tmpa;
1591
				$d++;
1592
			}
1593 791bcfd4 Bill Marquette
			unset($server['dhcp_ntp']);
1594 c3ae41e6 jim-p
1595 791bcfd4 Bill Marquette
			if ($server['dhcp_nbtdisable'])
1596
				$server['netbios_enable'] = false;
1597
			else
1598
				$server['netbios_enable'] = "yes";
1599
			unset($server['dhcp_nbtdisable']);
1600
			$server['netbios_ntype'] = $server['dhcp_nbttype'];
1601
			unset($server['dhcp_nbttype']);
1602
			$server['netbios_scope'] = $server['dhcp_nbtscope'];
1603
			unset($server['dhcp_nbtscope']);
1604 c3ae41e6 jim-p
1605
			$tmparr = explode(";", $server['dhcp_nbdd'], 2);
1606
			$d=1;
1607
			foreach ($tmparr as $tmpa) {
1608
				$server["nbdd_server{$d}"] = $tmpa;
1609
				$d++;
1610
			}
1611 791bcfd4 Bill Marquette
			unset($server['dhcp_nbdd']);
1612 c3ae41e6 jim-p
1613
			$tmparr = explode(";", $server['dhcp_wins'], 2);
1614
			$d=1;
1615
			foreach ($tmparr as $tmpa) {
1616
				$server["wins_server{$d}"] = $tmpa;
1617
				$d++;
1618
			}
1619 791bcfd4 Bill Marquette
			unset($server['dhcp_wins']);
1620
1621 763a1b52 jim-p
			if (!empty($server['disable']))
1622
				$server['disable'] = true;
1623
			else
1624
				unset($server['disable']);
1625
1626 791bcfd4 Bill Marquette
			/* allocate vpnid */
1627
			$server['vpnid'] = $vpnid++;
1628
1629 4f1ebacb Ermal
			if (!empty($server['custom_options'])) {
1630
				$cstmopts = array();
1631
				$tmpcstmopts = explode(";", $server['custom_options']);
1632 48e24ada jim-p
				$assigned_if = "";
1633 4f1ebacb Ermal
				$tmpstr = "";
1634
				foreach ($tmpcstmopts as $tmpcstmopt) {
1635
					$tmpstr = str_replace(" ", "", $tmpcstmopt);
1636
					if (substr($tmpstr,0 ,6) == "devtun") {
1637 48e24ada jim-p
						$assigned_if = substr($tmpstr, 3);
1638 4f1ebacb Ermal
						continue;
1639 8fd0badd Ermal
					} else if (substr($tmpstr, 0, 5) == "local") {
1640 9bc27ae5 jim-p
						$localip = substr($tmpstr, 5);
1641 8fd0badd Ermal
						$server['ipaddr'] = str_replace("\n", "", $localip);
1642 4f1ebacb Ermal
					} else
1643
						$cstmopts[] = $tmpcstmopt;
1644
				}
1645
				$server['custom_options'] = implode(";", $cstmopts);
1646 48e24ada jim-p
				if (!empty($assigned_if)) {
1647 4f1ebacb Ermal
					foreach ($config['interfaces'] as $iface => $cfgif) {
1648 48e24ada jim-p
						if ($cfgif['if'] == $assigned_if) {
1649 4f1ebacb Ermal
							$config['interfaces'][$iface]['if'] = "ovpns{$server['vpnid']}";
1650
							break;
1651
						}
1652
					}
1653
				}
1654
			}
1655
1656 791bcfd4 Bill Marquette
			$config['openvpn']['openvpn-server'][] = $server;
1657
		}
1658
		unset($config['installedpackages']['openvpnserver']);
1659
	}
1660
1661
	/* openvpn client configurations */
1662
	if (is_array($config['installedpackages']['openvpnclient'])) {
1663
		$config['openvpn']['openvpn-client'] = array();
1664
1665
		$index = 1;
1666
		foreach($config['installedpackages']['openvpnclient']['config'] as $client) {
1667
1668
			if (!is_array($client))
1669
				continue;
1670
1671
			if ($client['auth_method'] == "pki") {
1672
1673
				/* create ca entry */
1674
				$ca = array();
1675
				$ca['refid'] = uniqid();
1676 f2a86ca9 jim-p
				$ca['descr'] = "OpenVPN Client CA #{$index}";
1677 791bcfd4 Bill Marquette
				$ca['crt'] = $client['ca_cert'];
1678
				$ca['crl'] = $client['crl'];
1679 9ad72e5e jim-p
				$config['ca'][] = $ca;
1680 791bcfd4 Bill Marquette
1681
				/* create ca reference */
1682
				unset($client['ca_cert']);
1683
				unset($client['crl']);
1684
				$client['caref'] = $ca['refid'];
1685
1686
				/* create cert entry */
1687
				$cert = array();
1688
				$cert['refid'] = uniqid();
1689 f2a86ca9 jim-p
				$cert['descr'] = "OpenVPN Client Certificate #{$index}";
1690 791bcfd4 Bill Marquette
				$cert['crt'] = $client['client_cert'];
1691
				$cert['prv'] = $client['client_key'];
1692 9ad72e5e jim-p
				$config['cert'][] = $cert;
1693 791bcfd4 Bill Marquette
1694
				/* create cert reference */
1695
				unset($client['client_cert']);
1696
				unset($client['client_key']);
1697
				$client['certref'] = $cert['refid'];
1698
1699
				$index++;
1700
			}
1701
1702
			/* determine operational mode */
1703
			if ($client['auth_method'] == 'pki')
1704
				$client['mode'] = "p2p_tls";
1705
			else
1706
				$client['mode'] = "p2p_shared_key";
1707
			unset($client['auth_method']);
1708
1709
			/* modify configuration values */
1710
			if (!$client['interface'])
1711
				$client['interface'] = 'wan';
1712
			$client['tunnel_network'] = $client['interface_ip'];
1713
			unset($client['interface_ip']);
1714
			$client['server_addr'] = $client['serveraddr'];
1715
			unset($client['serveraddr']);
1716
			$client['server_port'] = $client['serverport'];
1717
			unset($client['serverport']);
1718
			$client['proxy_addr'] = $client['poxy_hostname'];
1719
			unset($client['proxy_addr']);
1720 a843870d jim-p
			if (isset($client['use_lzo']) && ($client['use_lzo'] == "on")) {
1721 8b666514 jim-p
				$client['compression'] = "on";
1722 da831323 Ermal Lu?i
				unset($client['use_lzo']);
1723
			}
1724 791bcfd4 Bill Marquette
			$client['resolve_retry'] = $client['infiniteresolvretry'];
1725
			unset($client['infiniteresolvretry']);
1726
1727
			/* allocate vpnid */
1728
			$client['vpnid'] = $vpnid++;
1729
1730 4f1ebacb Ermal
			if (!empty($client['custom_options'])) {
1731
				$cstmopts = array();
1732
				$tmpcstmopts = explode(";", $client['custom_options']);
1733 48e24ada jim-p
				$assigned_if = "";
1734 4f1ebacb Ermal
				$tmpstr = "";
1735
				foreach ($tmpcstmopts as $tmpcstmopt) {
1736
					$tmpstr = str_replace(" ", "", $tmpcstmopt);
1737
					if (substr($tmpstr,0 ,6) == "devtun") {
1738 48e24ada jim-p
						$assigned_if = substr($tmpstr, 3);
1739 4f1ebacb Ermal
						continue;
1740 8fd0badd Ermal
					} else if (substr($tmpstr, 0, 5) == "local") {
1741 2d563280 Renato Botelho
						$localip = substr($tmpstr, 5);
1742
						$client['ipaddr'] = str_replace("\n", "", $localip);
1743 4f1ebacb Ermal
					} else
1744
						$cstmopts[] = $tmpcstmopt;
1745
				}
1746
				$client['custom_options'] = implode(";", $cstmopts);
1747 48e24ada jim-p
				if (!empty($assigned_if)) {
1748 4f1ebacb Ermal
					foreach ($config['interfaces'] as $iface => $cfgif) {
1749 48e24ada jim-p
						if ($cfgif['if'] == $assigned_if) {
1750 4f1ebacb Ermal
							$config['interfaces'][$iface]['if'] = "ovpnc{$client['vpnid']}";
1751
							break;
1752
						}
1753
					}
1754
				}
1755
			}
1756
1757 763a1b52 jim-p
			if (!empty($client['disable']))
1758
				$client['disable'] = true;
1759
			else
1760
				unset($client['disable']);
1761
1762 791bcfd4 Bill Marquette
			$config['openvpn']['openvpn-client'][] = $client;
1763
		}
1764
1765
		unset($config['installedpackages']['openvpnclient']);
1766
	}
1767
1768
	/* openvpn client specific configurations */
1769
	if (is_array($config['installedpackages']['openvpncsc'])) {
1770
		$config['openvpn']['openvpn-csc'] = array();
1771
1772
		foreach($config['installedpackages']['openvpncsc']['config'] as $csc) {
1773
1774
			if (!is_array($csc))
1775
				continue;
1776
1777
			/* modify configuration values */
1778
			$csc['common_name'] = $csc['commonname'];
1779
			unset($csc['commonname']);
1780
			$csc['tunnel_network'] = $csc['ifconfig_push'];
1781
			unset($csc['ifconfig_push']);
1782
			$csc['dns_domain'] = $csc['dhcp_domainname'];
1783
			unset($csc['dhcp_domainname']);
1784 c3ae41e6 jim-p
1785
			$tmparr = explode(";", $csc['dhcp_dns'], 4);
1786
			$d=1;
1787
			foreach ($tmparr as $tmpa) {
1788
				$csc["dns_server{$d}"] = $tmpa;
1789
				$d++;
1790
			}
1791 791bcfd4 Bill Marquette
			unset($csc['dhcp_dns']);
1792 c3ae41e6 jim-p
1793
			$tmparr = explode(";", $csc['dhcp_ntp'], 2);
1794
			$d=1;
1795
			foreach ($tmparr as $tmpa) {
1796
				$csc["ntp_server{$d}"] = $tmpa;
1797
				$d++;
1798
			}
1799 791bcfd4 Bill Marquette
			unset($csc['dhcp_ntp']);
1800 c3ae41e6 jim-p
1801 791bcfd4 Bill Marquette
			if ($csc['dhcp_nbtdisable'])
1802
				$csc['netbios_enable'] = false;
1803
			else
1804
				$csc['netbios_enable'] = "yes";
1805
			unset($csc['dhcp_nbtdisable']);
1806
			$csc['netbios_ntype'] = $csc['dhcp_nbttype'];
1807
			unset($csc['dhcp_nbttype']);
1808
			$csc['netbios_scope'] = $csc['dhcp_nbtscope'];
1809
			unset($csc['dhcp_nbtscope']);
1810 c3ae41e6 jim-p
1811
			$tmparr = explode(";", $csc['dhcp_nbdd'], 2);
1812
			$d=1;
1813
			foreach ($tmparr as $tmpa) {
1814
				$csc["nbdd_server{$d}"] = $tmpa;
1815
				$d++;
1816
			}
1817 791bcfd4 Bill Marquette
			unset($csc['dhcp_nbdd']);
1818 c3ae41e6 jim-p
1819
			$tmparr = explode(";", $csc['dhcp_wins'], 2);
1820
			$d=1;
1821
			foreach ($tmparr as $tmpa) {
1822
				$csc["wins_server{$d}"] = $tmpa;
1823
				$d++;
1824
			}
1825 791bcfd4 Bill Marquette
			unset($csc['dhcp_wins']);
1826
1827 1e68a58b jim-p
			if (!empty($csc['disable']))
1828
				$csc['disable'] = true;
1829
			else
1830
				unset($csc['disable']);
1831
1832 791bcfd4 Bill Marquette
			$config['openvpn']['openvpn-csc'][] = $csc;
1833
		}
1834
1835
		unset($config['installedpackages']['openvpncsc']);
1836
	}
1837
1838 c73bd8f0 Ermal Lu?i
	if (count($config['openvpn']['openvpn-server']) > 0 ||
1839
		count($config['openvpn']['openvpn-client']) > 0) {
1840
		$ovpnrule = array();
1841 2d563280 Renato Botelho
		$ovpnrule['type'] = "pass";
1842
		$ovpnrule['interface'] = "openvpn";
1843
		$ovpnrule['statetype'] = "keep state";
1844
		$ovpnrule['source'] = array();
1845
		$ovpnrule['destination'] = array();
1846
		$ovpnrule['source']['any'] = true;
1847
		$ovpnrule['destination']['any'] = true;
1848
		$ovpnrule['descr'] = gettext("Auto added OpenVPN rule from config upgrade.");
1849 c73bd8f0 Ermal Lu?i
		$config['filter']['rule'][] = $ovpnrule;
1850
	}
1851
1852 791bcfd4 Bill Marquette
	/*
1853
		* FIXME: hack to keep things working with no installedpackages
1854
		* or carp array in the configuration data.
1855
		*/
1856
	if (!is_array($config['installedpackages']))
1857
		$config['installedpackages'] = array();
1858
	if (!is_array($config['installedpackages']['carp']))
1859
		$config['installedpackages']['carp'] = array();
1860
1861
}
1862
1863
1864
function upgrade_052_to_053() {
1865
	global $config;
1866 9ad72e5e jim-p
	if (!is_array($config['ca']))
1867
		$config['ca'] = array();
1868
	if (!is_array($config['cert']))
1869
		$config['cert'] = array();
1870 791bcfd4 Bill Marquette
1871
	/* migrate advanced admin page webui ssl to certifcate mngr */
1872
	if ($config['system']['webgui']['certificate'] &&
1873
	$config['system']['webgui']['private-key']) {
1874
1875
		/* create cert entry */
1876
		$cert = array();
1877
		$cert['refid'] = uniqid();
1878 f2a86ca9 jim-p
		$cert['descr'] = "webConfigurator SSL Certificate";
1879 791bcfd4 Bill Marquette
		$cert['crt'] = $config['system']['webgui']['certificate'];
1880
		$cert['prv'] = $config['system']['webgui']['private-key'];
1881 9ad72e5e jim-p
		$config['cert'][] = $cert;
1882 791bcfd4 Bill Marquette
1883
		/* create cert reference */
1884
		unset($config['system']['webgui']['certificate']);
1885
		unset($config['system']['webgui']['private-key']);
1886
		$config['system']['webgui']['ssl-certref'] = $cert['refid'];
1887
	}
1888
1889
	/* migrate advanced admin page ssh keys to user manager */
1890
	if ($config['system']['ssh']['authorizedkeys']) {
1891
		$admin_user =& getUserEntryByUID(0);
1892
		$admin_user['authorizedkeys'] = $config['system']['ssh']['authorizedkeys'];
1893
		unset($config['system']['ssh']['authorizedkeys']);
1894
	}
1895
}
1896
1897
1898
function upgrade_053_to_054() {
1899
	global $config;
1900 38b5beaf sullrich
	if(is_array($config['load_balancer']['lbpool'])) {
1901
		$lbpool_arr = $config['load_balancer']['lbpool'];
1902 791bcfd4 Bill Marquette
		$lbpool_srv_arr = array();
1903
		$gateway_group_arr = array();
1904 816a5aff Seth Mos
		$gateways = return_gateways_array();
1905 ce107ca5 jim-p
		$group_name_changes = array();
1906 d827f9cc smos
		if (! is_array($config['gateways']['gateway_item']))
1907 bf02c784 Ermal
			$config['gateways']['gateway_item'] = array();
1908 d827f9cc smos
1909 bf02c784 Ermal
		$a_gateways =& $config['gateways']['gateway_item'];
1910 791bcfd4 Bill Marquette
		foreach($lbpool_arr as $lbpool) {
1911
			if($lbpool['type'] == "gateway") {
1912 ce107ca5 jim-p
				// Gateway Groups have to have valid names in pf, old lb pools did not. Clean them up.
1913 aff670f6 ccesario
				$group_name = preg_replace("/[^A-Za-z0-9]/", "", $lbpool['name'] );
1914 ce107ca5 jim-p
				// If we made and changes, check for collisions and note the change.
1915
				if ($group_name != $lbpool['name']) {
1916
					// Make sure the name isn't already in use.
1917
					foreach ($gateway_group_arr as $gwg) {
1918
						// If the name is in use, add some random bits to avoid collision.
1919
						if ($gwg['name'] == $group_name)
1920
							$group_name .= uniqid();
1921
					}
1922
					$group_name_changes[$lbpool['name']] = $group_name;
1923
				}
1924
				$gateway_group['name'] = $group_name;
1925 e988813d jim-p
				$gateway_group['descr'] = $lbpool['descr'];
1926 791bcfd4 Bill Marquette
				$gateway_group['trigger'] = "down";
1927
				$gateway_group['item'] = array();
1928 cb945ced sullrich
				$i = 0;
1929 791bcfd4 Bill Marquette
				foreach($lbpool['servers'] as $member) {
1930 2ce660ad smos
					$split = explode("|", $member);
1931 791bcfd4 Bill Marquette
					$interface = $split[0];
1932 d9d4c637 Seth Mos
					$monitor = $split[1];
1933 2328dcc5 Seth Mos
					/* on static upgraded configuration we automatically prepend GW_ */
1934
					$static_name = "GW_" . strtoupper($interface);
1935 d2b20ab6 jim-p
					if(is_ipaddr($monitor))
1936
						foreach ($a_gateways as & $gw)
1937
							if ($gw['name'] == $static_name)
1938
								$gw['monitor'] = $monitor;
1939
1940 6ee1b7eb Seth Mos
					/* on failover increment tier. Else always assign 1 */
1941
					if($lbpool['behaviour'] == "failover") {
1942
						$i++;
1943
					} else {
1944
						$i = 1;
1945
					}
1946 685a26fc smos
					$gateway_group['item'][] = "$static_name|$i";
1947 791bcfd4 Bill Marquette
				}
1948
				$gateway_group_arr[] = $gateway_group;
1949
			} else {
1950
				$lbpool_srv_arr[] = $lbpool;
1951
			}
1952
		}
1953 38b5beaf sullrich
		$config['load_balancer']['lbpool'] = $lbpool_srv_arr;
1954 791bcfd4 Bill Marquette
		$config['gateways']['gateway_group'] = $gateway_group_arr;
1955
	}
1956
	// Unset lbpool if we no longer have any server pools
1957
	if (count($lbpool_srv_arr) == 0) {
1958 416ae3d6 Seth Mos
		if(empty($config['load_balancer'])) {
1959 0b5b4f32 Seth Mos
			unset($config['load_balancer']);
1960 92a2ceae Seth Mos
		} else {
1961
			unset($config['load_balancer']['lbpool']);
1962 0b5b4f32 Seth Mos
		}
1963 791bcfd4 Bill Marquette
	} else {
1964
		$config['load_balancer']['lbpool'] = $lbpool_srv_arr;
1965
	}
1966
	// Only set the gateway group array if we converted any
1967
	if (count($gateway_group_arr) != 0) {
1968
		$config['gateways']['gateway_group'] = $gateway_group_arr;
1969 ce107ca5 jim-p
		// Update any rules that had a gateway change, if any.
1970
		if (count($group_name_changes) > 0)
1971
			foreach ($config['filter']['rule'] as & $rule)
1972
				if (!empty($rule["gateway"]) && array_key_exists($rule["gateway"], $group_name_changes))
1973
					$rule["gateway"] = $group_name_changes[$rule["gateway"]];
1974 791bcfd4 Bill Marquette
	}
1975
}
1976
1977
1978
function upgrade_054_to_055() {
1979
	global $config;
1980 54f8bad0 Seth Mos
	global $g;
1981
1982 791bcfd4 Bill Marquette
	/* RRD files changed for quality, traffic and packets graphs */
1983 59cfe65d Ermal
	//ini_set("max_execution_time", "1800");
1984 791bcfd4 Bill Marquette
	/* convert traffic RRD file */
1985
	global $parsedcfg, $listtags;
1986
	$listtags = array("ds", "v", "rra", "row");
1987
1988
	$rrddbpath = "/var/db/rrd/";
1989
	$rrdtool = "/usr/bin/nice -n20 /usr/local/bin/rrdtool";
1990 e34cf1f6 smos
	if ($g['platform'] != "pfSense") {
1991
		/* restore the databases, if we have one */
1992 8bdb6879 Darren Embry
		if (restore_rrd()) {
1993 e34cf1f6 smos
			/* Make sure to move the rrd backup out of the way. We will make a new one after converting. */
1994 8560c756 jim-p
			@rename("{$g['cf_conf_path']}/rrd.tgz", "{$g['cf_conf_path']}/backup/rrd.tgz");
1995 e34cf1f6 smos
		}
1996
	}
1997 791bcfd4 Bill Marquette
1998
	$rrdinterval = 60;
1999
	$valid = $rrdinterval * 2;
2000
2001
	/* Asume GigE for now */
2002
	$downstream = 125000000;
2003
	$upstream = 125000000;
2004
2005
	/* build a list of quality databases */
2006
	/* roundtrip has become delay */
2007
	function divide_delay($delayval) {
2008
		$delayval = floatval($delayval);
2009
		$delayval = ($delayval / 1000);
2010
		$delayval = " ". sprintf("%1.10e", $delayval) ." ";
2011
		return $delayval;
2012
	}
2013
	/* the roundtrip times need to be divided by 1000 to get seconds, really */
2014
	$databases = array();
2015 af0b07d3 jim-p
	if (!file_exists($rrddbpath))
2016
		@mkdir($rrddbpath);
2017 4cb9abc3 jim-p
	chdir($rrddbpath);
2018
	$databases = glob("*-quality.rrd");
2019 791bcfd4 Bill Marquette
	rsort($databases);
2020
	foreach($databases as $database) {
2021
		$xmldump = "{$database}.old.xml";
2022
		$xmldumpnew = "{$database}.new.xml";
2023
2024 285ef132 Ermal LUÇI
		if (platform_booting())
2025 9bc8b6b6 Seth Mos
			echo "Migrate RRD database {$database} to new format for IPv6 \n";
2026 791bcfd4 Bill Marquette
		mwexec("$rrdtool tune {$rrddbpath}{$database} -r roundtrip:delay 2>&1");
2027
2028
		dump_rrd_to_xml("{$rrddbpath}/{$database}", "{$g['tmp_path']}/{$xmldump}");
2029 1005d4bf Seth Mos
		$rrdold = xml2array(file_get_contents("{$g['tmp_path']}/{$xmldump}"), 1, "tag");
2030 791bcfd4 Bill Marquette
		$rrdold = $rrdold['rrd'];
2031
2032
		$i = 0;
2033
		foreach($rrdold['rra'] as $rra) {
2034
			$l = 0;
2035
			foreach($rra['database']['row'] as $row) {
2036
				$vnew = divide_delay($row['v'][1]);
2037
				$rrdold['rra'][$i]['database']['row'][$l]['v'][1] = $vnew;
2038
				$l++;
2039
			}
2040
			$i++;
2041
		}
2042
2043 56ee96ed smos
		file_put_contents("{$g['tmp_path']}/{$xmldumpnew}", dump_xml_config_raw($rrdold, "rrd"));
2044 791bcfd4 Bill Marquette
		mwexec("$rrdtool restore -f {$g['tmp_path']}/{$xmldumpnew} {$rrddbpath}/{$database} 2>&1");
2045
2046 1005d4bf Seth Mos
		unset($rrdold);
2047 7ceff68a Ermal LUÇI
		@unlink("{$g['tmp_path']}/{$xmldump}");
2048
		@unlink("{$g['tmp_path']}/{$xmldumpnew}");
2049 791bcfd4 Bill Marquette
	}
2050
	/* let apinger recreate required files */
2051 f29e20a3 Ermal LUÇI
	if (!platform_booting())
2052
		setup_gateways_monitor();
2053 791bcfd4 Bill Marquette
2054
	/* build a list of traffic and packets databases */
2055 84683e42 Renato Botelho
	$databases = return_dir_as_array($rrddbpath, '/-(traffic|packets)\.rrd$/');
2056 791bcfd4 Bill Marquette
	rsort($databases);
2057
	foreach($databases as $database) {
2058
		$databasetmp = "{$database}.tmp";
2059
		$xmldump = "{$database}.old.xml";
2060
		$xmldumptmp = "{$database}.tmp.xml";
2061
		$xmldumpnew = "{$database}.new.xml";
2062
2063 285ef132 Ermal LUÇI
		if (platform_booting())
2064 34834e7e jim-p
			echo "Migrate RRD database {$database} to new format \n";
2065 791bcfd4 Bill Marquette
		/* rename DS source */
2066
		mwexec("$rrdtool tune {$rrddbpath}/{$database} -r in:inpass 2>&1");
2067
		mwexec("$rrdtool tune {$rrddbpath}/{$database} -r out:outpass 2>71");
2068
2069
		/* dump contents to xml and move database out of the way */
2070
		dump_rrd_to_xml("{$rrddbpath}/{$database}", "{$g['tmp_path']}/{$xmldump}");
2071
2072
		/* create new rrd database file */
2073
		$rrdcreate = "$rrdtool create {$g['tmp_path']}/{$databasetmp} --step $rrdinterval ";
2074
		$rrdcreate .= "DS:inpass:COUNTER:$valid:0:$downstream ";
2075
		$rrdcreate .= "DS:outpass:COUNTER:$valid:0:$upstream ";
2076
		$rrdcreate .= "DS:inblock:COUNTER:$valid:0:$downstream ";
2077
		$rrdcreate .= "DS:outblock:COUNTER:$valid:0:$upstream ";
2078
		$rrdcreate .= "RRA:AVERAGE:0.5:1:1000 ";
2079
		$rrdcreate .= "RRA:AVERAGE:0.5:5:1000 ";
2080
		$rrdcreate .= "RRA:AVERAGE:0.5:60:1000 ";
2081 eb346e0b Seth Mos
		$rrdcreate .= "RRA:AVERAGE:0.5:720:1000 ";
2082 791bcfd4 Bill Marquette
2083
		create_new_rrd("$rrdcreate");
2084
		/* create temporary xml from new RRD */
2085
		dump_rrd_to_xml("{$g['tmp_path']}/{$databasetmp}", "{$g['tmp_path']}/{$xmldumptmp}");
2086
2087 1005d4bf Seth Mos
		$rrdold = xml2array(file_get_contents("{$g['tmp_path']}/{$xmldump}"), 1, "tag");
2088 791bcfd4 Bill Marquette
		$rrdold = $rrdold['rrd'];
2089
2090 1005d4bf Seth Mos
		$rrdnew = xml2array(file_get_contents("{$g['tmp_path']}/{$xmldumptmp}"), 1, "tag");
2091 791bcfd4 Bill Marquette
		$rrdnew = $rrdnew['rrd'];
2092
2093
		/* remove any MAX RRA's. Not needed for traffic. */
2094
		$i = 0;
2095
		foreach ($rrdold['rra'] as $rra) {
2096
			if(trim($rra['cf']) == "MAX") {
2097
				unset($rrdold['rra'][$i]);
2098
			}
2099
			$i++;
2100
		}
2101
2102 56ee96ed smos
		file_put_contents("{$g['tmp_path']}/{$xmldumpnew}", dump_xml_config_raw(migrate_rrd_format($rrdold, $rrdnew), "rrd"));
2103 791bcfd4 Bill Marquette
		mwexec("$rrdtool restore -f {$g['tmp_path']}/{$xmldumpnew} {$rrddbpath}/{$database} 2>&1");
2104 eb346e0b Seth Mos
		/* we now have the rrd with the new fields, adjust the size now. */
2105
		/* RRA 2 is 60 minutes, RRA 3 is 720 minutes */
2106
		mwexec("/bin/sync");
2107 12a2f395 Seth Mos
		mwexec("$rrdtool resize {$rrddbpath}/{$database} 2 GROW 2000;/bin/mv resize.rrd {$rrddbpath}/{$database} 2>&1");
2108 eb346e0b Seth Mos
		mwexec("/bin/sync");
2109 12a2f395 Seth Mos
		mwexec("$rrdtool resize {$rrddbpath}/{$database} 3 GROW 2000;/bin/mv resize.rrd {$rrddbpath}/{$database} 2>&1");
2110 1005d4bf Seth Mos
		unset($rrdxmlarray);
2111 7ceff68a Ermal LUÇI
		@unlink("{$g['tmp_path']}/{$xmldump}");
2112
		@unlink("{$g['tmp_path']}/{$xmldumpnew}");
2113 791bcfd4 Bill Marquette
	}
2114 e546d2d1 Ermal LUÇI
	if (!platform_booting())
2115
		enable_rrd_graphing();
2116 e34cf1f6 smos
	/* Let's save the RRD graphs after we run enable RRD graphing */
2117
	/* The function will restore the rrd.tgz so we will save it after */
2118 8bdb6879 Darren Embry
	exec("cd /; LANG=C NO_REMOUNT=1 RRDDBPATH='{$rrddbpath}' CF_CONF_PATH='{$g['cf_conf_path']}' /etc/rc.backup_rrd.sh");
2119 e7f65689 Renato Botelho
	unlink_if_exists("{$g['vardb_path']}/rrd/*.xml");
2120 285ef132 Ermal LUÇI
	if (platform_booting())
2121 34834e7e jim-p
		echo "Updating configuration...";
2122 791bcfd4 Bill Marquette
}
2123
2124
2125
function upgrade_055_to_056() {
2126
	global $config;
2127
2128 9ad72e5e jim-p
	if (!is_array($config['ca']))
2129
		$config['ca'] = array();
2130
	if (!is_array($config['cert']))
2131
		$config['cert'] = array();
2132 791bcfd4 Bill Marquette
2133
	/* migrate ipsec ca's to cert manager */
2134
	if (is_array($config['ipsec']['cacert'])) {
2135
		foreach($config['ipsec']['cacert'] as & $cacert) {
2136
			$ca = array();
2137
			$ca['refid'] = uniqid();
2138
			if (is_array($cacert['cert']))
2139
				$ca['crt'] = $cacert['cert'][0];
2140
			else
2141
				$ca['crt'] = $cacert['cert'];
2142 f2a86ca9 jim-p
			$ca['descr'] = $cacert['ident'];
2143 9ad72e5e jim-p
			$config['ca'][] = $ca;
2144 791bcfd4 Bill Marquette
		}
2145
		unset($config['ipsec']['cacert']);
2146
	}
2147
2148
	/* migrate phase1 certificates to cert manager */
2149
	if (is_array($config['ipsec']['phase1'])) {
2150
		foreach($config['ipsec']['phase1'] as & $ph1ent) {
2151
			$cert = array();
2152
			$cert['refid'] = uniqid();
2153 f2a86ca9 jim-p
			$cert['descr'] = "IPsec Peer {$ph1ent['remote-gateway']} Certificate";
2154 791bcfd4 Bill Marquette
			if (is_array($ph1ent['cert']))
2155
				$cert['crt'] = $ph1ent['cert'][0];
2156
			else
2157
				$cert['crt'] = $ph1ent['cert'];
2158
			$cert['prv'] = $ph1ent['private-key'];
2159 9ad72e5e jim-p
			$config['cert'][] = $cert;
2160 791bcfd4 Bill Marquette
			$ph1ent['certref'] = $cert['refid'];
2161
			if ($ph1ent['cert'])
2162
				unset($ph1ent['cert']);
2163
			if ($ph1ent['private-key'])
2164
				unset($ph1ent['private-key']);
2165
			if ($ph1ent['peercert'])
2166
				unset($ph1ent['peercert']);
2167
		}
2168
	}
2169
}
2170
2171
2172
function upgrade_056_to_057() {
2173
	global $config;
2174 84924e76 Ermal
2175 4830e56a Erik Fonnesbeck
	if (!is_array($config['system']['user']))
2176
		$config['system']['user'] = array();
2177 791bcfd4 Bill Marquette
	/* migrate captivate portal to user manager */
2178
	if (is_array($config['captiveportal']['user'])) {
2179
		foreach($config['captiveportal']['user'] as $user) {
2180
			// avoid user conflicts
2181 4830e56a Erik Fonnesbeck
			$found = false;
2182
			foreach ($config['system']['user'] as $userent) {
2183
				if ($userent['name'] == $user['name']) {
2184
					$found = true;
2185
					break;
2186
				}
2187
			}
2188
			if ($found)
2189 791bcfd4 Bill Marquette
				continue;
2190
			$user['scope'] = "user";
2191
			if (isset($user['expirationdate'])) {
2192
				$user['expires'] = $user['expirationdate'];
2193
				unset($user['expirationdate']);
2194
			}
2195
			if (isset($user['password'])) {
2196
				$user['md5-hash'] = $user['password'];
2197
				unset($user['password']);
2198
			}
2199 4830e56a Erik Fonnesbeck
			$user['uid'] = $config['system']['nextuid']++;
2200 791bcfd4 Bill Marquette
			$config['system']['user'][] = $user;
2201
		}
2202
		unset($config['captiveportal']['user']);
2203
	}
2204
}
2205 4b96b367 mgrooms
2206
function upgrade_057_to_058() {
2207
	global $config;
2208
	/* set all phase2 entries to tunnel mode */
2209
	if (is_array($config['ipsec']['phase2']))
2210
		foreach($config['ipsec']['phase2'] as & $ph2ent)
2211
			$ph2ent['mode'] = 'tunnel';
2212
}
2213 60120e37 Ermal Lu?i
2214
function upgrade_058_to_059() {
2215
	global $config;
2216
2217
	if (is_array($config['schedules']['schedule'])) {
2218
		foreach ($config['schedules']['schedule'] as & $schedl)
2219
			$schedl['schedlabel'] = uniqid();
2220
	}
2221
}
2222 2523c923 Seth Mos
2223
function upgrade_059_to_060() {
2224 fcf5afa0 Seth Mos
	global $config;
2225 a0588fad Scott Ullrich
	require_once("/etc/inc/certs.inc");
2226 9ad72e5e jim-p
	if (is_array($config['ca'])) {
2227 2cf6ddcb Nigel Graham
		/* Locate issuer for all CAs */
2228 9ad72e5e jim-p
		foreach ($config['ca'] as & $ca) {
2229 2cf6ddcb Nigel Graham
			$subject = cert_get_subject($ca['crt']);
2230
			$issuer = cert_get_issuer($ca['crt']);
2231
			if($issuer <> $subject) {
2232
				$issuer_crt =& lookup_ca_by_subject($issuer);
2233
				if($issuer_crt)
2234
					$ca['caref'] = $issuer_crt['refid'];
2235
			}
2236
		}
2237 2d563280 Renato Botelho
2238 2cf6ddcb Nigel Graham
		/* Locate issuer for all certificates */
2239 9ad72e5e jim-p
		if (is_array($config['cert'])) {
2240
			foreach ($config['cert'] as & $cert) {
2241 2cf6ddcb Nigel Graham
				$subject = cert_get_subject($cert['crt']);
2242
				$issuer = cert_get_issuer($cert['crt']);
2243
				if($issuer <> $subject) {
2244
					$issuer_crt =& lookup_ca_by_subject($issuer);
2245
					if($issuer_crt)
2246
						$cert['caref'] = $issuer_crt['refid'];
2247
				}
2248
			}
2249 9d3dab70 Scott Ullrich
		}
2250 2cf6ddcb Nigel Graham
	}
2251
}
2252 d43ad788 Scott Ullrich
2253 6a688547 Ermal
function upgrade_060_to_061() {
2254
	global $config;
2255 3cfa11c2 Scott Ullrich
2256 6a688547 Ermal
	if (is_array($config['interfaces']['wan']))
2257
		$config['interfaces']['wan']['enable'] = true;
2258
	if (is_array($config['interfaces']['lan']))
2259
		$config['interfaces']['lan']['enable'] = true;
2260 1cad6f6c jim-p
2261
	/* On 1.2.3 the "mtu" field adjusted MSS.
2262
	   On 2.x the "mtu" field is actually the MTU. Rename accordingly.
2263
	   See redmine ticket #1886
2264
	*/
2265
	foreach ($config['interfaces'] as $ifr => &$intf) {
2266
		if (isset($intf['mtu']) && is_numeric($intf['mtu'])) {
2267
			$intf['mss'] = $intf['mtu'];
2268
			unset($intf['mtu']);
2269
		}
2270
	}
2271 6a688547 Ermal
}
2272 3cfa11c2 Scott Ullrich
2273 59ecde49 Renato Botelho
function upgrade_061_to_062() {
2274
	global $config;
2275
2276
	/* Convert NAT port forwarding rules */
2277
	if (is_array($config['nat']['rule'])) {
2278
		$a_nat = &$config['nat']['rule'];
2279
2280
		foreach ($a_nat as &$natent) {
2281
			$natent['disabled'] = false;
2282
			$natent['nordr']    = false;
2283
2284
			$natent['source'] = array(
2285
				"not"     => false,
2286
				"any"     => true,
2287
				"port"    => ""
2288
			);
2289
2290
			$natent['destination'] = array(
2291
				"not"     => false,
2292
				"address" => $natent['external-address'],
2293
				"port"    => $natent['external-port']
2294
			);
2295
2296 743ce9f8 Erik Fonnesbeck
			if (empty($natent['destination']['address'])) {
2297 fcf4e8cd Erik Fonnesbeck
				unset($natent['destination']['address']);
2298
				$natent['destination']['network'] = $natent['interface'] . 'ip';
2299 743ce9f8 Erik Fonnesbeck
			} else if ($natent['destination']['address'] == 'any') {
2300
				unset($natent['destination']['address']);
2301
				$natent['destination']['any'] = true;
2302
			}
2303
2304 59ecde49 Renato Botelho
			unset($natent['external-address']);
2305
			unset($natent['external-port']);
2306
		}
2307
2308
		unset($natent);
2309
	}
2310
}
2311
2312 0f8266ed smos
function upgrade_062_to_063() {
2313 168a1e48 smos
	/* Upgrade legacy Themes to the new pfsense_ng */
2314
	global $config;
2315
2316
	switch($config['theme']) {
2317 1852fef0 smos
		case "nervecenter":
2318 168a1e48 smos
			$config['theme'] = "pfsense_ng";
2319
			break;
2320
	}
2321 2d563280 Renato Botelho
2322 168a1e48 smos
}
2323 c2b2b571 gnhb
2324
function upgrade_063_to_064() {
2325
	global $config;
2326 d09ca87e gnhb
	$j=0;
2327
	$ifcfg = &$config['interfaces'];
2328 2d563280 Renato Botelho
2329
	if (is_array($config['ppps']['ppp']) && count($config['ppps']['ppp'])) {
2330 c2b2b571 gnhb
		foreach ($config['ppps']['ppp'] as $pppid => $ppp) {
2331 d09ca87e gnhb
			$config['ppps']['ppp'][$pppid]['if'] = "ppp".$j;
2332
			$config['ppps']['ppp'][$pppid]['ptpid'] = $j;
2333
			$j++;
2334 c2b2b571 gnhb
			if (isset($ppp['port'])){
2335
				$config['ppps']['ppp'][$pppid]['ports'] = $ppp['port'];
2336
				unset($config['ppps']['ppp'][$pppid]['port']);
2337
			}
2338
			if (!isset($ppp['type'])){
2339
				$config['ppps']['ppp'][$pppid]['type'] = "ppp";
2340
			}
2341 8256f324 gnhb
			if (isset($ppp['defaultgw']))
2342 6fdfa8fb gnhb
				unset($config['ppps']['ppp'][$pppid]['defaultgw']);
2343 c2b2b571 gnhb
		}
2344
	}
2345 2d563280 Renato Botelho
2346 c2b2b571 gnhb
	if (!is_array($config['ppps']['ppp']))
2347
		$config['ppps']['ppp'] = array();
2348
	$a_ppps = &$config['ppps']['ppp'];
2349
2350
	foreach ($ifcfg as $ifname => $ifinfo) {
2351
		$ppp = array();
2352
		// For pppoe conversion
2353
		if ($ifinfo['ipaddr'] == "pppoe" || $ifinfo['ipaddr'] == "pptp"){
2354
			if (isset($ifinfo['ptpid']))
2355
				continue;
2356 d09ca87e gnhb
			$ppp['ptpid'] =  $j;
2357 c2b2b571 gnhb
			$ppp['type'] = $ifinfo['ipaddr'];
2358 d09ca87e gnhb
			$ppp['if'] = $ifinfo['ipaddr'].$j;
2359 c2b2b571 gnhb
			$ppp['ports'] = $ifinfo['if'];
2360
			if ($ifinfo['ipaddr'] == "pppoe"){
2361
				$ppp['username'] = $ifinfo['pppoe_username'];
2362
				$ppp['password'] = base64_encode($ifinfo['pppoe_password']);
2363
			}
2364
			if ($ifinfo['ipaddr'] == "pptp"){
2365
				$ppp['username'] = $ifinfo['pptp_username'];
2366
				$ppp['password'] = base64_encode($ifinfo['pptp_password']);
2367
			}
2368 2d563280 Renato Botelho
2369 c2b2b571 gnhb
			if (isset($ifinfo['provider']))
2370
				$ppp['provider'] = $ifinfo['provider'];
2371
			if (isset($ifinfo['ondemand']))
2372
				$ppp['ondemand'] = true;
2373
			if (isset($ifinfo['timeout']))
2374
				$ppp['idletimeout'] = $ifinfo['timeout'];
2375
			if (isset($ifinfo['pppoe']['pppoe-reset-type'])){
2376
				$ppp['pppoe-reset-type'] = $ifinfo['pppoe']['pppoe-reset-type'];
2377
				if (is_array($config['cron']['item'])) {
2378
					for ($i = 0; $i < count($config['cron']['item']); $i++) {
2379
						$item = $config['cron']['item'][$i];
2380
						if (strpos($item['command'], "/conf/pppoe{$ifname}restart") !== false)
2381 f7480829 gnhb
							$config['cron']['item'][$i]['command'] = "/var/etc/pppoe_restart_" . $ppp['if'];
2382 c2b2b571 gnhb
					}
2383
				}
2384
			}
2385
			if (isset($ifinfo['local']))
2386
				$ppp['localip'] = $ifinfo['local'];
2387
			if (isset($ifinfo['subnet']))
2388
				$ppp['subnet'] = $ifinfo['subnet'];
2389
			if (isset($ifinfo['remote']))
2390
				$ppp['gateway'] = $ifinfo['remote'];
2391 f7480829 gnhb
2392 d09ca87e gnhb
			$ifcfg[$ifname]['if'] = $ifinfo['ipaddr'].$j;
2393
			$j++;
2394 2d563280 Renato Botelho
2395 c2b2b571 gnhb
			unset($ifcfg[$ifname]['pppoe_username']);
2396
			unset($ifcfg[$ifname]['pppoe_password']);
2397
			unset($ifcfg[$ifname]['provider']);
2398
			unset($ifcfg[$ifname]['ondemand']);
2399
			unset($ifcfg[$ifname]['timeout']);
2400
			unset($ifcfg[$ifname]['pppoe_reset']);
2401
			unset($ifcfg[$ifname]['pppoe_preset']);
2402
			unset($ifcfg[$ifname]['pppoe']);
2403
			unset($ifcfg[$ifname]['pptp_username']);
2404
			unset($ifcfg[$ifname]['pptp_password']);
2405
			unset($ifcfg[$ifname]['local']);
2406
			unset($ifcfg[$ifname]['subnet']);
2407
			unset($ifcfg[$ifname]['remote']);
2408 2d563280 Renato Botelho
2409 c2b2b571 gnhb
			$a_ppps[] = $ppp;
2410 2d563280 Renato Botelho
2411 c2b2b571 gnhb
		}
2412
	}
2413
}
2414
2415 56a5a0ab jim-p
function upgrade_064_to_065() {
2416
	/* Disable TSO and LRO in upgraded configs */
2417
	global $config;
2418
	$config['system']['disablesegmentationoffloading'] = true;
2419
	$config['system']['disablelargereceiveoffloading'] = true;
2420
}
2421
2422 2f06cc3f Ermal
function upgrade_065_to_066() {
2423
	global $config;
2424
2425
	$dhcrelaycfg =& $config['dhcrelay'];
2426
2427 2d563280 Renato Botelho
	if (is_array($dhcrelaycfg)) {
2428
		$dhcrelayifs = array();
2429 2f06cc3f Ermal
		$foundifs = false;
2430 2d563280 Renato Botelho
		/* DHCPRelay enabled on any interfaces? */
2431
		foreach ($dhcrelaycfg as $dhcrelayif => $dhcrelayifconf) {
2432
			if (isset($dhcrelayifconf['enable'])) {
2433 2f06cc3f Ermal
				$dhcrelayifs[] = $dhcrelayif;
2434
				unset($dhcrelaycfg['dhcrelayif']);
2435
				$foundifs = true;
2436
			}
2437 2d563280 Renato Botelho
		}
2438 2f06cc3f Ermal
		if ($foundifs == true)
2439
			$dhcrelaycfg['interface'] = implode(",", $dhcrelayifs);
2440 2d563280 Renato Botelho
	}
2441 2f06cc3f Ermal
}
2442
2443 9ad72e5e jim-p
function upgrade_066_to_067() {
2444
	global $config;
2445
	if (isset($config['system']['ca'])) {
2446
		$config['ca'] = $config['system']['ca'];
2447
	}
2448
	if (isset($config['system']['cert'])) {
2449
		$config['cert'] = $config['system']['cert'];
2450
	}
2451
}
2452
2453 6ae9f9b7 Ermal
function upgrade_067_to_068() {
2454
	global $config;
2455
2456
	if (!empty($config['pppoe'])) {
2457
		$config['pppoes'] = array();
2458
		$config['pppoes']['pppoe'] = array();
2459
		$config['pppoes']['pppoe'][] = $config['pppoe'][0];
2460 ce968051 Ermal
2461
		if (is_array($config['pppoe']['user'])) {
2462 2d563280 Renato Botelho
			$username = array();
2463 ce968051 Ermal
			foreach ($config['pppoe']['user'] as $user) {
2464 2fc29020 Ermal
				$usr = $user['name'] . ":" . base64_encode($user['password']);
2465 ce968051 Ermal
				if ($user['ip'])
2466
					$usr .= ":{$user['ip']}";
2467
				$username[] = $usr;
2468
			}
2469
			$config['pppoes']['pppoe'][0]['username'] = implode(" ", $username);
2470
		}
2471 6ae9f9b7 Ermal
		unset($config['pppoe']);
2472
	}
2473
}
2474
2475 18de0728 Ermal
function upgrade_068_to_069() {
2476 8fefb9dd jim-p
	global $config;
2477
	if (!is_array($config['system']['user']))
2478
		return;
2479
	foreach ($config['system']['user'] as & $user) {
2480
		if (!is_array($user['cert']))
2481
			continue;
2482
		$rids = array();
2483
		foreach ($user['cert'] as $id => $cert) {
2484 f2a86ca9 jim-p
			if (!isset($cert['descr']))
2485 8fefb9dd jim-p
				continue;
2486
			$tcert = $cert;
2487
			// Make sure each cert gets a refid
2488
			if (!isset($tcert['refid']))
2489
				$tcert['refid'] = uniqid();
2490
			// Keep the cert references for this user
2491
			$rids[] = $tcert['refid'];
2492
			$config['cert'][] = $tcert;
2493
		}
2494
		// Replace user certs with cert references instead.
2495
		if (count($rids) > 0)
2496
			$user['cert'] = $rids;
2497
	}
2498
}
2499
2500 4c5b8653 Erik Fonnesbeck
function upgrade_069_to_070() {
2501
	global $config;
2502
2503
	/* Convert NAT 1:1 rules */
2504
	if (is_array($config['nat']['onetoone'])) {
2505 a3bac4ce Ermal
		foreach ($config['nat']['onetoone'] as $nidx => $natent) {
2506 4c5b8653 Erik Fonnesbeck
			if ($natent['subnet'] == 32)
2507 a3bac4ce Ermal
				$config['nat']['onetoone'][$nidx]['source'] = array("address" => $natent['internal']);
2508 4c5b8653 Erik Fonnesbeck
			else
2509 a3bac4ce Ermal
				$config['nat']['onetoone'][$nidx]['source'] = array("address" => $natent['internal'] . "/" . $natent['subnet']);
2510 4c5b8653 Erik Fonnesbeck
2511 a3bac4ce Ermal
			$config['nat']['onetoone'][$nidx]['destination'] = array("any" => true);
2512 4c5b8653 Erik Fonnesbeck
2513 a3bac4ce Ermal
			unset($config['nat']['onetoone'][$nidx]['internal']);
2514
			unset($config['nat']['onetoone'][$nidx]['subnet']);
2515 4c5b8653 Erik Fonnesbeck
		}
2516
2517
		unset($natent);
2518
	}
2519
}
2520
2521 65167fcc Ermal
function upgrade_070_to_071() {
2522
	global $config;
2523
2524
	if (is_array($config['cron']['item'])) {
2525
		foreach($config['cron']['item'] as $idx => $cronitem) {
2526 f21c7979 Ermal
			if(stristr($cronitem['command'], "checkreload.sh")) {
2527 65167fcc Ermal
				unset($config['cron']['item'][$idx]);
2528
				break;
2529
			}
2530
		}
2531
	}
2532
}
2533 15864861 jim-p
2534 6751b3e7 jim-p
function rename_field(& $section, $oldname, $newname) {
2535 e988813d jim-p
	if (is_array($section)) {
2536
		foreach($section as & $item) {
2537 5962f766 jim-p
			if (is_array($item) && !empty($item[$oldname]))
2538 6751b3e7 jim-p
				$item[$newname] = $item[$oldname];
2539 5962f766 jim-p
			if (is_array($item) && isset($item[$oldname]))
2540 6751b3e7 jim-p
				unset($item[$oldname]);
2541 e988813d jim-p
		}
2542
	}
2543
}
2544
2545 6751b3e7 jim-p
function upgrade_071_to_072() {
2546
	global $config;
2547 6bef0554 jim-p
	if (is_array($config['sysctl']) && is_array($config['sysctl']['item']))
2548
		rename_field($config['sysctl']['item'], 'desc', 'descr');
2549 6751b3e7 jim-p
}
2550
2551 e988813d jim-p
function upgrade_072_to_073() {
2552
	global $config;
2553 6bef0554 jim-p
	if (!is_array($config['load_balancer']))
2554
		return;
2555
	if (is_array($config['load_balancer']['monitor_type']))
2556
		rename_field($config['load_balancer']['monitor_type'], 'desc', 'descr');
2557
	if (is_array($config['load_balancer']['lbpool']))
2558
		rename_field($config['load_balancer']['lbpool'], 'desc', 'descr');
2559
	if (is_array($config['load_balancer']['lbaction']))
2560
		rename_field($config['load_balancer']['lbaction'], 'desc', 'descr');
2561
	if (is_array($config['load_balancer']['lbprotocol']))
2562
		rename_field($config['load_balancer']['lbprotocol'], 'desc', 'descr');
2563
	if (is_array($config['load_balancer']['virtual_server']))
2564
		rename_field($config['load_balancer']['virtual_server'], 'desc', 'descr');
2565 e988813d jim-p
}
2566 9ff73b79 jim-p
2567
function upgrade_073_to_074() {
2568
	global $config;
2569 6751b3e7 jim-p
	rename_field($config['system']['user'], 'fullname', 'descr');
2570 9ff73b79 jim-p
}
2571 f2a86ca9 jim-p
2572
function upgrade_074_to_075() {
2573
	global $config;
2574 6bef0554 jim-p
	if (is_array($config['ca']))
2575
		rename_field($config['ca'], 'name', 'descr');
2576
	if (is_array($config['cert']))
2577
		rename_field($config['cert'], 'name', 'descr');
2578
	if (is_array($config['crl']))
2579
		rename_field($config['crl'], 'name', 'descr');
2580 f2a86ca9 jim-p
}
2581 9734b054 Scott Ullrich
2582 d0dc2fd1 jim-p
function upgrade_075_to_076() {
2583 7d9b3d5e jim-p
	global $config;
2584
	$cron_item = array();
2585
	$cron_item['minute'] = "30";
2586
	$cron_item['hour'] = "12";
2587
	$cron_item['mday'] = "*";
2588
	$cron_item['month'] = "*";
2589
	$cron_item['wday'] = "*";
2590
	$cron_item['who'] = "root";
2591
	$cron_item['command'] = "/usr/bin/nice -n20 /etc/rc.update_urltables";
2592
	$config['cron']['item'][] = $cron_item;
2593 d0dc2fd1 jim-p
}
2594
2595 9bc8b6b6 Seth Mos
function upgrade_076_to_077() {
2596 9956b38a Seth Mos
	global $config;
2597
	foreach($config['filter']['rule'] as & $rule) {
2598
	if (isset($rule['protocol']) && !empty($rule['protocol']))
2599
		$rule['protocol'] = strtolower($rule['protocol']);
2600
	}
2601
}
2602
2603
function upgrade_077_to_078() {
2604 f33030aa jim-p
	global $config;
2605 7171b7b6 jim-p
	if (is_array($config['pptpd']) && is_array($config['pptpd']['radius'])
2606
		&& !is_array($config['pptpd']['radius']['server'])) {
2607
		$radarr = array();
2608
		$radsvr = array();
2609
		$radsvr['ip'] = $config['pptpd']['radius']['server'];
2610
		$radsvr['secret'] = $config['pptpd']['radius']['secret'];
2611
		$radsvr['port'] = 1812;
2612
		$radsvr['acctport'] = 1813;
2613
		$radsvr['enable'] = isset($config['pptpd']['radius']['enable']);
2614
		$radarr['accounting'] = isset($config['pptpd']['radius']['accounting']);
2615
		if ($radarr['accounting'])
2616
			$radarr['acct_update'] = $radsvr['ip'];
2617
		$radarr['server'] = $radsvr;
2618
		$config['pptpd']['radius'] = $radarr;
2619
	}
2620 f7c8f633 jim-p
	if (is_array($config['pptpd'])) {
2621
		$config['pptpd']['n_pptp_units'] = empty($config['pptpd']['n_pptp_units']) ? 16 : $config['pptpd']['n_pptp_units'];
2622
	}
2623 7171b7b6 jim-p
}
2624 27d0722d jim-p
function upgrade_078_to_079() {
2625 838e4eb8 Warren Baker
	global $g;
2626 5c723d9f Warren Baker
	/* Delete old and unused RRD file */
2627 838e4eb8 Warren Baker
	unlink_if_exists("{$g['vardb_path']}/rrd/captiveportal-totalusers.rrd");
2628 5c723d9f Warren Baker
}
2629
2630 58005e52 jim-p
function upgrade_079_to_080() {
2631 9bc8b6b6 Seth Mos
	global $config;
2632 e6ee8fc6 Ermal
2633
	/* Upgrade config in 1.2.3 specifying a username other than admin for synching. */
2634
	if (!empty($config['system']['username']) && is_array($config['installedpackages']['carpsettings']) &&
2635
		is_array($config['installedpackages']['carpsettings']['config'])) {
2636
		$config['installedpackages']['carpsettings']['config'][0]['username'] = $config['system']['username'];
2637
		unset($config['system']['username']);
2638
	}
2639
}
2640
2641 e49d4564 jim-p
function upgrade_080_to_081() {
2642
	global $config;
2643 9bc8b6b6 Seth Mos
	global $g;
2644 ff6677cf smos
	/* Welcome to the 2.1 migration path */
2645
2646
	/* tag all the existing gateways as being IPv4 */
2647
	$i = 0;
2648
	if(is_array($config['gateways']['gateway_item'])) {
2649
		foreach($config['gateways']['gateway_item'] as $gw) {
2650
			$config['gateways']['gateway_item'][$i]['ipprotocol'] = "inet";
2651
			$i++;
2652
		}
2653
	}
2654 9bc8b6b6 Seth Mos
2655
	/* RRD files changed for quality, traffic and packets graphs */
2656
	/* convert traffic RRD file */
2657
	global $parsedcfg, $listtags;
2658
	$listtags = array("ds", "v", "rra", "row");
2659
2660
	$rrddbpath = "/var/db/rrd/";
2661
	$rrdtool = "/usr/bin/nice -n20 /usr/local/bin/rrdtool";
2662
2663 42ec9337 Renato Botelho
	if ($g['platform'] != "pfSense") {
2664
		/* restore the databases, if we have one */
2665
		if (restore_rrd()) {
2666
			/* Make sure to move the rrd backup out of the way. We will make a new one after converting. */
2667 e1854cad jim-p
			@rename("{$g['cf_conf_path']}/rrd.tgz", "{$g['cf_conf_path']}/backup/rrd.tgz");
2668 42ec9337 Renato Botelho
		}
2669
	}
2670
2671 9bc8b6b6 Seth Mos
	$rrdinterval = 60;
2672
	$valid = $rrdinterval * 2;
2673
2674
	/* Asume GigE for now */
2675
	$downstream = 125000000;
2676
	$upstream = 125000000;
2677
2678
	/* build a list of traffic and packets databases */
2679 84683e42 Renato Botelho
	$databases = return_dir_as_array($rrddbpath, '/-(traffic|packets)\.rrd$/');
2680 9bc8b6b6 Seth Mos
	rsort($databases);
2681
	foreach($databases as $database) {
2682
		$xmldump = "{$database}.old.xml";
2683
		$xmldumpnew = "{$database}.new.xml";
2684
2685 285ef132 Ermal LUÇI
		if (platform_booting())
2686 d55ea970 Seth Mos
			echo "Migrate RRD database {$database} to new format for IPv6.\n";
2687 9bc8b6b6 Seth Mos
2688
		/* dump contents to xml and move database out of the way */
2689
		dump_rrd_to_xml("{$rrddbpath}/{$database}", "{$g['tmp_path']}/{$xmldump}");
2690
2691 fcaa56b1 smos
		/* search and replace tags to add data sources */
2692
		$ds_search = "<!-- Round Robin Archives -->";
2693
		$ds_arr = array();
2694
		$ds_arr[] = "	<ds>
2695
				<name> inpass6 </name>
2696
				<type> COUNTER </type>
2697
				<minimal_heartbeat> {$valid} </minimal_heartbeat>
2698
				<min> 0.0000000000e+00 </min>
2699
				<max> 1.2500000000e+08 </max>
2700
2701
				<!-- PDP Status -->
2702
				<last_ds> 0 </last_ds>
2703
				<value> NaN </value>
2704
				<unknown_sec> 3 </unknown_sec>
2705
			</ds>
2706
			";
2707
		$ds_arr[] = "	<ds>
2708
				<name> outpass6 </name>
2709
				<type> COUNTER </type>
2710
				<minimal_heartbeat> {$valid} </minimal_heartbeat>
2711
				<min> 0.0000000000e+00 </min>
2712
				<max> 1.2500000000e+08 </max>
2713
2714
				<!-- PDP Status -->
2715
				<last_ds> 0 </last_ds>
2716
				<value> NaN </value>
2717
				<unknown_sec> 3 </unknown_sec>
2718
			</ds>
2719
			";
2720
		$ds_arr[] = "	<ds>
2721
				<name> inblock6 </name>
2722
				<type> COUNTER </type>
2723
				<minimal_heartbeat> {$valid} </minimal_heartbeat>
2724
				<min> 0.0000000000e+00 </min>
2725
				<max> 1.2500000000e+08 </max>
2726
2727
				<!-- PDP Status -->
2728
				<last_ds> 0 </last_ds>
2729
				<value> NaN </value>
2730
				<unknown_sec> 3 </unknown_sec>
2731
			</ds>
2732
			";
2733
		$ds_arr[] = "	<ds>
2734
				<name> outblock6 </name>
2735
				<type> COUNTER </type>
2736
				<minimal_heartbeat> {$valid} </minimal_heartbeat>
2737
				<min> 0.0000000000e+00 </min>
2738
				<max> 1.2500000000e+08 </max>
2739
2740
				<!-- PDP Status -->
2741
				<last_ds> 0 </last_ds>
2742
				<value> NaN </value>
2743
				<unknown_sec> 3 </unknown_sec>
2744
			</ds>
2745
			";
2746
2747
		$cdp_search = "<\/cdp_prep>";
2748
		$cdp_replace = "</cdp_prep>";
2749
		$cdp_arr = array();
2750
		$cdp_arr[] = "			<ds>
2751
					<primary_value> NaN </primary_value>
2752
					<secondary_value> 0.0000000000e+00 </secondary_value>
2753
					<value> NaN </value>
2754
					<unknown_datapoints> 0 </unknown_datapoints>
2755
					</ds>
2756
		";
2757
		$cdp_arr[] = "			<ds>
2758
					<primary_value> NaN </primary_value>
2759
					<secondary_value> 0.0000000000e+00 </secondary_value>
2760
					<value> NaN </value>
2761
					<unknown_datapoints> 0 </unknown_datapoints>
2762
					</ds>
2763
		";
2764
		$cdp_arr[] = "			<ds>
2765
					<primary_value> NaN </primary_value>
2766
					<secondary_value> 0.0000000000e+00 </secondary_value>
2767
					<value> NaN </value>
2768
					<unknown_datapoints> 0 </unknown_datapoints>
2769
					</ds>
2770
		";
2771
		$cdp_arr[] = "			<ds>
2772
					<primary_value> NaN </primary_value>
2773
					<secondary_value> 0.0000000000e+00 </secondary_value>
2774
					<value> NaN </value>
2775
					<unknown_datapoints> 0 </unknown_datapoints>
2776
					</ds>
2777
		";
2778
2779
		$value_search = "<\/row>";
2780
		$value_replace = "</row>";
2781
		$value = "<v> NaN </v>";
2782
2783
		$xml = file_get_contents("{$g['tmp_path']}/{$xmldump}");
2784
		foreach($ds_arr as $ds) {
2785
			$xml = preg_replace("/$ds_search/s", "$ds{$ds_search}", $xml);
2786
		}
2787
		foreach($cdp_arr as $cdp) {
2788
			$xml = preg_replace("/$cdp_search/s", "$cdp{$cdp_replace}", $xml);
2789
		}
2790
		foreach($ds_arr as $ds) {
2791
			$xml = preg_replace("/$value_search/s", "$value{$value_replace}", $xml);
2792
		}
2793
		
2794
		file_put_contents("{$g['tmp_path']}/{$xmldumpnew}", $xml);
2795
		mwexec("$rrdtool restore -f {$g['tmp_path']}/{$xmldumpnew} {$rrddbpath}/{$database} 2>&1");
2796
		unset($xml);
2797 73c569ea Xon
		# Default /tmp tmpfs is ~40mb, do not leave temp files around
2798 48047e3f Renato Botelho
		unlink_if_exists("{$g['tmp_path']}/{$xmldump}");
2799
		unlink_if_exists("{$g['tmp_path']}/{$xmldumpnew}");
2800 9bc8b6b6 Seth Mos
	}
2801 e546d2d1 Ermal LUÇI
	if (!platform_booting())
2802
		enable_rrd_graphing();
2803 42ec9337 Renato Botelho
	/* Let's save the RRD graphs after we run enable RRD graphing */
2804
	/* The function will restore the rrd.tgz so we will save it after */
2805
	exec("cd /; LANG=C NO_REMOUNT=1 RRDDBPATH='{$rrddbpath}' CF_CONF_PATH='{$g['cf_conf_path']}' /etc/rc.backup_rrd.sh");
2806 285ef132 Ermal LUÇI
	if (platform_booting())
2807 9bc8b6b6 Seth Mos
		echo "Updating configuration...";
2808 7ec0e6e2 jim-p
	foreach($config['filter']['rule'] as & $rule) {
2809 1c1a74fa jim-p
		if (isset($rule['protocol']) && !empty($rule['protocol']))
2810
			$rule['protocol'] = strtolower($rule['protocol']);
2811 7ec0e6e2 jim-p
	}
2812 17640b28 Ermal
	unset($rule);
2813 9bc8b6b6 Seth Mos
}
2814
2815 e49d4564 jim-p
function upgrade_081_to_082() {
2816 4cdf35a4 Chris Buechler
	/* don't enable the allow IPv6 toggle */
2817 1f116988 Seth Mos
}
2818 b4792bf8 Ermal
2819
function upgrade_082_to_083() {
2820
	global $config;
2821 7b47bd4c Ermal
2822 b4792bf8 Ermal
	/* Upgrade captiveportal config */
2823
	if (!empty($config['captiveportal'])) {
2824
		$tmpcp = $config['captiveportal'];
2825
		$config['captiveportal'] = array();
2826 17640b28 Ermal
		$config['captiveportal']['cpzone'] = array();
2827
		$config['captiveportal']['cpzone'] = $tmpcp;
2828
		$config['captiveportal']['cpzone']['zoneid'] = 8000;
2829 26b6e758 jim-p
		$config['captiveportal']['cpzone']['zone'] = "cpzone";
2830 2d72659a Renato Botelho
		if ($config['captiveportal']['cpzone']['auth_method'] == "radius")
2831
			$config['captiveportal']['cpzone']['radius_protocol'] = "PAP";
2832 b4792bf8 Ermal
	}
2833 67e73dcd Ermal
	if (!empty($config['voucher'])) {
2834
		$tmpcp = $config['voucher'];
2835
		$config['voucher'] = array();
2836 17640b28 Ermal
		$config['voucher']['cpzone'] = array();
2837
		$config['voucher']['cpzone'] = $tmpcp;
2838 67e73dcd Ermal
	}
2839 b4792bf8 Ermal
}
2840 67e73dcd Ermal
2841 f97a5b04 Darren Embry
function upgrade_083_to_084() {
2842
	global $config;
2843
	if (!isset($config['hasync'])) {
2844
		if (!empty($config['installedpackages']) &&
2845
		    !empty($config['installedpackages']['carpsettings']) &&
2846
		    !empty($config['installedpackages']['carpsettings']['config'])) {
2847
			$config['hasync'] = $config['installedpackages']['carpsettings']['config'][0];
2848
			unset($config['installedpackages']['carpsettings']);
2849
		}
2850
		if (empty($config['installedpackages']['carpsettings'])) {
2851
			unset($config['installedpackages']['carpsettings']);
2852
		}
2853
		if (empty($config['installedpackages'])) {
2854
			unset($config['installedpackages']);
2855
		}
2856
	}
2857
}
2858
2859 c3ce2ece smos
function upgrade_084_to_085() {
2860
	global $config;
2861
2862
	$gateway_group_arr = array();
2863
	$gateways = return_gateways_array();
2864
	$oldnames = array();
2865
	/* setup translation array */
2866
	foreach($gateways as $name => $gw) {
2867
		if(isset($gw['dynamic'])){
2868
			$oldname = strtoupper($config['interfaces'][$gw['friendlyiface']]['descr']);
2869 2d563280 Renato Botelho
			$oldnames[$oldname] = $name;
2870 c3ce2ece smos
		} else {
2871
			$oldnames[$name] = $name;
2872
		}
2873
	}
2874
2875
	/* process the old array */
2876
	if(is_array($config['gateways']['gateway_group'])) {
2877
		$group_array_new = array();
2878
		foreach($config['gateways']['gateway_group'] as $name => $group) {
2879
			if(is_array($group['item'])) {
2880
				$newlist = array();
2881
				foreach($group['item'] as $entry) {
2882
					$elements = explode("|", $entry);
2883
					if($oldnames[$elements[0]] <> "") {
2884
						$newlist[] = "{$oldnames[$elements[0]]}|{$elements[1]}";
2885 da12a8a4 smos
					} else {
2886
						$newlist[] = "{$elements[0]}|{$elements[1]}";
2887 c3ce2ece smos
					}
2888
				}
2889
				$group['item'] = $newlist;
2890
				$group_array_new[$name] = $group;
2891
			}
2892
		}
2893
		$config['gateways']['gateway_group'] = $group_array_new;
2894
	}
2895 d4d5f7b4 smos
	/* rename old Quality RRD files in the process */
2896
	$rrddbpath = "/var/db/rrd";
2897
	foreach($oldnames as $old => $new) {
2898
		if(is_readable("{$rrddbpath}/{$old}-quality.rrd")) {
2899 17640b28 Ermal
			@rename("{$rrddbpath}/{$old}-quality.rrd", "{$rrddbpath}/{$new}-quality.rrd");
2900 d4d5f7b4 smos
		}
2901
	}
2902 17640b28 Ermal
	unset($gateways, $oldnames, $gateway_group_arr);
2903 c3ce2ece smos
}
2904
2905 b22fc825 jim-p
function upgrade_085_to_086() {
2906 879f7db7 Erik Fonnesbeck
	global $config, $g;
2907 b22fc825 jim-p
2908
	/* XXX: Gross hacks in sight */
2909 12766374 Erik Fonnesbeck
	if (is_array($config['virtualip']['vip'])) {
2910 b22fc825 jim-p
		$vipchg = array();
2911 12766374 Erik Fonnesbeck
		foreach ($config['virtualip']['vip'] as $vip) {
2912 fbda07b9 Ermal
			if ($vip['mode'] != "carp")
2913
				continue;
2914 f2cc3344 Renato Botelho
			$config = array_replace_values_recursive(
2915
				$config,
2916
				'^vip' . $vip['vhid'] . '$',
2917
				"{$vip['interface']}_vip{$vip['vhid']}"
2918
			);
2919 fe47f1f2 Erik Fonnesbeck
		}
2920 b22fc825 jim-p
	}
2921
}
2922
2923 85a236e9 Ermal
function upgrade_086_to_087() {
2924
	global $config, $dummynet_pipe_list;
2925
2926
	if (!is_array($config['filter']) || !is_array($config['filter']['rule']))
2927
		return;
2928
	if (!is_array($config['dnshaper']) || !is_array($config['dnshaper']['queue']))
2929
		return;
2930
2931
	$dnqueue_number = 1;
2932
	$dnpipe_number = 1;
2933
2934
	foreach ($config['dnshaper']['queue'] as $idx => $dnpipe) {
2935
		$config['dnshaper']['queue'][$idx]['number'] = $dnpipe_number;
2936
		$dnpipe_number++;
2937
		if (is_array($dnpipe['queue'])) {
2938
			foreach ($dnpipe['queue'] as $qidx => $dnqueue) {
2939
				$config['dnshaper']['queue'][$idx]['queue'][$qidx]['number'] = $dnqueue_number;
2940
				$dnqueue_number++;
2941
			}
2942
		}
2943
	}
2944
2945
	unset($dnqueue_number, $dnpipe_number, $qidx, $idx, $dnpipe, $dnqueue);
2946
2947
	require_once("shaper.inc");
2948
	read_dummynet_config();
2949
2950 628306af Ermal
	$dn_list = array();
2951 2d563280 Renato Botelho
	if (is_array($dummynet_pipe_list)) {
2952
		foreach ($dummynet_pipe_list as $dn) {
2953
			$tmplist =& $dn->get_queue_list();
2954
			foreach ($tmplist as $qname => $link) {
2955
				$dn_list[$link] = $qname;
2956
			}
2957
		}
2958 17640b28 Ermal
		unset($dummynet_pipe_list);
2959 2d563280 Renato Botelho
	}
2960 628306af Ermal
2961 85a236e9 Ermal
	foreach ($config['filter']['rule'] as $idx => $rule) {
2962
		if (!empty($rule['dnpipe'])) {
2963 628306af Ermal
			if (!empty($dn_list[$rule['dnpipe']]))
2964
				$config['filter']['rule'][$idx]['dnpipe'] = $dn_list[$rule['dnpipe']];
2965 85a236e9 Ermal
		}
2966
		if (!empty($rule['pdnpipe'])) {
2967 628306af Ermal
			if (!empty($dn_list[$rule['pdnpipe']]))
2968
				$config['filter']['rule'][$idx]['pdnpipe'] = $dn_list[$rule['pdnpipe']];
2969 85a236e9 Ermal
		}
2970
	}
2971
}
2972 7530177c jim-p
function upgrade_087_to_088() {
2973
	global $config;
2974
	if (isset($config['system']['glxsb_enable'])) {
2975
		unset($config['system']['glxsb_enable']);
2976
		$config['system']['crypto_hardware'] = "glxsb";
2977
	}
2978
}
2979 36f6ed35 bcyrill
2980
function upgrade_088_to_089() {
2981 2d563280 Renato Botelho
	global $config;
2982
	if (!is_array($config['ca']))
2983
		$config['ca'] = array();
2984
	if (!is_array($config['cert']))
2985
		$config['cert'] = array();
2986
2987
	/* migrate captive portal ssl to certifcate mngr */
2988
	if (is_array($config['captiveportal'])) {
2989
		foreach ($config['captiveportal'] as $id => &$setting) {
2990
			if (isset($setting['httpslogin'])) {
2991
				/* create cert entry */
2992
				$cert = array();
2993
				$cert['refid'] = uniqid();
2994
				$cert['descr'] = "Captive Portal Cert - {$setting['zone']}";
2995
				$cert['crt'] = $setting['certificate'];
2996
				$cert['prv'] = $setting['private-key'];
2997
2998
				if (!empty($setting['cacertificate'])) {
2999
					/* create ca entry */
3000
					$ca = array();
3001
					$ca['refid'] = uniqid();
3002
					$ca['descr'] = "Captive Portal CA - {$setting['zone']}";
3003
					$ca['crt'] = $setting['cacertificate'];
3004
					$config['ca'][] = $ca;
3005
3006
					/* add ca reference to certificate */
3007
					$cert['caref'] = $ca['refid'];
3008
				}
3009
3010
				$config['cert'][] = $cert;
3011
3012
				/* create cert reference */
3013
				$setting['certref'] = $cert['refid'];
3014
3015
				unset($setting['certificate']);
3016
				unset($setting['private-key']);
3017
				unset($setting['cacertificate']);
3018
3019
			}
3020
		}
3021
	}
3022 36f6ed35 bcyrill
}
3023 2d563280 Renato Botelho
3024 6e9b046e jim-p
function upgrade_089_to_090() {
3025
	global $config;
3026
	if (is_array($config['load_balancer']['virtual_server']) && count($config['load_balancer']['virtual_server'])) {
3027
		$vs_a = &$config['load_balancer']['virtual_server'];
3028
		for ($i = 0; isset($vs_a[$i]); $i++) {
3029
			if (is_array($vs_a[$i]['pool'])) {
3030
				$vs_a[$i]['poolname'] = $vs_a[$i]['pool'][0];
3031
				unset($vs_a[$i]['pool']);
3032
			} elseif (!empty($vs_a[$i]['pool'])) {
3033
				$vs_a[$i]['poolname'] = $vs_a[$i]['pool'];
3034
				unset($vs_a[$i]['pool']);
3035
			}
3036
		}
3037
	}
3038
}
3039 c9ba2f8a Ermal
3040
function upgrade_090_to_091() {
3041
	global $config;
3042
3043
	if (is_array($config['dnshaper']) && is_array($config['dnshaper']['queue'])) {
3044
		foreach ($config['dnshaper']['queue'] as $idx => $dnqueue) {
3045
			if (!empty($dnqueue['bandwidth'])) {
3046
				$bw = array();
3047
				$bw['bw'] = $dnqueue['bandwidth'];
3048
				$bw['bwscale'] = $dnqueue['bandwidthtype'];
3049
				$bw['bwsched'] = "none";
3050
				$config['dnshaper']['queue'][$idx]['bandwidth'] = array();
3051
				$config['dnshaper']['queue'][$idx]['bandwidth']['item'] = array();
3052
				$config['dnshaper']['queue'][$idx]['bandwidth']['item'][] = $bw;
3053
			}
3054
		}
3055
	}
3056
}
3057 e99ba2d6 Renato Botelho
3058
function upgrade_091_to_092() {
3059
	global $config;
3060
3061
	if (is_array($config['nat']['advancedoutbound']) && is_array($config['nat']['advancedoutbound']['rule'])) {
3062
		$nat_rules = &$config['nat']['advancedoutbound']['rule'];
3063
		for ($i = 0; isset($nat_rules[$i]); $i++) {
3064
			if (empty($nat_rules[$i]['interface'])) {
3065
				$nat_rules[$i]['interface'] = 'wan';
3066
			}
3067
		}
3068
	}
3069
}
3070 2d563280 Renato Botelho
3071 cba9d7d9 Renato Botelho
function upgrade_092_to_093() {
3072
	global $g;
3073
3074
	$suffixes = array("concurrent", "loggedin");
3075
3076
	foreach ($suffixes as $suffix)
3077
		if (file_exists("{$g['vardb_path']}/rrd/captiveportal-{$suffix}.rrd"))
3078
			rename("{$g['vardb_path']}/rrd/captiveportal-{$suffix}.rrd",
3079
				"{$g['vardb_path']}/rrd/captiveportal-cpZone-{$suffix}.rrd");
3080
3081 e546d2d1 Ermal LUÇI
	if (!platform_booting())
3082
		enable_rrd_graphing();
3083 cba9d7d9 Renato Botelho
}
3084
3085 6015f75b N0YB
function upgrade_093_to_094() {
3086
	global $config;
3087
3088
	if (isset($config['system']['powerd_mode'])) {
3089
		$config['system']['powerd_ac_mode'] = $config['system']['powerd_mode'];
3090
		$config['system']['powerd_battery_mode'] = $config['system']['powerd_mode'];
3091
		unset($config['system']['powerd_mode']);
3092
	}
3093
}
3094
3095 02203e6d Renato Botelho
function upgrade_094_to_095() {
3096
	global $config;
3097
3098
	if (!isset($config['interfaces']) || !is_array($config['interfaces']))
3099
		return;
3100
3101
	foreach ($config['interfaces'] as $iface => $cfg)
3102
		if (isset($cfg['ipaddrv6']) && ($cfg['ipaddrv6'] == "track6"))
3103
			if (!isset($cfg['track6-prefix-id']) || ($cfg['track6-prefix-id'] == ""))
3104
				$config['interfaces'][$iface]['track6-prefix-id'] = 0;
3105
}
3106
3107 fa3b33a5 Renato Botelho
function upgrade_095_to_096() {
3108
	global $config, $g;
3109
3110
	$names = array("inpass", "outpass", "inblock", "outblock",
3111
		"inpass6", "outpass6", "inblock6", "outblock6");
3112
	$rrddbpath = "/var/db/rrd";
3113
	$rrdtool = "/usr/local/bin/rrdtool";
3114
3115 42ec9337 Renato Botelho
	if ($g['platform'] != "pfSense") {
3116
		/* restore the databases, if we have one */
3117
		if (restore_rrd()) {
3118
			/* Make sure to move the rrd backup out of the way. We will make a new one after converting. */
3119 8560c756 jim-p
			@rename("{$g['cf_conf_path']}/rrd.tgz", "{$g['cf_conf_path']}/backup/rrd.tgz");
3120 42ec9337 Renato Botelho
		}
3121
	}
3122
3123 fa3b33a5 Renato Botelho
	/* Assume 2*10GigE for now */
3124
	$stream = 2500000000;
3125
3126
	/* build a list of traffic and packets databases */
3127
	$databases = return_dir_as_array($rrddbpath, '/-(traffic|packets)\.rrd$/');
3128
	rsort($databases);
3129
	foreach($databases as $database) {
3130 285ef132 Ermal LUÇI
		if (platform_booting())
3131 fa3b33a5 Renato Botelho
			echo "Update RRD database {$database}.\n";
3132
3133
		$cmd = "{$rrdtool} tune {$rrddbpath}/{$database}";
3134
		foreach ($names as $name)
3135
			$cmd .= " -a {$name}:{$stream}";
3136
		mwexec("{$cmd} 2>&1");
3137
3138
	}
3139 e546d2d1 Ermal LUÇI
	if (!platform_booting())
3140
		enable_rrd_graphing();
3141 42ec9337 Renato Botelho
	/* Let's save the RRD graphs after we run enable RRD graphing */
3142
	/* The function will restore the rrd.tgz so we will save it after */
3143
	exec("cd /; LANG=C NO_REMOUNT=1 RRDDBPATH='{$rrddbpath}' CF_CONF_PATH='{$g['cf_conf_path']}' /etc/rc.backup_rrd.sh");
3144 fa3b33a5 Renato Botelho
}
3145
3146 1cf24f0a jim-p
function upgrade_096_to_097() {
3147
	global $config, $g;
3148
	/* If the user had disabled default block rule logging before, then bogon/private network logging was already off, so respect their choice. */
3149
	if (isset($config['syslog']['nologdefaultblock'])) {
3150
		$config['syslog']['nologbogons'] = true;
3151
		$config['syslog']['nologprivatenets'] = true;
3152
	}
3153
}
3154 af0a477a Renato Botelho
3155
function upgrade_097_to_098() {
3156
	global $config, $g;
3157
	/* Disable kill_states by default */
3158
	$config['system']['kill_states'] = true;
3159
}
3160 67e5e3c6 Renato Botelho
3161
function upgrade_098_to_099() {
3162 a3cc1409 jim-p
	global $config;
3163 759a6fcf Ermal
3164
	if (empty($config['dhcpd']) || !is_array($config['dhcpd']))
3165
		return;
3166
3167 a3cc1409 jim-p
	foreach ($config['dhcpd'] as & $dhcpifconf) {
3168
		if (isset($dhcpifconf['next-server'])) {
3169
			$dhcpifconf['nextserver'] = $dhcpifconf['next-server'];
3170 aa0753e3 jim-p
			unset($dhcpifconf['next-server']);
3171 a3cc1409 jim-p
		}
3172
	}
3173
}
3174
3175
function upgrade_099_to_100() {
3176
	require_once("/etc/inc/services.inc");
3177
	install_cron_job("/usr/bin/nice -n20 newsyslog", false);
3178
}
3179
3180 20dad315 Ermal
function upgrade_100_to_101() {
3181
	global $config, $g;
3182
3183
	if (!is_array($config['voucher']))
3184
		return;
3185
3186
	foreach ($config['voucher'] as $cpzone => $cp) {
3187
		if (!is_array($cp['roll']))
3188
			continue;
3189
		foreach ($cp['roll'] as $ridx => $rcfg) {
3190
			if (!empty($rcfg['comment']))
3191
				$config['voucher'][$cpzone]['roll'][$ridx]['descr'] = $rcfg['comment'];
3192
		}
3193
	}
3194
}
3195
3196 eae91304 Ermal
function upgrade_101_to_102() {
3197 67e5e3c6 Renato Botelho
	global $config, $g;
3198
3199 ee34e137 Phil Davis
	if (is_array($config['captiveportal'])) {
3200
		foreach ($config['captiveportal'] as $cpzone => $cp) {
3201
			if (!is_array($cp['passthrumac']))
3202
				continue;
3203 67e5e3c6 Renato Botelho
3204 ee34e137 Phil Davis
			foreach ($cp['passthrumac'] as $idx => $passthrumac)
3205
				$config['captiveportal'][$cpzone]['passthrumac'][$idx]['action'] = 'pass';
3206
		}
3207 67e5e3c6 Renato Botelho
	}
3208 edba1982 jim-p
3209 eae91304 Ermal
	/* Convert OpenVPN Compression option to the new style */
3210 edba1982 jim-p
	// Nothing to do if there is no OpenVPN tag
3211 ee34e137 Phil Davis
	if (isset($config['openvpn']) && is_array($config['openvpn'])) {
3212
		if (is_array($config['openvpn']['openvpn-server'])) {
3213
			foreach ($config['openvpn']['openvpn-server'] as &$vpn) {
3214
				if (!empty($vpn['compression']))
3215
					$vpn['compression'] = "adaptive";
3216
			}
3217 edba1982 jim-p
		}
3218 ee34e137 Phil Davis
		if (is_array($config['openvpn']['openvpn-client'])) {
3219
			foreach ($config['openvpn']['openvpn-client'] as &$vpn) {
3220
				if (!empty($vpn['compression']))
3221
					$vpn['compression'] = "adaptive";
3222
			}
3223 edba1982 jim-p
		}
3224
	}
3225
}
3226 eef01b14 Renato Botelho
3227
function upgrade_102_to_103() {
3228
	global $config;
3229
3230
	if (isset($config['nat']['advancedoutbound']['enable'])) {
3231
		$config['nat']['advancedoutbound']['mode'] = "advanced";
3232
		unset($config['nat']['advancedoutbound']['enable']);
3233
	} else
3234
		$config['nat']['advancedoutbound']['mode'] = "automatic";
3235
3236
	$config['nat']['outbound'] = $config['nat']['advancedoutbound'];
3237
3238
	unset($config['nat']['ipsecpassthru']);
3239
	unset($config['nat']['advancedoutbound']);
3240
}
3241
3242 7997ed44 Renato Botelho
function upgrade_103_to_104() {
3243
	global $config;
3244
3245
	$changed_privs = array(
3246
		"page-diag-system-activity" => "page-diagnostics-system-activity",
3247
		"page-interfacess-groups" => "page-interfaces-groups",
3248
		"page-interfacess-lagg" => "page-interfaces-lagg",
3249
		"page-interfacess-qinq" => "page-interfaces-qinq"
3250
	);
3251
3252
	/* update user privileges */
3253
	foreach ($config['system']['user'] as & $user) {
3254
		if (!is_array($user['priv']))
3255
			continue;
3256
		foreach ($user['priv'] as & $priv) {
3257
			if (array_key_exists($priv, $changed_privs))
3258
				$priv = $changed_privs[$priv];
3259
		}
3260
	}
3261
3262
	/* update group privileges */
3263
	foreach ($config['system']['group'] as & $group) {
3264
		if (!is_array($group['priv']))
3265
			continue;
3266
		foreach ($group['priv'] as & $priv) {
3267
			if (array_key_exists($priv, $changed_privs))
3268
				$priv = $changed_privs[$priv];
3269
		}
3270
	}
3271
3272
	/* sync all local account information */
3273
	local_sync_accounts();
3274
}
3275
3276 0a806969 Ermal
function upgrade_104_to_105() {
3277
	global $config;
3278
3279
	if (is_array($config['captiveportal'])) {
3280
		$zoneid = 2;
3281
		foreach ($config['captiveportal'] as $cpzone => $cpcfg) {
3282
			if (empty($cpfg['zoneid'])) {
3283
				$config['captiveportal'][$cpzone]['zoneid'] = $zoneid;
3284
				$zoneid += 2;
3285
			} else if ($cpcfg['zoneid'] > 4000) {
3286
				$config['captiveportal'][$cpzone]['zoneid'] = $zoneid;
3287
				$zoneid += 2;
3288
			}
3289
		}
3290
	}
3291
}
3292
3293 e7d35d84 Ermal
function upgrade_105_to_106() {
3294
3295 6f55af1c Ermal
	/* NOTE: This entry can be reused for something else since the upgrade code was reverted */
3296 e7d35d84 Ermal
}
3297
3298 31dce430 Ermal
function upgrade_106_to_107() {
3299
	global $config;
3300
3301
	if (is_array($config['filter']) && is_array($config['filter']['rule'])) {
3302
		$tracker = (int)microtime(true);
3303
		foreach ($config['filter']['rule'] as $ridx => $rule) {
3304
			if (empty($rule['tracker'])) {
3305
				$config['filter']['rule'][$ridx]['tracker'] = $tracker;
3306
				$tracker++;
3307
			}
3308
		}
3309
		unset($tracker, $ridx);
3310
	}
3311
	if (is_array($config['nat']) && is_array($config['nat']['rule'])) {
3312
		$tracker = (int)microtime(true);
3313
		foreach ($config['nat']['rule'] as $ridx => $rule) {
3314
			if (empty($rule['tracker'])) {
3315
				$config['nat']['rule'][$ridx]['tracker'] = $tracker;
3316
				$tracker++;
3317
			}
3318
3319
		}
3320
		unset($tracker, $ridx);
3321
	}
3322
}
3323
3324 08f30320 Renato Botelho
function upgrade_107_to_108() {
3325
	global $config;
3326
3327
	if (isset($config['system']['webgui']['noautocomplete']))
3328
		unset($config['system']['webgui']['noautocomplete']);
3329
	else
3330
		$config['system']['webgui']['loginautocomplete'] = true;
3331
}
3332
3333 c15b5ed8 Renato Botelho
function upgrade_108_to_109() {
3334
	global $config;
3335
3336
	if (!isset($config['filter']['rule']) || !is_array($config['filter']['rule']))
3337
		return;
3338
3339
	foreach ($config['filter']['rule'] as &$rule) {
3340
		if (!isset($rule['dscp']) || empty($rule['dscp']))
3341
			continue;
3342
3343
		$pos = strpos($rule['dscp'], ' ');
3344
		if ($pos !== false)
3345
			$rule['dscp'] = substr($rule['dscp'], 0, $pos);
3346
		unset($pos);
3347
	}
3348
}
3349
3350 9b915686 Ermal
function upgrade_109_to_110() {
3351
	global $config;
3352
3353
	if (!is_array($config['ipsec']) || !is_array($config['ipsec']['phase2']))
3354
		return;
3355
3356
	foreach ($config['ipsec']['phase2'] as &$rule) {
3357
		if (!empty($rule['uniqid']))
3358
			continue;
3359
3360
		$rule['uniqid'] = uniqid();
3361
	}
3362
}
3363
3364 3f257101 Renato Botelho
function upgrade_110_to_111() {
3365
	global $config;
3366
3367 bdbb4dba Renato Botelho
	/* Make sure unbound user exist */
3368
	mwexec('/usr/sbin/pw groupadd -n unbound -g 59', true);
3369
	mwexec('/usr/sbin/pw useradd -n unbound -c "Unbound DNS Resolver" -d /var/unbound -s /usr/sbin/nologin -u 59 -g 59', true);
3370
3371 c11b7ffe Renato Botelho
	/* cleanup old unbound package stuffs */
3372
	unlink_if_exists("/usr/local/pkg/unbound.xml");
3373
	unlink_if_exists("/usr/local/pkg/unbound.inc");
3374
	unlink_if_exists("/usr/local/pkg/unbound_advanced.xml");
3375
	unlink_if_exists("/usr/local/www/unbound_status.php");
3376
	unlink_if_exists("/usr/local/www/unbound_acls.php");
3377
	unlink_if_exists("/usr/local/bin/unbound_monitor.sh");
3378 b4db2d0e Renato Botelho
	unlink_if_exists("/usr/local/etc/rc.d/unbound.sh");
3379 c11b7ffe Renato Botelho
3380
	/* Remove old menu and service entries */
3381
	if (isset($config['installedpackages']['menu']) && is_array($config['installedpackages']['menu'])) {
3382
		foreach ($config['installedpackages']['menu'] as $idx => $menu) {
3383
			if ($menu['name'] != 'Unbound DNS')
3384
				continue;
3385
3386
			unset($config['installedpackages']['menu'][$idx]);
3387
			break;
3388
		}
3389
	}
3390
3391
	if (isset($config['installedpackages']['service']) && is_array($config['installedpackages']['service'])) {
3392
		foreach ($config['installedpackages']['service'] as $idx => $service) {
3393
			if ($service['name'] != 'unbound')
3394
				continue;
3395
			unset($config['installedpackages']['service'][$idx]);
3396
			break;
3397
		}
3398
	}
3399
3400 3f257101 Renato Botelho
	if (!isset($config['installedpackages']['unbound']['config'][0]))
3401
		return;
3402
3403
	$pkg = $config['installedpackages']['unbound']['config'][0];
3404
3405
	if (isset($config['installedpackages']['unboundadvanced']['config'][0]))
3406
		$pkg = array_merge($pkg, $config['installedpackages']['unboundadvanced']['config'][0]);
3407
3408
	$new = array();
3409
3410
	/* deal first with boolean fields */
3411
	$fields = array(
3412
		"enable" => "enable",
3413
		"dnssec_status" => "dnssec",
3414
		"forwarding_mode" => "forwarding",
3415
		"regdhcp" => "regdhcp",
3416
		"regdhcpstatic" => "regdhcpstatic",
3417
		"txtsupport" => "txtsupport",
3418
		"hide_id" => "hideidentity",
3419
		"hide_version" => "hideversion",
3420
		"prefetch" => "prefetch",
3421
		"prefetch_key" => "prefetchkey",
3422
		"harden_glue" => "hardenglue",
3423
		"harden_dnssec_stripped" => "dnssec_stripped");
3424
3425
	foreach ($fields as $oldk => $newk) {
3426
		if (isset($pkg[$oldk])) {
3427
			if ($pkg[$oldk] == 'on')
3428
				$new[$newk] = true;
3429
			unset($pkg[$oldk]);
3430
		}
3431
	}
3432
3433
	$fields = array(
3434
		"active_interface" => "network_interface",
3435
		"query_interface" => "outgoing_interface",
3436
		"unbound_verbosity" => "log_verbosity",
3437
		"unbound_verbosity" => "log_verbosity",
3438
		"msg_cache_size" => "msgcachesize",
3439
		"outgoing_num_tcp" => "outgoing_num_tcp",
3440
		"incoming_num_tcp" => "incoming_num_tcp",
3441
		"edns_buffer_size" => "edns_buffer_size",
3442
		"num_queries_per_thread" => "num_queries_per_thread",
3443
		"jostle_timeout" => "jostle_timeout",
3444
		"cache_max_ttl" => "cache_max_ttl",
3445
		"cache_min_ttl" => "cache_min_ttl",
3446
		"infra_host_ttl" => "infra_host_ttl",
3447
		"infra_cache_numhosts" => "infra_cache_numhosts",
3448
		"unwanted_reply_threshold" => "unwanted_reply_threshold",
3449
		"custom_options" => "custom_options");
3450
3451
	foreach ($fields as $oldk => $newk) {
3452
		if (isset($pkg[$oldk])) {
3453
			$new[$newk] = $pkg[$oldk];
3454
			unset($pkg[$oldk]);
3455
		}
3456
	}
3457
3458 0fcab48b Renato Botelho
	if (isset($new['custom_options']) && !empty($new['custom_options']))
3459
		$new['custom_options'] = str_replace(';', "\n", $new['custom_options']);
3460
3461 3f257101 Renato Botelho
	/* Following options were removed, bring them as custom_options */
3462
	if (isset($pkg['stats']) && $pkg['stats'] == "on") {
3463
		if (isset($pkg['stats_interval']))
3464 03226d75 Renato Botelho
			$new['custom_options'] .= (empty($new['custom_options']) ? "" : "\n") . "statistics-interval: {$pkg['stats_interval']}";
3465 3f257101 Renato Botelho
		if (isset($pkg['cumulative_stats']))
3466 03226d75 Renato Botelho
			$new['custom_options'] .= (empty($new['custom_options']) ? "" : "\n") . "statistics-cumulative: {$pkg['cumulative_stats']}";
3467 3f257101 Renato Botelho
		if (isset($pkg['extended_stats']) && $pkg['extended_stats'] == "on")
3468 03226d75 Renato Botelho
			$new['custom_options'] .= (empty($new['custom_options']) ? "" : "\n") . "extended-statistics: yes";
3469 3f257101 Renato Botelho
		else
3470 03226d75 Renato Botelho
			$new['custom_options'] .= (empty($new['custom_options']) ? "" : "\n") . "extended-statistics: no";
3471 3f257101 Renato Botelho
	}
3472
3473
	$new['acls'] = array();
3474
	if (isset($config['installedpackages']['unboundacls']['config']) &&
3475
	    is_array($config['installedpackages']['unboundacls']['config'])) {
3476
		foreach ($config['installedpackages']['unboundacls']['config'] as $acl)
3477
			$new['acls'][] = $acl;
3478
	}
3479
3480
	$config['unbound'] = $new;
3481
3482
	if(isset($config['installedpackages']['unbound']))
3483
		unset($config['installedpackages']['unbound']);
3484
	if(isset($config['installedpackages']['unboundadvanced']))
3485
		unset($config['installedpackages']['unboundadvanced']);
3486
	if(isset($config['installedpackages']['unboundacls']))
3487
		unset($config['installedpackages']['unboundacls']);
3488
3489
	unset($pkg, $new);
3490
}
3491
3492 56c8376a Renato Botelho
function upgrade_111_to_112() {
3493
	global $config;
3494
3495
	$config['cron']['item'][] = array(
3496
		'minute' => '*/60',
3497
		'hour' => '*',
3498
		'mday' => '*',
3499
		'month' => '*',
3500
		'wday' => '*',
3501
		'who' => 'root',
3502
		'command' => '/usr/bin/nice -n20 /usr/local/sbin/expiretable -v -t 3600 webConfiguratorlockout'
3503
	);
3504
}
3505
3506 1916d34a Ermal
?>