Project

General

Profile

Download (40.2 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/****h* pfSense/pkg-utils
3
 * NAME
4
 *   pkg-utils.inc - Package subsystem
5
 * DESCRIPTION
6
 *   This file contains various functions used by the pfSense package system.
7
 * HISTORY
8
 *   $Id$
9
 ******
10
 *
11
 * Copyright (C) 2005-2006 Colin Smith (ethethlay@gmail.com)
12
 * All rights reserved.
13
 * Redistribution and use in source and binary forms, with or without
14
 * modification, are permitted provided that the following conditions are met:
15
 *
16
 * 1. Redistributions of source code must retain the above copyright notice,
17
 * this list of conditions and the following disclaimer.
18
 *
19
 * 2. Redistributions in binary form must reproduce the above copyright
20
 * notice, this list of conditions and the following disclaimer in the
21
 * documentation and/or other materials provided with the distribution.
22
 *
23
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
24
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
25
 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26
 * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
27
 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
 * RISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
 * POSSIBILITY OF SUCH DAMAGE.
33
 *
34
 */
35
require_once("xmlrpc.inc");
36
require_once("xmlparse.inc");
37
require_once("service-utils.inc");
38
require_once("pfsense-utils.inc");
39
require_once("globals.inc");
40

    
41
if(!function_exists("update_status")) {
42
	function update_status($status) {
43
		echo $status . "\n";
44
	}
45
}
46
if(!function_exists("update_output_window")) {
47
	function update_output_window($status) {
48
		echo $status . "\n";
49
	}
50
}
51

    
52
safe_mkdir("/var/db/pkg");
53

    
54
$g['platform'] = trim(file_get_contents("/etc/platform"));
55
if($g['platform'] == "pfSense") {
56
	safe_mkdir("/usr/local/pkg");
57
	safe_mkdir("/usr/local/pkg/pf");
58
} else {
59
	if(!is_dir("/usr/local/pkg") or !is_dir("/usr/local/pkg/pf")) {
60
	conf_mount_rw();
61
	safe_mkdir("/usr/local/pkg");
62
	safe_mkdir("/usr/local/pkg/pf");	
63
	conf_mount_ro();
64
	}
65
}
66

    
67
$version = split("-", trim(file_get_contents("/etc/version")));
68
$ver = split("\.", $version[0]);
69
$g['version'] = intval($ver[1]);
70

    
71
/****f* pkg-utils/remove_package
72
 * NAME
73
 *   remove_package - Removes package from FreeBSD if it exists
74
 * INPUTS
75
 *   $packagestring	- name/string to check for
76
 * RESULT
77
 *   none
78
 * NOTES
79
 *   
80
 ******/
81
function remove_freebsd_package($packagestring) {
82
	exec("cd /var/db/pkg && echo y | pkg_delete `ls | grep $packagestring`");
83
}
84

    
85
/****f* pkg-utils/is_package_installed
86
 * NAME
87
 *   is_package_installed - Check whether a package is installed.
88
 * INPUTS
89
 *   $packagename	- name of the package to check
90
 * RESULT
91
 *   boolean	- true if the package is installed, false otherwise
92
 * NOTES
93
 *   This function is deprecated - get_pkg_id() can already check for installation.
94
 ******/
95
function is_package_installed($packagename) {
96
	$pkg = get_pkg_id($packagename);
97
	if($pkg == -1) return false;
98
	return true;
99
}
100

    
101
/****f* pkg-utils/get_pkg_id
102
 * NAME
103
 *   get_pkg_id - Find a package's numeric ID.
104
 * INPUTS
105
 *   $pkg_name	- name of the package to check
106
 * RESULT
107
 *   integer    - -1 if package is not found, >-1 otherwise
108
 ******/
109
function get_pkg_id($pkg_name) {
110
	global $config;
111

    
112
	if(is_array($config['installedpackages']['package'])) {
113
		$i = 0;
114
		foreach($config['installedpackages']['package'] as $pkg) {
115
			if($pkg['name'] == $pkg_name) return $i;
116
			$i++;
117
		}
118
	}
119
	return -1;
120
}
121

    
122
/****f* pkg-utils/get_pkg_info
123
 * NAME
124
 *   get_pkg_info - Retrive package information from pfsense.com.
125
 * INPUTS
126
 *   $pkgs - 'all' to retrive all packages, an array containing package names otherwise
127
 *   $info - 'all' to retrive all information, an array containing keys otherwise
128
 * RESULT
129
 *   $raw_versions - Array containing retrieved information, indexed by package name.
130
 ******/
131
function get_pkg_info($pkgs = 'all', $info = 'all') {
132
	global $g;
133
	$freebsd_version = str_replace("\n", "", `uname -r | cut -d'-' -f1 | cut -d'.' -f1`);
134
	$params = array(
135
		"pkg" => $pkgs, 
136
		"info" => $info, 
137
		"freebsd_version" => $freebsd_version
138
		);
139
	$resp = call_pfsense_method('pfsense.get_pkgs', $params, 10);
140
	return $resp ? $resp : array();
141
}
142

    
143
function get_pkg_sizes($pkgs = 'all') {
144
	global $g;
145
	$params = array("pkg" => $pkgs);
146
	$msg = new XML_RPC_Message('pfsense.get_pkg_sizes', array(php_value_to_xmlrpc($params)));
147
	$cli = new XML_RPC_Client($g['xmlrpcpath'], $g['xmlrpcbaseurl']);
148
	$resp = $cli->send($msg, 10);
149
	if($resp and !$resp->faultCode()) {
150
		$raw_versions = $resp->value();
151
		return xmlrpc_value_to_php($raw_versions);
152
	} else {
153
		return array();
154
	}
155
}
156

    
157
/*
158
 * resync_all_package_configs() Force packages to setup their configuration and rc.d files.
159
 * This function may also print output to the terminal indicating progress.
160
 */
161
function resync_all_package_configs($show_message = false) {
162
	global $config, $restart_sync, $pkg_interface;
163
	$i = 0;
164
	log_error("Resyncing configuration for all packages.");
165
	if(!$config['installedpackages']['package']) return;
166
	if($show_message == true) print "Syncing packages:";
167
	foreach($config['installedpackages']['package'] as $package) {
168
		if($show_message == true) print " " . $package['name'];
169
		get_pkg_depends($package['name'], "all");
170
		stop_service($package['name']);
171
		sync_package($i, true, true);
172
		if($restart_sync == true) {
173
			$restart_sync = false;
174
			if($pkg_interface == "console") 
175
				echo "\nSyncing packages:";
176
		}
177
		$i++;
178
	}
179
	if($show_message == true) print ".\n";
180
}
181

    
182
/*
183
 * is_freebsd_pkg_installed() - Check /var/db/pkg to determine whether or not a FreeBSD
184
 *				package is installed.
185
 */
186
function is_freebsd_pkg_installed($pkg) {
187
	global $g;
188
	if(in_array($pkg, return_dir_as_array("{$g['vardb_path']}/pkg"))) return true;
189
	return false;
190
}
191

    
192
/*
193
 * get_pkg_depends($pkg_name, $filetype = ".xml", $format = "files", return_nosync = 1):  Return a package's dependencies.
194
 *
195
 * $filetype = "all" || ".xml", ".tgz", etc.
196
 * $format = "files" (full filenames) || "names" (stripped / parsed depend names)
197
 * $return_nosync = 1 (return depends that have nosync set) | 0 (ignore packages with nosync)
198
 *
199
 */
200
function get_pkg_depends($pkg_name, $filetype = ".xml", $format = "files", $return_nosync = 1) {
201
	global $config;
202
	require_once("notices.inc");
203
	$pkg_id = get_pkg_id($pkg_name);
204
	if(!is_numeric($pkg_name)) {
205
		if($pkg_id == -1) return -1; // This package doesn't really exist - exit the function.
206
	} else {
207
		if(!isset($config['installedpackages']['package'][$pkg_id])) return; // No package belongs to the pkg_id passed to this function.
208
	}
209
	$package = $config['installedpackages']['package'][$pkg_id];
210
	if(!file_exists("/usr/local/pkg/" . $package['configurationfile'])) {
211
		log_error("The {$package['name']} package is missing required dependencies and must be reinstalled." . $package['configurationfile']);
212
		install_package($package['name']);
213
		uninstall_package_from_name($package['name']);
214
		install_package($package['name']);
215
		return;
216
	}
217
	$pkg_xml = parse_xml_config_pkg("/usr/local/pkg/" . $package['configurationfile'], "packagegui");
218
	if($pkg_xml['additional_files_needed'] != "") {
219
		foreach($pkg_xml['additional_files_needed'] as $item) {
220
			if (($return_nosync == 0) && (isset($item['nosync']))) continue; // Do not return depends with nosync set if not required.
221
			$depend_file = substr(strrchr($item['item']['0'], '/'),1); // Strip URLs down to filenames.
222
			$depend_name = substr(substr($depend_file,0,strpos($depend_file,".")+1),0,-1); // Strip filename down to dependency name.
223
			if (($filetype != "all") && (!preg_match("/{$filetype}/i", $depend_file))) continue;
224
			if ($item['prefix'] != "") {
225
				$prefix = $item['prefix'];
226
			} else {
227
				$prefix = "/usr/local/pkg/";
228
			}
229
			if(!file_exists($prefix . $depend_file))
230
				log_error("The {$package['name']} package is missing required dependencies and must be reinstalled.");
231
			switch ($format) {
232
				case "files":
233
				$depends[] = $depend_file;
234
			break;
235
            			case "names":
236
                		switch ($filetype) {
237

    
238
				case "all":
239
				if(preg_match("/\.xml/i", $depend_file)) {
240
					$depend_xml = parse_xml_config_pkg("/usr/local/pkg/" . $depend_file, "packagegui");
241
					$depends[] = $depend_xml['name'];
242
					break;
243
				} else {
244
					$depends[] = $depend_name; // If this dependency isn't package XML, use the stripped filename.
245
				break;
246
				}
247
				case ".xml":
248
				$depend_xml = parse_xml_config_pkg("/usr/local/pkg/" . $depend_file, "packagegui");
249
				$depends[] = $depend_xml['name'];
250
				break;
251
				default:
252
				$depends[] = $depend_name; // If we aren't looking for XML, use the stripped filename (it's all we have).
253
				break;
254
				}
255
			}
256
		}
257
		return $depends;
258
	}
259
}
260

    
261
function uninstall_package_from_name($pkg_name) {
262
	global $config;
263
	$id = get_pkg_id($pkg_name);
264
	$todel = substr(reverse_strrchr($config['installedpackages']['package'][$id]['depends_on_package'], "."), 0, -1);
265
	delete_package($todel, $pkg_name);
266
	delete_package_xml($pkg_name);
267
	remove_freebsd_package($pkg_name);
268
}
269

    
270
function force_remove_package($pkg_name) {
271
	global $config;
272
	delete_package_xml($pkg_name);
273
}
274

    
275
/*
276
 * sync_package($pkg_name, $sync_depends = true, $show_message = false) Force a package to setup its configuration and rc.d files.
277
 */
278
function sync_package($pkg_name, $sync_depends = true, $show_message = false) {
279
	global $config;
280
	require_once("notices.inc");
281
	if(!$config['installedpackages']['package']) return;
282
	if(!is_numeric($pkg_name)) {
283
		$pkg_id = get_pkg_id($pkg_name);
284
		if($pkg_id == -1) return -1; // This package doesn't really exist - exit the function.
285
	} else {
286
		$pkg_id = $pkg_name;
287
		if(!isset($config['installedpackages']['package'][$pkg_id]))
288
		return;  // No package belongs to the pkg_id passed to this function.
289
	}
290
        if (is_array($config['installedpackages']['package'][$pkg_id]))
291
			$package = $config['installedpackages']['package'][$pkg_id];
292
        else
293
			return; /* empty package tag */
294
	if(!file_exists("/usr/local/pkg/" . $package['configurationfile'])) {
295
		log_error("The {$package['name']} package is missing its configuration file and must be reinstalled.");
296
		force_remove_package($package['name']);
297
	} else {
298
		$pkg_config = parse_xml_config_pkg("/usr/local/pkg/" . $package['configurationfile'], "packagegui");
299

    
300
		/* Bring in package include files */
301
		if (isset($pkg_config['include_file']) && $pkg_config['include_file'] != "") {
302
			$include_file = $pkg_config['include_file'];
303
			if (file_exists($include_file))
304
				require_once($include_file);
305
			else
306
				if (file_exists($include_file)) {
307
					require_once($include_file);
308
				} else {
309
					log_error("Could not locate {$include_file}.");
310
					install_package($package['name']);
311
					uninstall_package_from_name($package['name']);
312
					remove_freebsd_package($package['name']);
313
					install_package($package['name']);
314
				}
315
		}
316

    
317
		/* XXX: Zend complains about the next line "Wrong break depth"
318
		 * The code is obviously wrong, but I'm not sure what it's supposed to do?
319
		 */
320
		if(isset($pkg_config['nosync'])) continue;
321
		if($pkg_config['custom_php_global_functions'] <> "")
322
		eval($pkg_config['custom_php_global_functions']);
323
		if($pkg_config['custom_php_resync_config_command'] <> "")
324
		eval($pkg_config['custom_php_resync_config_command']);
325
		if($sync_depends == true) {
326
			$depends = get_pkg_depends($pkg_name, ".xml", "files", 1); // Call dependency handler and do a little more error checking.
327
			if(is_array($depends)) {
328
				foreach($depends as $item) {
329
					if(!file_exists("/usr/local/pkg/" . $item)) {
330
						file_notice($package['name'], "The {$package['name']} package is missing required dependencies and must be reinstalled.", "Packages", "/pkg_mgr_install.php?mode=reinstallpkg&pkg={$package['name']}", 1);
331
						log_error("Could not find {$item}. Reinstalling package.");
332
						install_package($pkg_name);
333
						uninstall_package_from_name($pkg_name);
334
						remove_freebsd_package($pkg_name);						
335
						install_package($pkg_name);
336
					} else {
337
						$item_config = parse_xml_config_pkg("/usr/local/pkg/" . $item, "packagegui");
338
						if(isset($item_config['nosync'])) continue;
339
						if($item_config['custom_php_command_before_form'] <> "") {
340
							eval($item_config['custom_php_command_before_form']);
341
						}
342
						if($item_config['custom_php_resync_config_command'] <> "") {
343
							eval($item_config['custom_php_resync_config_command']);
344
						}
345
						if($show_message == true) print " " . $item_config['name'];
346
					}
347
				}
348
			}
349
		}
350
	}
351
}
352

    
353
/*
354
 * pkg_fetch_recursive: Download and install a FreeBSD package and its dependencies. This function provides output to
355
 * 			a progress bar and output window.
356
 *
357
 * XXX: This function needs to return where a pkg_add fails. Our current error messages aren't very descriptive.
358
 */
359
function pkg_fetch_recursive($pkgname, $filename, $dependlevel = 0, $base_url = 'http://ftp2.freebsd.org/pub/FreeBSD/ports/i386/packages-5.4-release/Latest') {
360
	global $pkgent, $static_output, $g, $fd_log;
361
	$pkg_extension = strrchr($filename, '.');
362
	$static_output .= "\n" . str_repeat(" ", $dependlevel * 2) . $pkgname . " ";
363
	$fetchto = "/tmp/apkg_" . $pkgname . $pkg_extension;
364
	download_file_with_progress_bar($base_url . '/' . $filename, $fetchto);
365
	$static_output .= " (extracting)";
366
	update_output_window($static_output);
367
		$slaveout = "";
368
	exec("/usr/bin/tar --fast-read -O -f {$fetchto} -x +CONTENTS 2>&1", $slaveout);
369
	$workingdir = preg_grep("/instmp/", $slaveout);
370
	$workingdir = $workingdir[0];
371
	$raw_depends_list = array_values(preg_grep("/\@pkgdep/", $slaveout));
372
	if($raw_depends_list != "") {
373
		if($pkgent['exclude_dependency'] != "")
374
			$raw_depends_list = array_values(preg_grep($pkgent['exclude_dependency'], PREG_GREP_INVERT));
375
		foreach($raw_depends_list as $adepend) {
376
			$working_depend = explode(" ", $adepend);
377
			//$working_depend = explode("-", $working_depend[1]);
378
			$depend_filename = $working_depend[1] . $pkg_extension;
379
			if(is_freebsd_pkg_installed($working_depend[1]) === false) {
380
				pkg_fetch_recursive($working_depend[1], $depend_filename, $dependlevel + 1, $base_url);
381
			} else {
382
//				$dependlevel++;
383
				$static_output .= "\n" . str_repeat(" ", $dependlevel * 2) . $working_depend[1] . " ";
384
				@fwrite($fd_log, $working_depend[1] . "\n");
385
			}
386
		}
387
	}
388
	$pkgaddout = "";
389
	exec("cat {$g['tmp_path']}/y | /usr/sbin/pkg_add -fv {$fetchto} 2>&1", $pkgaddout);
390
	@fwrite($fd_log, $pkgname . " " . print_r($pkgaddout, true) . "\n");
391
	return true;
392
}
393

    
394
function install_package($package, $pkg_info = "") {
395
	global $g, $config, $pkg_interface, $fd_log, $static_output, $pkg_interface, $restart_sync;
396
	if($pkg_interface == "console") 	
397
		echo "\n";
398
	/* open logfiles and begin installation */
399
	if(!$fd_log) {
400
		if(!$fd_log = fopen("{$g['tmp_path']}/pkg_mgr_{$package}.log", "w")) {
401
			update_output_window("Warning, could not open log for writing.");
402
		}
403
	}
404
	/* fetch package information if needed */
405
	if(!$pkg_info or !is_array($pkg_info[$package])) {
406
		$pkg_info = get_pkg_info(array($package));
407
		$pkg_info = $pkg_info[$package]; // We're only dealing with one package, so we can strip away the extra array.
408
	}
409
	@fwrite($fd_log, "Beginning package installation.\n");
410
	log_error('Beginning package installation for ' . $pkg_info['name'] . '.');
411
	update_status("Beginning package installation for " . $pkg_info['name'] . "...");	
412
	/* fetch the package's configuration file */
413
	if($pkg_info['config_file'] != "") {
414
		$static_output .= "Downloading package configuration file... ";
415
		update_output_window($static_output);
416
		@fwrite($fd_log, "Downloading package configuration file...\n");
417
		$fetchto = substr(strrchr($pkg_info['config_file'], '/'), 1);
418
		download_file_with_progress_bar($pkg_info['config_file'], '/usr/local/pkg/' . $fetchto);
419
		if(!file_exists('/usr/local/pkg/' . $fetchto)) {
420
			@fwrite($fd_log, "ERROR! Unable to fetch package configuration file. Aborting installation.\n");
421
			if($pkg_interface == "console") {
422
				print "\nERROR! Unable to fetch package configuration file. Aborting package installation.\n";
423
				return;
424
			} else {
425
				$static_output .= "failed!\n\nInstallation aborted.";
426
				update_output_window($static_output);
427
				echo "<br>Show <a href=\"pkg_mgr_install.php?showlog=true\">install log</a></center>";
428
			 	return -1;
429
			}
430
		}
431
		$static_output .= "done.\n";
432
		update_output_window($static_output);
433
	}
434
	/* add package information to config.xml */
435
	$pkgid = get_pkg_id($pkg_info['name']);
436
	$static_output .= "Saving updated package information... ";
437
	update_output_window($static_output);
438
	if($pkgid == -1) {
439
		$config['installedpackages']['package'][] = $pkg_info;
440
		$changedesc = "Installed {$pkg_info['name']} package.";
441
		$to_output = "done.\n";
442
	} else {
443
		$config['installedpackages']['package'][$pkgid] = $pkg_info;
444
		$changedesc = "Overwrote previous installation of {$pkg_info['name']}.";
445
		$to_output = "overwrite!\n";
446
	}
447
	$static_output .= $to_output;
448
	update_output_window($static_output);
449
	/* install other package components */
450
	install_package_xml($package);
451
	$static_output .= "Writing configuration... ";
452
	update_output_window($static_output);
453
	write_config($changedesc);
454
	$static_output .= "done.\n";
455
	update_output_window($static_output);
456
	$static_output .= "Starting service.\n";
457
	update_output_window($static_output);
458
	if($pkg_info['after_install_info']) 
459
		update_output_window($pkg_info['after_install_info']);	
460
	start_service($pkg_info['config_file']);
461
	$restart_sync = true;
462
}
463

    
464
function get_after_install_info($package) {
465
	global $pkg_info;
466
	/* fetch package information if needed */
467
	if(!$pkg_info or !is_array($pkg_info[$package])) {
468
		$pkg_info = get_pkg_info(array($package));
469
		$pkg_info = $pkg_info[$package]; // We're only dealing with one package, so we can strip away the extra array.
470
	}
471
	if($pkg_info['after_install_info'])
472
		return $pkg_info['after_install_info'];
473
}
474

    
475
function eval_once($toeval) {
476
	global $evaled;
477
	if(!$evaled) $evaled = array();
478
	$evalmd5 = md5($toeval);
479
	if(!in_array($evalmd5, $evaled)) {
480
		eval($toeval);
481
		$evaled[] = $evalmd5;
482
	}
483
	return;
484
}
485

    
486
function install_package_xml($pkg) {
487
	global $g, $config, $fd_log, $static_output, $pkg_interface;
488
	if(($pkgid = get_pkg_id($pkg)) == -1) {
489
		$static_output .= "The {$pkg} package is not installed.\n\nInstallation aborted.";
490
		update_output_window($static_output);
491
		if($pkg_interface <> "console") {
492
			echo "\n<script language=\"JavaScript\">document.progressbar.style.visibility='hidden';</script>";
493
			echo "\n<script language=\"JavaScript\">document.progholder.style.visibility='hidden';</script>";
494
		}
495
		sleep(1);
496
		return;
497
	} else {
498
		$pkg_info = $config['installedpackages']['package'][$pkgid];
499
	}
500
	/* set up logging if needed */
501
	if(!$fd_log) {
502
		if(!$fd_log = fopen("{$g['tmp_path']}/pkg_mgr_{$pkg}.log", "w")) {
503
			update_output_window("Warning, could not open log for writing.");
504
		}
505
	}
506

    
507
	/* set up package logging streams */
508
	if($pkg_info['logging']) {
509
		mwexec("/usr/sbin/fifolog_create -s 32768 {$g['varlog_path']}/{$pkg_info['logging']['logfilename']}");
510
		chmod($g['varlog_path'] . '/' . $pkg_info['logging']['logfilename'], 0600);
511
		@fwrite($fd_log, "Adding text to file /etc/syslog.conf\n");
512
		mwexec("killall syslogd");
513
		system_syslogd_start();
514
	}
515

    
516
	/* make 'y' file */
517
	$fd = fopen("{$g['tmp_path']}/y", "w");
518
	for($line = 0; $line < 10; $line++) {
519
		fwrite($fd, "y\n");
520
	}
521
	fclose($fd);
522

    
523
	/* pkg_add the package and its dependencies */
524
	if($pkg_info['depends_on_package_base_url'] != "") {
525
		if($pkg_interface == "console") 
526
			echo "\n";
527
		update_status("Installing " . $pkg_info['name'] . " and its dependencies.");
528
		$static_output .= "Downloading " . $pkg_info['name'] . " and its dependencies... ";
529
		$static_orig = $static_output;
530
		$static_output .= "\n";
531
		update_output_window($static_output);
532
		foreach((array) $pkg_info['depends_on_package'] as $pkgdep) {
533
			$pkg_name = substr(reverse_strrchr($pkgdep, "."), 0, -1);
534
			if(isset($pkg_info['skip_install_checks'])) {
535
				$pkg_installed = true;
536
			} else {
537
				$pkg_installed = is_freebsd_pkg_installed($pkg_name);
538
			}
539
			if($pkg_installed == false) pkg_fetch_recursive($pkg_name, $pkgdep, 0, $pkg_info['depends_on_package_base_url']);
540
			$static_output = $static_orig . "done.\nChecking for successful package installation... ";
541
			update_output_window($static_output);
542
			/* make sure our package was successfully installed */
543
			if($pkg_installed == false) $pkg_installed = is_freebsd_pkg_installed($pkg_name);
544
			if($pkg_installed == true) {
545
				$static_output .= "done.\n";
546
				update_output_window($static_output);
547
				fwrite($fd_log, "pkg_add successfully completed.\n");
548
			} else {
549
				$static_output .= "failed!\n\nInstallation aborted.";
550
				update_output_window($static_output);
551
				fwrite($fd_log, "Package WAS NOT installed properly.\n");
552
				fclose($fd_log);
553
				if($pkg_interface <> "console") {
554
					echo "\n<script language=\"JavaScript\">document.progressbar.style.visibility='hidden';</script>";
555
					echo "\n<script language=\"JavaScript\">document.progholder.style.visibility='hidden';</script>";
556
				}
557
				sleep(1);
558
				die;
559
			}
560
		}
561
	}
562
	$configfile = substr(strrchr($pkg_info['config_file'], '/'), 1);
563
	if(file_exists("/usr/local/pkg/" . $configfile)) {
564
		$static_output .= "Loading package configuration... ";
565
		update_output_window($static_output);
566
		$pkg_config = parse_xml_config_pkg("/usr/local/pkg/" . $configfile, "packagegui");
567
		$static_output .= "done.\n";
568
		update_output_window($static_output);
569
		$static_output .= "Configuring package components...\n";
570
		update_output_window($static_output);
571
		/* modify system files */
572
		if($pkg_config['modify_system']['item'] <> "") {
573
			$static_output .= "\tSystem files... ";
574
			update_output_window($static_output);
575
			foreach($pkg_config['modify_system']['item'] as $ms) {
576
				if($ms['textneeded']) {
577
					add_text_to_file($ms['modifyfilename'], $ms['textneeded']);
578
				}
579
			}
580
			$static_output .= "done.\n";
581
			update_output_window($static_output);
582
		}
583
		/* download additional files */
584
		if($pkg_config['additional_files_needed'] <> "") {
585
			$static_output .= "\tAdditional files... ";
586
			$static_orig = $static_output;
587
			update_output_window($static_output);
588
			foreach($pkg_config['additional_files_needed'] as $afn) {
589
				$filename = get_filename_from_url($afn['item'][0]);
590
				if($afn['chmod'] <> "") {
591
					$pkg_chmod = $afn['chmod'];
592
				} else {
593
					$pkg_chmod = "";
594
				}
595
				if($afn['prefix'] <> "") {
596
					$prefix = $afn['prefix'];
597
				} else {
598
					$prefix = "/usr/local/pkg/";
599
				}
600
				if(!is_dir($prefix)) 
601
					safe_mkdir($prefix);
602
 				$static_output .= $filename . " ";
603
                                update_output_window($static_output);
604
				download_file_with_progress_bar($afn['item'][0], $prefix . $filename);
605
				if(stristr($filename, ".tgz") <> "") {
606
					fwrite($fd_log, "Extracting tarball to -C for " . $filename . "...\n");
607
					$tarout = "";
608
					exec("/usr/bin/tar xvzf " . $prefix . $filename . " -C / 2>&1", $tarout);
609
					fwrite($fd_log, print_r($tarout, true) . "\n");
610
				}
611
				if($pkg_chmod <> "") {
612
					fwrite($fd_log, "Changing file mode to {$pkg_chmod} for {$prefix}{$filename}\n");
613
					chmod($prefix . $filename, $pkg_chmod);
614
					system("/bin/chmod {$pkg_chmod} {$prefix}{$filename}");
615
				}
616
				$static_output = $static_orig;
617
                                update_output_window($static_output);
618
			}
619
			$static_output .= "done.\n";
620
			update_output_window($static_output);
621
		}
622
		/*   if a require exists, include it.  this will
623
		 *   show us where an error exists in a package
624
		 *   instead of making us blindly guess
625
		 */
626
		if($pkg_config['include_file'] <> "") {
627
			$static_output = "Loading package instructions...";
628
			update_output_window($static_output);
629
			fwrite($fd_log, "require_once('include_file')\n");
630
			require_once($pkg_config['include_file']);
631
		}
632
		/* sidebar items */
633
		if($pkg_config['menu'] != "") {
634
			$static_output .= "\tMenu items... ";
635
			update_output_window($static_output);
636
			if(is_array($pkg_config['menu'])) {
637
				foreach($pkg_config['menu'] as $menu) {
638
					if(is_array($config['installedpackages']['menu']))
639
						foreach($config['installedpackages']['menu'] as $amenu)
640
							if($amenu['name'] == $menu['name'])
641
								continue 2;
642
					$config['installedpackages']['menu'][] = $menu;
643
				}
644
			}
645
			$static_output .= "done.\n";
646
			update_output_window($static_output);
647
		}
648
		/* integrated tab items */
649
		if($pkg_config['tabs'] != "") {
650
			$static_output .= "\tIntegrated Tab items... ";
651
			update_output_window($static_output);
652
			if(is_array($pkg_config['tabs']['tab'])) {
653
				foreach($pkg_config['tabs']['tab'] as $tab) {
654
					if(is_array($config['installedpackages']['tab']))
655
						foreach($config['installedpackages']['tab'] as $atab)
656
							if($atab['name'] == $tab['name'])
657
								continue 2;
658
					$config['installedpackages']['tab'][] = $tab;
659
				}
660
			}
661
			$static_output .= "done.\n";
662
			update_output_window($static_output);
663
		}
664
		/* services */
665
		if($pkg_config['service'] != "") {
666
			$static_output .= "\tServices... ";
667
			update_output_window($static_output);
668
			foreach($pkg_config['service'] as $service) {
669
				$config['installedpackages']['service'][] = $service;
670
			}
671
			$static_output .= "done.\n";
672
			update_output_window($static_output);
673
		}
674
		/* custom commands */
675
		$static_output .= "\tCustom commands... ";
676
		update_output_window($static_output);
677
		if($pkg_config['custom_php_global_functions'] <> "") {
678
			$static_output = "Executing custom_php_global_functions()...";
679
			update_output_window($static_output);
680
			eval_once($pkg_config['custom_php_global_functions']);
681
		}
682
		if($pkg_config['custom_php_install_command']) {
683
			$static_output = "Executing custom_php_install_command()...";
684
			update_output_window($static_output);
685
			eval_once($pkg_config['custom_php_install_command']);
686
		}
687
		if($pkg_config['custom_php_resync_config_command'] <> "") {
688
			$static_output = "Executing custom_php_resync_config_command()...";
689
			update_output_window($static_output);
690
			eval_once($pkg_config['custom_php_resync_config_command']);
691
		}
692
		$static_output .= "done.\n";
693
		update_output_window($static_output);
694
	} else {
695
		$static_output .= "Loading package configuration... failed!\n\nInstallation aborted.";
696
		update_output_window($static_output);
697
		fwrite($fd_log, "Unable to load package configuration. Installation aborted.\n");
698
		fclose($fd_log);
699
		if($pkg_interface <> "console") {
700
			echo "\n<script language=\"JavaScript\">document.progressbar.style.visibility='hidden';</script>";
701
			echo "\n<script language=\"JavaScript\">document.progholder.style.visibility='hidden';</script>";
702
		}
703
		sleep(1);
704
		return;
705
	}
706
}
707

    
708
function delete_package($pkg, $pkgid) {
709
	global $g, $config, $fd_log, $static_output;
710
	update_status("Removing package...");
711
	$static_output .= "Removing package... ";
712
	update_output_window($static_output);
713
	$pkgid = get_pkg_id($pkgid);
714
	$pkg_info = $config['installedpackages']['package'][$pkgid];
715

    
716
	$configfile = $pkg_info['configurationfile'];
717
	if(file_exists("/usr/local/pkg/" . $configfile)) {
718
		$static_output .= "\nLoading package configuration $configfile... ";
719
		update_output_window($static_output);
720
		$pkg_config = parse_xml_config_pkg("/usr/local/pkg/" . $configfile, "packagegui");
721
		/*   if a require exists, include it.  this will
722
		 *   show us where an error exists in a package
723
		 *   instead of making us blindly guess
724
		 */
725
		if($pkg_config['include_file'] <> "") {
726
			$static_output .= "\nLoading package instructions...\n";
727
			update_output_window($static_output);
728
			require_once($pkg_config['include_file']);
729
		}
730
	}
731
	$static_output .= "\nStarting package deletion for {$pkg_info['name']}...\n";
732
	update_output_window($static_output);
733
	delete_package_recursive($pkg);
734
	remove_freebsd_package($pkg);
735
	$static_output .= "done.\n";
736
	update_output_window($static_output);
737
	return;
738
}
739

    
740
function delete_package_recursive($pkg) {
741
	global $config, $g;
742
	$fd = fopen("{$g['tmp_path']}/y", "w");
743
	for($line = 0; $line < 10; $line++) {
744
		fwrite($fd, "y\n");
745
	}
746
	fclose($fd);
747
	$info = "";
748
	exec("/usr/sbin/pkg_info -r " . $pkg . " 2>&1", $info);
749
	exec("cat {$g['tmp_path']}/y | /usr/sbin/pkg_delete " . $pkg ." > /dev/null 2>&1");
750
	remove_freebsd_package($pkg);
751
	$pkgdb = "";
752
	exec("/bin/ls /var/db/pkg", $pkgdb);
753
	foreach($info as $line) {
754
		$depend = trim(array_pop(explode(":", $line)));
755
		if(in_array($depend, $pkgdb)) 
756
			delete_package_recursive($depend);
757
	}
758
	return;
759
}
760

    
761
function delete_package_xml($pkg) {
762
	global $g, $config, $fd_log, $static_output, $pkg_interface;
763
	if(($pkgid = get_pkg_id($pkg)) == -1) {
764
		$static_output .= "The {$pkg} package is not installed.\n\nDeletion aborted.";
765
		update_output_window($static_output);
766
		if($pkg_interface <> "console") {
767
			echo "\n<script language=\"JavaScript\">document.progressbar.style.visibility='hidden';</script>";
768
			echo "\n<script language=\"JavaScript\">document.progholder.style.visibility='hidden';</script>";
769
		}
770
		ob_flush();
771
		sleep(1);
772
		return;
773
	}
774
	/* set up logging if needed */
775
	if(!$fd_log) {
776
		if(!$fd_log = fopen("{$g['tmp_path']}/pkg_mgr_{$pkg}.log", "w")) {
777
			update_output_window("Warning, could not open log for writing.");
778
		}
779
	}
780
	update_status("Removing {$pkg} components...");
781
	fwrite($fd_log, "Removing {$pkg} package... ");
782
	$static_output .= "Removing {$pkg} components...\n";
783
	update_output_window($static_output);
784
	/* parse package configuration */
785
	$packages = &$config['installedpackages']['package'];
786
	$tabs =& $config['installedpackages']['tab'];
787
	$menus =& $config['installedpackages']['menu'];
788
	$services = &$config['installedpackages']['service'];
789
	if(file_exists("/usr/local/pkg/" . $packages[$pkgid]['configurationfile'])) {
790
		$pkg_config = parse_xml_config_pkg("/usr/local/pkg/" . $packages[$pkgid]['configurationfile'], "packagegui");
791
		/* remove tab items */
792
		if(is_array($pkg_config['tabs'])) {
793
			$static_output .= "\tMenu items... ";
794
			update_output_window($static_output);
795
			if(is_array($tabs))
796
				foreach($tabs as $tab)
797
					$insttabs[] = $tab['name'];
798
			if($pkg_config['tabs']['tab'])
799
				foreach($pkg_config['tabs']['tab'] as $tab)
800
					foreach($insttabs as $key => $insttab)
801
						if($insttab == $tab['name'])
802
							unset($tabs[$key]);
803
			$static_output .= "done.\n";
804
			update_output_window($static_output);
805
		}
806
		/* remove menu items */
807
		if(is_array($pkg_config['menu'])) {
808
			$static_output .= "\tMenu items... ";
809
			update_output_window($static_output);
810
			foreach($menus as $menu)
811
				$instmenus[] = $menu['name'];
812
			foreach($pkg_config['menu'] as $menu)
813
				foreach($instmenus as $key => $instmenu)
814
					if($instmenu == $menu['name'])
815
						unset($menus[$key]);
816
			$static_output .= "done.\n";
817
			update_output_window($static_output);
818
		}
819
		/* remove services */
820
		if(is_array($pkg_config['service'])) {
821
			$static_output .= "\tServices... ";
822
			update_output_window($static_output);
823
			foreach($services as $service) $instservices[] = $service['name'];
824
			foreach($pkg_config['service'] as $service) {
825
				foreach($instservices as $key => $instservice) {
826
					if($instservice == $service['name']) {
827
						stop_service($service['name']);
828
						unset($services[$key]);
829
					}
830
				}
831
			}
832
			$static_output .= "done.\n";
833
			update_output_window($static_output);
834
		}
835
		/*   if a require exists, include it.  this will
836
		 *   show us where an error exists in a package
837
		 *   instead of making us blindly guess
838
		 */
839
		if($pkg_config['include_file'] <> "") {
840
			$static_output = "Loading package instructions...";
841
			update_output_window($static_output);
842
			fwrite($fd_log, "require_once('include_file')\n");
843
			if(file_exists($pkg_config['include_file']))
844
				require_once($pkg_config['include_file']);
845
			fwrite($fd_log, "require_once('include_file') included\n");
846
		}
847
		/* evalate this package's global functions and pre deinstall commands */
848
		if($pkg_config['custom_php_global_functions'] <> "")
849
			eval_once($pkg_config['custom_php_global_functions']);
850
		if($pkg_config['custom_php_pre_deinstall_command'] <> "")
851
			eval_once($pkg_config['custom_php_pre_deinstall_command']);
852
		/* remove all additional files */
853
		if($pkg_config['additional_files_needed'] <> "") {
854
			$static_output .= "\tAuxiliary files... ";
855
			update_output_window($static_output);
856
			foreach($pkg_config['additional_files_needed'] as $afn) {
857
				$filename = get_filename_from_url($afn['item'][0]);
858
				if($afn['prefix'] <> "") {
859
					$prefix = $afn['prefix'];
860
				} else {
861
					$prefix = "/usr/local/pkg/";
862
				}
863
				unlink_if_exists($prefix . $filename);
864
				if(file_exists($prefix . $filename))
865
				    mwexec("rm -rf {$prefix}{$filename}");
866
			}
867
			$static_output .= "done.\n";
868
			update_output_window($static_output);
869
		}
870
		/* system files */
871
		if($pkg_config['modify_system']['item'] <> "") {
872
			$static_output .= "\tSystem files... ";
873
			update_output_window($static_output);
874
			foreach($pkg_config['modify_system']['item'] as $ms) {
875
				if($ms['textneeded']) remove_text_from_file($ms['modifyfilename'], $ms['textneeded']);
876
			}
877
			$static_output .= "done.\n";
878
			update_output_window($static_output);
879
		}
880
		/* syslog */
881
		if($pkg_config['logging']['logfile_name'] <> "") {
882
			$static_output .= "\tSyslog entries... ";
883
			update_output_window($static_output);
884
			remove_text_from_file("/etc/syslog.conf", $pkg_config['logging']['facilityname'] . "\t\t\t\t" . $pkg_config['logging']['logfilename']);
885
			$static_output .= "done.\n";
886
			update_output_window($static_output);
887
		}
888
		/* deinstall commands */
889
		if($pkg_config['custom_php_deinstall_command'] <> "") {
890
			$static_output .= "\tDeinstall commands... ";
891
			update_output_window($static_output);
892
			eval_once($pkg_config['custom_php_deinstall_command']);
893
			$static_output .= "done.\n";
894
			update_output_window($static_output);
895
		}
896
		/* package XML file */
897
		$static_output .= "\tPackage XML... ";
898
		update_output_window($static_output);
899
		unlink_if_exists("/usr/local/pkg/" . $packages[$pkgid]['configurationfile']);
900
		$static_output .= "done.\n";
901
		update_output_window($static_output);
902
	}
903
	/* remove config.xml entries */
904
	$static_output .= "\tConfiguration... ";
905
	update_output_window($static_output);
906
	unset($config['installedpackages']['package'][$pkgid]);
907
	$static_output .= "done.\n";
908
	update_output_window($static_output);
909
	write_config("Removed {$pkg} package.");
910
	/* file cleanup */
911
	$ctag = file("/etc/crontab");
912
	foreach($ctag as $line) {
913
		if(trim($line) != "") $towrite[] = $line;
914
	}
915
	$tmptab = fopen("/tmp/crontab", "w");
916
	foreach($towrite as $line) {
917
		fwrite($tmptab, $line);
918
	}
919
	fclose($tmptab);
920
	rename("/tmp/crontab", "/etc/crontab");
921
}
922

    
923
function expand_to_bytes($size) {
924
	$conv = array(
925
			"G" =>	"3",
926
			"M" =>  "2",
927
			"K" =>  "1",
928
			"B" =>  "0"
929
		);
930
	$suffix = substr($size, -1);
931
	if(!in_array($suffix, array_keys($conv))) return $size;
932
	$size = substr($size, 0, -1);
933
	for($i = 0; $i < $conv[$suffix]; $i++) {
934
		$size *= 1024;
935
	}
936
	return $size;
937
}
938

    
939
function get_pkg_db() {
940
	global $g;
941
	return return_dir_as_array($g['vardb_path'] . '/pkg');
942
}
943

    
944
function walk_depend($depend, $pkgdb = "", $alreadyseen = "") {
945
	if(!$pkgdb) $pkgdb = get_pkg_db();
946
	if(!$alreadyseen) $alreadyseen = array();
947
	foreach($depend as $adepend) {
948
		$pkgname = reverse_strrchr($adepend['name'], '.');
949
		if(in_array($pkgname, $alreadyseen)) {
950
			continue;
951
		} elseif(!in_array($pkgname, $pkgdb)) {
952
			$size += expand_to_bytes($adepend['size']);
953
			$alreadyseen[] = $pkgname;
954
			if(is_array($adepend['depend'])) $size += walk_depend($adepend['depend'], $pkgdb, $alreadyseen);
955
		} else {
956
			continue;
957
		}
958
	}
959
	return $size;
960
}
961

    
962
function get_package_install_size($pkg = 'all', $pkg_info = "") {
963
	global $config, $g;
964
	if((!is_array($pkg)) and ($pkg != 'all')) $pkg = array($pkg);
965
	$pkgdb = get_pkg_db();
966
	if(!$pkg_info) $pkg_info = get_pkg_sizes($pkg);
967
	foreach($pkg as $apkg) {
968
		if(!$pkg_info[$apkg]) continue;
969
		$toreturn[$apkg] = expand_to_bytes(walk_depend(array($pkg_info[$apkg]), $pkgdb));
970
	}
971
	return $toreturn;
972
}
973

    
974
function squash_from_bytes($size, $round = "") {
975
	$conv = array(1 => "B", "K", "M", "G");
976
	foreach($conv as $div => $suffix) {
977
		$sizeorig = $size;
978
		if(($size /= 1024) < 1) {
979
			if($round) {
980
				$sizeorig = round($sizeorig, $round);
981
			}
982
			return $sizeorig . $suffix;
983
		}
984
	}
985
	return;
986
}
987

    
988
function pkg_build_filter_rules() {
989
	global $config;
990

    
991
	$pkgrules = "";
992
	$pkgrulesearly = "";
993
	$pkgnatrules = "";
994
	$pkgnatrulesearly = "";
995
	$pkgrdrrules = "";
996
	$pkgrdrrules = "";
997
	$pkgrdrrulesearly = "";
998
	if (is_array($config['installedpackages']['package'])) {
999
		run_plugins("/usr/local/pkg");
1000
                foreach($config['installedpackages']['package'] as $pkg) {
1001
                        if (!isset($pkg['filter_rule_function']))
1002
				continue;
1003
			$tmpresult = call_user_func($pkg['filter_rule_function'], 'natearly');
1004
                        if (!empty($tmpresult))
1005
                                $pkgnatrulesearly .= $tmpresult . " \n";
1006
			$tmpresult = call_user_func($pkg['filter_rule_function'], 'nat');
1007
			if (!empty($tmpresult))
1008
				$pkgnatrules .= $tmpresult . " \n";
1009
			$tmpresult = call_user_func($pkg['filter_rule_function'], 'ruleearly');
1010
                        if (!empty($tmpresult))
1011
                                $pkgrulesearly .= $tmpresult . " \n";
1012
			$tmpresult = call_user_func($pkg['filter_rule_function'], 'rule');
1013
			if (!empty($tmpresult))
1014
				$pkgrules .= $tmpresult . " \n";
1015
			$tmpresult = call_user_func($pkg['filter_rule_function'], 'rdrearly');
1016
                        if (!empty($tmpresult))
1017
                                $pkgrdrrulesearly .= $tmpresult . " \n";
1018
			$tmpresult = call_user_func($pkg['filter_rule_function'], 'rdr');
1019
                        if (!empty($tmpresult))
1020
                                $pkgrdrrules .= $tmpresult . " \n";
1021
			
1022
                }
1023
        }
1024
	if ($pkgnatrulesearly <> "")
1025
                file_put_contents("{$g['tmp_path']}/rules.natearly.packages", $pkgnatrulesearly);
1026
	if ($pkgnatrules <> "")
1027
		file_put_contents("{$g['tmp_path']}/rules.nat.packages", $pkgnatrules);
1028
	if ($pkgrules <> "")
1029
		file_put_contents("{$g['tmp_path']}/rules.packages", $pkgrules);
1030
	if ($pkgrdrrules <> "")
1031
                file_put_contents("{$g['tmp_path']}/rules.rdr.packages", $pkgrdrrules);
1032
	if ($pkgrdrrulesearly <> "")
1033
                file_put_contents("{$g['tmp_path']}/rules.rdr.packages", $pkgrdrrulesearly);
1034
	$error = "";
1035
	$status = mwexec("/sbin/pfctl -nf {$g['tmp_path']}/rules.natearly.packages");
1036
        if ($status <> 0) {
1037
                log_error("There was an error while parsing the NAT early package rules.");
1038
                $error = "\nThere was an error while parsing the NAT early package rules.";
1039
        } else {
1040
                mwexec("/sbin/pfctl -a pkgnatearly -F rules");
1041
                mwexec("/sbin/pfctl -a pkgnatearly -f {$g['tmp_path']}/rules.natearly.packages");
1042
        }
1043
	$status = mwexec("/sbin/pfctl -nf {$g['tmp_path']}/rules.nat.packages");
1044
        if ($status <> 0) {
1045
                log_error("There was an error while parsing the NAT package rules.");
1046
                $error = "\nThere was an error while parsing the NAT package rules.";
1047
        } else {
1048
                mwexec("/sbin/pfctl -a pkgnat -F rules");
1049
                mwexec("/sbin/pfctl -a pkgnat -f {$g['tmp_path']}/rules.nat.packages");
1050
        }
1051
	$status = mwexec("/sbin/pfctl -nf {$g['tmp_path']}/rules.rulesearly.packages");
1052
	if ($status <> 0) {
1053
		log_error("There was an error while parsing the package filter early rules.");
1054
		$error = "\nThere was an error while parsing the package filter early rules.";
1055
	} else {
1056
		mwexec("/sbin/pfctl -a packageearly -F rules");
1057
		mwexec("/sbin/pfctl -a packageearly -f {$g['tmp_path']}/rulesearly.packages");
1058
	}
1059
	$status = mwexec("/sbin/pfctl -nf {$g['tmp_path']}/rules.packages");
1060
	if ($status <> 0) {
1061
		log_error("There was an error while parsing the package filter rules.");
1062
		$error = "\nThere was an error while parsing the package filter rules.";
1063
        } else {
1064
                mwexec("/sbin/pfctl -a packagelate -F rules");
1065
                mwexec("/sbin/pfctl -a packagelate -f {$g['tmp_path']}/rules.packages");
1066
        }
1067
	$status = mwexec("/sbin/pfctl -nf {$g['tmp_path']}/rules.rdrearly.packages");
1068
        if ($status <> 0) {
1069
                log_error("There was an error while parsing the RDR early package rules.");
1070
                $error = "\nThere was an error while parsing the RDR early package rules.";
1071
        } else {
1072
                mwexec("/sbin/pfctl -a pkgrdrearly -F rules");
1073
                mwexec("/sbin/pfctl -a pkgrdrearly -f {$g['tmp_path']}/rules.rdrearly.packages");
1074
        }
1075
	$status = mwexec("/sbin/pfctl -nf {$g['tmp_path']}/rules.rdr.packages");
1076
        if ($status <> 0) {
1077
		log_error("There was an error while parsing the RDR package rules.");
1078
		$error = "\nThere was an error while parsing the RDR package rules.";
1079
        } else {
1080
                mwexec("/sbin/pfctl -a pkgrdr -F rules");
1081
                mwexec("/sbin/pfctl -a pkgrdr -f {$g['tmp_path']}/rules.rdr.packages");
1082
        }
1083
	if ($error <> "")
1084
		file_notice($error);
1085
}
1086

    
1087
?>
(23-23/41)