summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeth Mos <seth.mos@dds.nl>2010-12-20 21:06:33 +0100
committerSeth Mos <seth.mos@dds.nl>2010-12-20 21:06:33 +0100
commit81afb50916235853a9b3046796199a443d27c224 (patch)
treef25e1acd56748f178699a1edc33c123bd2182f20
parent172007f50c215acf458340773a32052c28556aaa (diff)
parent49659e1cc6f78af1287590fca7b64791fd6da6f1 (diff)
downloadpfsense-81afb50916235853a9b3046796199a443d27c224.zip
pfsense-81afb50916235853a9b3046796199a443d27c224.tar.gz
Merge remote branch 'upstream/master'
Conflicts: etc/inc/interfaces.inc etc/inc/vslb.inc usr/local/www/interfaces.php
-rw-r--r--conf.default/config.xml10
-rw-r--r--etc/devd.conf13
-rwxr-xr-xetc/ecl.php164
-rw-r--r--etc/inc/auth.inc103
-rw-r--r--etc/inc/captiveportal.inc5
-rw-r--r--etc/inc/certs.inc13
-rw-r--r--etc/inc/config.console.inc2
-rw-r--r--etc/inc/config.gui.inc6
-rw-r--r--etc/inc/config.inc13
-rw-r--r--etc/inc/config.lib.inc88
-rw-r--r--etc/inc/dyndns.class20
-rw-r--r--etc/inc/filter.inc235
-rw-r--r--etc/inc/globals.inc65
-rw-r--r--etc/inc/gwlb.inc20
-rw-r--r--etc/inc/interfaces.inc322
-rw-r--r--etc/inc/ipsec.inc16
-rwxr-xr-xetc/inc/openvpn.auth-user.php8
-rw-r--r--etc/inc/openvpn.inc27
-rw-r--r--etc/inc/pfsense-utils.inc138
-rw-r--r--etc/inc/pkg-utils.inc525
-rw-r--r--etc/inc/services.inc2
-rw-r--r--etc/inc/shaper.inc2
-rw-r--r--etc/inc/system.inc37
-rw-r--r--etc/inc/upgrade_config.inc47
-rw-r--r--etc/inc/util.inc42
-rw-r--r--etc/inc/voucher.inc161
-rw-r--r--etc/inc/vpn.inc59
-rw-r--r--etc/inc/vslb.inc76
-rw-r--r--etc/inc/xmlparse.inc17
-rw-r--r--etc/inc/xmlreader.inc8
-rw-r--r--etc/inc/xmlrpc.inc27
-rw-r--r--etc/inc/xmlrpc_client.inc2
-rw-r--r--etc/phpshellsessions/externalconfiglocator3
-rwxr-xr-xetc/rc34
-rwxr-xr-xetc/rc.banner2
-rwxr-xr-xetc/rc.bootup32
-rwxr-xr-xetc/rc.dyndns.update7
-rwxr-xr-xetc/rc.filter_configure_xmlrpc3
-rwxr-xr-xetc/rc.filter_synchronize106
-rwxr-xr-xetc/rc.initial47
-rwxr-xr-xetc/rc.newwanip27
-rwxr-xr-xetc/rc.php_ini_setup45
-rwxr-xr-xetc/sshd11
-rwxr-xr-xsbin/dhclient-script40
-rwxr-xr-xusr/local/bin/beep.sh4
-rw-r--r--usr/local/pkg/carp_settings.xml120
-rwxr-xr-xusr/local/www/carp_status.php13
-rwxr-xr-xusr/local/www/diag_backup.php1
-rw-r--r--usr/local/www/diag_limiter_info.php116
-rw-r--r--usr/local/www/diag_pf_info.php120
-rwxr-xr-xusr/local/www/diag_pkglogs.php21
-rw-r--r--usr/local/www/diag_system_pftop.php2
-rw-r--r--usr/local/www/edit.php4
-rwxr-xr-xusr/local/www/fbegin.inc9
-rwxr-xr-xusr/local/www/firewall_aliases_edit.php2
-rwxr-xr-xusr/local/www/firewall_nat_1to1.php24
-rwxr-xr-xusr/local/www/firewall_nat_out_edit.php26
-rwxr-xr-xusr/local/www/firewall_rules.php23
-rwxr-xr-xusr/local/www/firewall_rules_edit.php4
-rwxr-xr-xusr/local/www/firewall_shaper_layer7.php2
-rwxr-xr-xusr/local/www/firewall_virtual_ip.php6
-rwxr-xr-xusr/local/www/firewall_virtual_ip_edit.php85
-rw-r--r--usr/local/www/getserviceproviders.php1
-rwxr-xr-xusr/local/www/guiconfig.inc3
-rw-r--r--usr/local/www/help.php10
-rwxr-xr-xusr/local/www/index.php2
-rw-r--r--usr/local/www/installer/index.php5
-rw-r--r--usr/local/www/installer/installer.php (renamed from usr/local/www/installer.php)607
-rwxr-xr-xusr/local/www/interfaces.php18
-rwxr-xr-xusr/local/www/interfaces_assign.php11
-rw-r--r--usr/local/www/interfaces_gif_edit.php3
-rw-r--r--usr/local/www/interfaces_gre_edit.php3
-rwxr-xr-xusr/local/www/interfaces_groups_edit.php1
-rw-r--r--usr/local/www/interfaces_lagg_edit.php10
-rw-r--r--usr/local/www/javascript/filter_log.js18
-rwxr-xr-xusr/local/www/javascript/row_helper_dynamic.js34
-rwxr-xr-xusr/local/www/load_balancer_pool_edit.php14
-rwxr-xr-xusr/local/www/pkg_edit.php13
-rwxr-xr-xusr/local/www/pkg_mgr_install.php21
-rw-r--r--usr/local/www/services_captiveportal_vouchers.php2
-rwxr-xr-xusr/local/www/services_dhcp.php38
-rwxr-xr-xusr/local/www/services_dhcp_relay.php14
-rwxr-xr-xusr/local/www/services_dyndns.php18
-rw-r--r--usr/local/www/services_dyndns_edit.php2
-rwxr-xr-xusr/local/www/services_snmp.php10
-rwxr-xr-xusr/local/www/status_graph.php6
-rwxr-xr-xusr/local/www/status_lb_pool.php17
-rwxr-xr-xusr/local/www/status_lb_vs.php61
-rw-r--r--usr/local/www/system_advanced_firewall.php14
-rw-r--r--usr/local/www/system_advanced_misc.php21
-rw-r--r--usr/local/www/system_crlmanager.php14
-rwxr-xr-xusr/local/www/system_gateways_edit.php2
-rwxr-xr-xusr/local/www/system_routes_edit.php8
-rwxr-xr-xusr/local/www/system_usermanager_settings.php11
-rwxr-xr-xusr/local/www/vpn_ipsec.php9
-rw-r--r--usr/local/www/vpn_ipsec_phase1.php5
-rw-r--r--usr/local/www/vpn_ipsec_phase2.php7
-rw-r--r--usr/local/www/vpn_openvpn_client.php6
-rw-r--r--usr/local/www/vpn_openvpn_server.php11
-rw-r--r--usr/local/www/widgets/include/carp_status.inc2
-rw-r--r--usr/local/www/widgets/include/wake_on_lan.inc7
-rw-r--r--usr/local/www/widgets/widgets/carp_status.widget.php11
-rw-r--r--usr/local/www/widgets/widgets/deactivated/cpu_graphs.widget.php (renamed from usr/local/www/widgets/widgets/cpu_graphs.widget.php)1
-rw-r--r--usr/local/www/widgets/widgets/load_balancer_status.widget.php237
-rw-r--r--usr/local/www/widgets/widgets/system_information.widget.php10
-rw-r--r--usr/local/www/widgets/widgets/traffic_graphs.widget.php2
-rw-r--r--usr/local/www/widgets/widgets/wake_on_lan.widget.php78
-rwxr-xr-xusr/local/www/wizard.php23
-rw-r--r--usr/local/www/wizards/setup_wizard.xml23
-rw-r--r--usr/local/www/wizards/traffic_shaper_wizard.inc18
-rw-r--r--usr/local/www/wizards/traffic_shaper_wizard.xml12
-rwxr-xr-xusr/local/www/wizards/traffic_shaper_wizard_dedicated.inc17
-rwxr-xr-xusr/local/www/wizards/traffic_shaper_wizard_dedicated.xml12
-rwxr-xr-xusr/local/www/wizards/traffic_shaper_wizard_multi_all.inc13
-rwxr-xr-xusr/local/www/wizards/traffic_shaper_wizard_multi_all.xml12
-rw-r--r--usr/local/www/wizards/traffic_shaper_wizard_multi_lan.inc19
-rw-r--r--usr/local/www/wizards/traffic_shaper_wizard_multi_lan.xml12
-rwxr-xr-xusr/local/www/xmlrpc.php288
-rw-r--r--usr/sbin/pc-sysinstall/backend-query/Makefile6
-rwxr-xr-xusr/sbin/pc-sysinstall/backend-query/disk-info.sh32
-rwxr-xr-xusr/sbin/pc-sysinstall/backend-query/disk-list.sh51
-rwxr-xr-xusr/sbin/pc-sysinstall/backend-query/disk-part.sh18
-rwxr-xr-xusr/sbin/pc-sysinstall/backend-query/enable-net.sh6
-rwxr-xr-xusr/sbin/pc-sysinstall/backend-query/get-packages.sh20
-rwxr-xr-xusr/sbin/pc-sysinstall/backend-query/list-components.sh39
-rwxr-xr-xusr/sbin/pc-sysinstall/backend-query/list-packages.sh34
-rwxr-xr-xusr/sbin/pc-sysinstall/backend-query/list-tzones.sh19
-rwxr-xr-xusr/sbin/pc-sysinstall/backend-query/query-langs.sh4
-rw-r--r--usr/sbin/pc-sysinstall/backend-query/set-mirror.sh40
-rwxr-xr-xusr/sbin/pc-sysinstall/backend-query/sys-mem.sh7
-rwxr-xr-xusr/sbin/pc-sysinstall/backend-query/test-live.sh13
-rwxr-xr-xusr/sbin/pc-sysinstall/backend-query/test-netup.sh10
-rwxr-xr-xusr/sbin/pc-sysinstall/backend-query/update-part-list.sh63
-rwxr-xr-xusr/sbin/pc-sysinstall/backend-query/xkeyboard-layouts.sh4
-rwxr-xr-xusr/sbin/pc-sysinstall/backend-query/xkeyboard-models.sh4
-rwxr-xr-xusr/sbin/pc-sysinstall/backend-query/xkeyboard-variants.sh4
-rwxr-xr-xusr/sbin/pc-sysinstall/backend/Makefile6
-rwxr-xr-xusr/sbin/pc-sysinstall/backend/functions-bsdlabel.sh306
-rwxr-xr-xusr/sbin/pc-sysinstall/backend/functions-cleanup.sh62
-rwxr-xr-xusr/sbin/pc-sysinstall/backend/functions-disk.sh421
-rwxr-xr-xusr/sbin/pc-sysinstall/backend/functions-extractimage.sh216
-rwxr-xr-xusr/sbin/pc-sysinstall/backend/functions-ftp.sh49
-rwxr-xr-xusr/sbin/pc-sysinstall/backend/functions-installcomponents.sh95
-rw-r--r--usr/sbin/pc-sysinstall/backend/functions-installpackages.sh125
-rwxr-xr-xusr/sbin/pc-sysinstall/backend/functions-localize.sh445
-rwxr-xr-xusr/sbin/pc-sysinstall/backend/functions-mountdisk.sh195
-rwxr-xr-xusr/sbin/pc-sysinstall/backend/functions-mountoptical.sh204
-rwxr-xr-xusr/sbin/pc-sysinstall/backend/functions-networking.sh27
-rwxr-xr-xusr/sbin/pc-sysinstall/backend/functions-newfs.sh231
-rwxr-xr-xusr/sbin/pc-sysinstall/backend/functions-packages.sh394
-rwxr-xr-xusr/sbin/pc-sysinstall/backend/functions-parse.sh29
-rwxr-xr-xusr/sbin/pc-sysinstall/backend/functions-runcommands.sh10
-rwxr-xr-xusr/sbin/pc-sysinstall/backend/functions-unmount.sh253
-rwxr-xr-xusr/sbin/pc-sysinstall/backend/functions-upgrade.sh110
-rwxr-xr-xusr/sbin/pc-sysinstall/backend/functions-users.sh184
-rwxr-xr-xusr/sbin/pc-sysinstall/backend/functions.sh325
-rw-r--r--usr/sbin/pc-sysinstall/backend/installimage.sh34
-rwxr-xr-xusr/sbin/pc-sysinstall/backend/parseconfig.sh95
-rw-r--r--usr/sbin/pc-sysinstall/conf/pc-sysinstall.conf10
-rw-r--r--usr/sbin/pc-sysinstall/doc/help-index9
-rw-r--r--usr/sbin/pc-sysinstall/examples/README24
-rw-r--r--usr/sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.810
-rwxr-xr-xusr/sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh58
163 files changed, 6019 insertions, 3341 deletions
diff --git a/conf.default/config.xml b/conf.default/config.xml
index 35d2c75..0200f4d 100644
--- a/conf.default/config.xml
+++ b/conf.default/config.xml
@@ -6,6 +6,11 @@
<theme>pfsense_ng</theme>
<sysctl>
<item>
+ <descr>Increase UFS read-ahead speeds to match current state of hard drives and NCQ. More information here: http://ivoras.sharanet.org/blog/tree/2010-11-19.ufs-read-ahead.html</descr>
+ <tunable>vfs.read_max</tunable>
+ <value>default</value>
+ </item>
+ <item>
<descr>Set the ephemeral port range to be lower.</descr>
<tunable>net.inet.ip.portrange.first</tunable>
<value>default</value>
@@ -130,11 +135,6 @@
<tunable>net.inet.tcp.tso</tunable>
<value>default</value>
</item>
- <item>
- <descr>TCP Offload Engine - BCE</descr>
- <tunable>hw.bce.tso_enable</tunable>
- <value>default</value>
- </item>
</sysctl>
<system>
<optimization>normal</optimization>
diff --git a/etc/devd.conf b/etc/devd.conf
index 647de43..7c63591 100644
--- a/etc/devd.conf
+++ b/etc/devd.conf
@@ -27,12 +27,6 @@ notify 100 {
action "/etc/rc.carpbackup $subsystem";
};
-#notify 0 {
-# match "type" "LINK_DOWN";
-# media-type "ethernet";
-# action "/usr/local/sbin/pfSctl -c 'interface linkup stop $subsystem'";
-#};
-
# When a USB keyboard arrives, attach it as the console keyboard.
attach 100 {
device-name "ukbd0";
@@ -57,6 +51,13 @@ notify 0 {
action "/usr/local/sbin/pfSctl -c 'interface linkup start $subsystem'";
};
+notify 0 {
+ match "system" "IFNET";
+ match "type" "LINK_DOWN";
+ media-type "ethernet";
+ action "/usr/local/sbin/pfSctl -c 'interface linkup stop $subsystem'";
+};
+
# Notify all users before beginning emergency shutdown when we get
# a _CRT or _HOT thermal event and we're going to power down the system
# very soon.
diff --git a/etc/ecl.php b/etc/ecl.php
new file mode 100755
index 0000000..9f68919
--- /dev/null
+++ b/etc/ecl.php
@@ -0,0 +1,164 @@
+<?php
+/*
+ external config loader
+ Copyright (C) 2010 Scott Ullrich
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+
+ Currently supported file system types: MS-Dos, FreeBSD UFS
+
+*/
+
+require("globals.inc");
+require("functions.inc");
+require("config.lib.inc");
+require("config.inc");
+
+$debug = false;
+
+function get_boot_disk() {
+ global $g, $debug;
+ $disk = exec("/sbin/mount | /usr/bin/grep \"on / \" | /usr/bin/cut -d'/' -f3 | /usr/bin/cut -d' ' -f1");
+ return $disk;
+}
+
+function get_disk_slices($disk) {
+ global $g, $debug;
+ $slices_array = array();
+ $slices = trim(exec("/bin/ls /dev/{$disk}s* 2>/dev/null"));
+ $slices = str_replace("/dev/", "", $slices);
+ if($slices == "ls: No match.")
+ return;
+ $slices_array = split(" ", $slices);
+ return $slices_array;
+}
+
+function get_disks() {
+ global $g, $debug;
+ $disks_array = array();
+ $disks = exec("/sbin/sysctl kern.disks | cut -d':' -f2");
+ $disks_s = explode(" ", $disks);
+ foreach($disks_s as $disk)
+ if(trim($disk))
+ $disks_array[] = $disk;
+ return $disks_array;
+}
+
+function discover_config($mountpoint) {
+ global $g, $debug;
+ $locations_to_check = array("/", "/config");
+ foreach($locations_to_check as $ltc) {
+ $tocheck = "/tmp/mnt/cf{$ltc}config.xml";
+ if($debug) {
+ echo "\nChecking for $tocheck";
+ if(file_exists($tocheck))
+ echo " -> found!";
+ }
+ if(file_exists($tocheck))
+ return $tocheck;
+ }
+ return "";
+}
+
+function test_config($file_location) {
+ global $g, $debug;
+ if(!$file_location)
+ return;
+ // config.xml was found. ensure it is sound.
+ $root_obj = trim("<{$g['xml_rootobj']}>");
+ $xml_file_head = exec("/usr/bin/head -2 {$file_location} | /usr/bin/tail -n1");
+ if($debug) {
+ echo "\nroot obj = $root_obj";
+ echo "\nfile head = $xml_file_head";
+ }
+ if($xml_file_head == $root_obj) {
+ // Now parse config to make sure
+ $config_status = config_validate($file_location);
+ if($config_status)
+ return true;
+ }
+ return false;
+}
+
+// Probes all disks looking for config.xml
+function find_config_xml() {
+ global $g, $debug;
+ $disks = get_disks();
+ // Safety check.
+ if(!is_array($disks))
+ return;
+ $boot_disk = get_boot_disk();
+ exec("/bin/mkdir -p /tmp/mnt/cf");
+ foreach($disks as $disk) {
+ $slices = get_disk_slices($disk);
+ if(is_array($slices)) {
+ foreach($slices as $slice) {
+ if($slice == "")
+ continue;
+ if(stristr($slice, $boot_disk)) {
+ if($debug)
+ echo "\nSkipping boot device slice $slice";
+ continue;
+ }
+ echo " $slice";
+ // First try msdos fs
+ if($debug)
+ echo "\n/sbin/mount -t msdosfs /dev/{$slice} /tmp/mnt/cf 2>/dev/null \n";
+ $result = exec("/sbin/mount -t msdosfs /dev/{$slice} /tmp/mnt/cf 2>/dev/null");
+ // Next try regular fs (ufs)
+ if(!$result) {
+ if($debug)
+ echo "\n/sbin/mount /dev/{$slice} /tmp/mnt/cf 2>/dev/null \n";
+ $result = exec("/sbin/mount /dev/{$slice} /tmp/mnt/cf 2>/dev/null");
+ }
+ $mounted = trim(exec("/sbin/mount | /usr/bin/grep -v grep | /usr/bin/grep '/tmp/mnt/cf' | /usr/bin/wc -l"));
+ if($debug)
+ echo "\nmounted: $mounted ";
+ if(intval($mounted) > 0) {
+ // Item was mounted - look for config.xml file
+ $config_location = discover_config($slice);
+ if($config_location) {
+ if(test_config($config_location)) {
+ // We have a valid configuration. Install it.
+ echo " -> found config.xml\n";
+ echo "Backing up old configuration...\n";
+ backup_config();
+ echo "Restoring [{$slice}] {$config_location}...\n";
+ restore_backup($config_location);
+ echo "Cleaning up...\n";
+ exec("/sbin/umount /tmp/mnt/cf");
+ exit;
+ }
+ exec("/sbin/umount /tmp/mnt/cf");
+ }
+ }
+ }
+ }
+ }
+}
+
+echo "External config loader 1.0 is now starting...";
+find_config_xml();
+echo "\n";
+
+?> \ No newline at end of file
diff --git a/etc/inc/auth.inc b/etc/inc/auth.inc
index dbd8a3e..60912f7 100644
--- a/etc/inc/auth.inc
+++ b/etc/inc/auth.inc
@@ -49,6 +49,9 @@
if(!$do_not_include_config_gui_inc)
require_once("config.gui.inc");
+// Will be changed to false if security checks fail
+$security_passed = true;
+
/* If this function doesn't exist, we're being called from Captive Portal or
another internal subsystem which does not include authgui.inc */
if (function_exists("display_error_form") && !isset($config['system']['webgui']['nodnsrebindcheck'])) {
@@ -61,57 +64,90 @@ if (function_exists("display_error_form") && !isset($config['system']['webgui'][
$http_host = $_SERVER['HTTP_HOST'];
}
if(is_ipaddr($http_host) or $_SERVER['SERVER_ADDR'] == "127.0.0.1" or
- $http_host == "localhost" or $_SERVER['SERVER_ADDR'] == "localhost")
+ strcasecmp($http_host, "localhost") == 0)
+ $found_host = true;
+ if(strcasecmp($http_host, $config['system']['hostname'] . "." . $config['system']['domain']) == 0 or
+ strcasecmp($http_host, $config['system']['hostname']) == 0)
$found_host = true;
- if($config['dyndnses']['dyndns'])
+
+ if(is_array($config['dyndnses']['dyndns']) && !$found_host)
foreach($config['dyndnses']['dyndns'] as $dyndns)
- if($dyndns['host'] == $http_host or $dyndns['host'] == $_SERVER['SERVER_ADDR'])
+ if(strcasecmp($dyndns['host'], $http_host) == 0) {
$found_host = true;
+ break;
+ }
- if(!empty($config['system']['webgui']['althostnames'])) {
+ if(!empty($config['system']['webgui']['althostnames']) && !$found_host) {
$althosts = explode(" ", $config['system']['webgui']['althostnames']);
foreach ($althosts as $ah)
- if($ah == $http_host or $ah == $_SERVER['SERVER_ADDR'])
+ if(strcasecmp($ah, $http_host) == 0 or strcasecmp($ah, $_SERVER['SERVER_ADDR']) == 0) {
$found_host = true;
+ break;
+ }
}
- if($http_host == $config['system']['hostname'] . "." . $config['system']['domain'] or
- $http_host == $_SERVER['SERVER_ADDR'] or
- $http_host == $config['system']['hostname'])
- $found_host = true;
-
if($found_host == false) {
- display_error_form("501", "Potential DNS Rebind attack detected, see http://en.wikipedia.org/wiki/DNS_rebinding<br/>Try accessing the router by IP address instead of by hostname.");
- exit;
+ if(!security_checks_disabled()) {
+ display_error_form("501", "Potential DNS Rebind attack detected, see http://en.wikipedia.org/wiki/DNS_rebinding<br/>Try accessing the router by IP address instead of by hostname.");
+ exit;
+ }
+ $security_passed = false;
}
}
// If the HTTP_REFERER is something other than ourselves then disallow.
-if(function_exists("display_error_form") && !$config['system']['nohttpreferercheck']) {
+if(function_exists("display_error_form") && !isset($config['system']['webgui']['nohttpreferercheck'])) {
if($_SERVER['HTTP_REFERER']) {
- $found_host = false;
- $hostname_me = $config['system']['hostname'] . "." . $config['system']['domain'];
- if(stristr($_SERVER['HTTP_REFERER'], $hostname_me))
- $found_host = true;
- if(!empty($config['system']['webgui']['althostnames'])) {
- $althosts = explode(" ", $config['system']['webgui']['althostnames']);
- foreach ($althosts as $ah)
- if(stristr($ah, $hostname_me))
- $found_host = true;
+ if(file_exists("{$g['tmp_path']}/setupwizard_lastreferrer")) {
+ if($_SERVER['HTTP_REFERER'] == file_get_contents("{$g['tmp_path']}/setupwizard_lastreferrer")) {
+ unlink("{$g['tmp_path']}/setupwizard_lastreferrer");
+ header("Refresh: 1; url=index.php");
+ echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
+ echo "<html><head><title>" . gettext("Redirecting...") . "</title></head><body>" . gettext("Redirecting to the dashboard...") . "</body></html>";
+ exit;
+ }
}
- $interface_list_ips = get_configured_ip_addresses();
- foreach($interface_list_ips as $ilips) {
- $hostname_me_ip = $config['webgui']['protocol'] . "://" . $ilips;
- if(stristr($_SERVER['HTTP_REFERER'],$hostname_me_ip))
+ $found_host = false;
+ $referrer_host = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST);
+ if($referrer_host) {
+ if(strcasecmp($referrer_host, $config['system']['hostname'] . "." . $config['system']['domain']) == 0
+ || strcasecmp($referrer_host, $config['system']['hostname']) == 0)
$found_host = true;
+ if(!empty($config['system']['webgui']['althostnames']) && !$found_host) {
+ $althosts = explode(" ", $config['system']['webgui']['althostnames']);
+ foreach ($althosts as $ah) {
+ if(strcasecmp($referrer_host, $ah) == 0) {
+ $found_host = true;
+ break;
+ }
+ }
+ }
+ if(!$found_host) {
+ $interface_list_ips = get_configured_ip_addresses();
+ foreach($interface_list_ips as $ilips) {
+ if(strcasecmp($referrer_host, $ilips) == 0) {
+ $found_host = true;
+ break;
+ }
+ }
+ }
}
if($found_host == false) {
- display_error_form("501", "An HTTP_REFERER was detected other than what is defined in System -> Advanced (" . htmlspecialchars($_SERVER['HTTP_REFERER']) . "). You can disable this check if needed in System -> Advanced -> Admin.");
- exit;
+ if(!security_checks_disabled()) {
+ display_error_form("501", "An HTTP_REFERER was detected other than what is defined in System -> Advanced (" . htmlspecialchars($_SERVER['HTTP_REFERER']) . "). You can disable this check if needed in System -> Advanced -> Admin.");
+ exit;
+ }
+ $security_passed = false;
}
- }
+ } else
+ $security_passed = false;
}
+if (function_exists("display_error_form") && $security_passed)
+ /* Security checks passed, so it should be OK to turn them back on */
+ restore_security_checks();
+unset($security_passed);
+
$groupindex = index_groups();
$userindex = index_users();
@@ -384,10 +420,11 @@ function local_user_set(& $user) {
$keys = base64_decode($user['authorizedkeys']);
file_put_contents("{$user_home}/.ssh/authorized_keys", $keys);
chown("{$user_home}/.ssh/authorized_keys", $user_name);
- }
+ } else
+ unlink_if_exists("{$user_home}/.ssh/authorized_keys");
$un = $lock_account ? "" : "un";
- exec("/usr/sbin/pw {$un}lock -q {$user_name}");
+ exec("/usr/sbin/pw {$un}lock {$user_name} -q");
conf_mount_ro();
}
@@ -1175,7 +1212,7 @@ function session_auth() {
$_SESSION['Logged_In'] = "True";
$_SESSION['Username'] = $_POST['usernamefld'];
$_SESSION['last_access'] = time();
- log_error("Successful login for user '{$_POST['usernamefld']}' from: {$_SERVER['REMOTE_ADDR']}");
+ log_auth("Successful webConfigurator login for user '{$_POST['usernamefld']}' from {$_SERVER['REMOTE_ADDR']}");
$HTTP_SERVER_VARS['AUTH_USER'] = $_SESSION['Username'];
if (isset($_POST['postafterlogin']))
return true;
@@ -1188,7 +1225,7 @@ function session_auth() {
} else {
/* give the user an error message */
$_SESSION['Login_Error'] = "Username or Password incorrect";
- log_error("Login attempt with user: '{$_POST['usernamefld']}' from: '{$_SERVER['REMOTE_ADDR']}' failed.");
+ log_auth("webConfigurator authentication error for '{$_POST['usernamefld']}' from {$_SERVER['REMOTE_ADDR']}");
if(isAjax()) {
echo "showajaxmessage('{$_SESSION['Login_Error']}');";
return;
diff --git a/etc/inc/captiveportal.inc b/etc/inc/captiveportal.inc
index 007bd44..e36a626 100644
--- a/etc/inc/captiveportal.inc
+++ b/etc/inc/captiveportal.inc
@@ -608,6 +608,7 @@ EOD;
$rulenum = 65310;
$ipcount = 0;
+ $ips = "";
foreach ($cpips as $cpip) {
if($ipcount == 0) {
$ips = "{$cpip} ";
@@ -616,7 +617,7 @@ EOD;
}
$ipcount++;
}
- $ips = "{ {$ips} }";
+ $ips = "{ 255.255.255.255 or {$ips} }";
$cprules .= "add {$rulenum} set 1 pass ip from any to {$ips} in\n";
$rulenum++;
$cprules .= "add {$rulenum} set 1 pass ip from {$ips} to any out\n";
@@ -1471,4 +1472,4 @@ function portal_ip_from_client_ip($cliip) {
return false;
}
-?> \ No newline at end of file
+?>
diff --git a/etc/inc/certs.inc b/etc/inc/certs.inc
index 33aac66..e82baba 100644
--- a/etc/inc/certs.inc
+++ b/etc/inc/certs.inc
@@ -308,10 +308,15 @@ function cert_get_subject($str_crt, $decode = true) {
return "unknown";
foreach ($components as $a => $v) {
- if (!strlen($subject))
- $subject = "{$a}={$v}";
- else
- $subject = "{$a}={$v}, {$subject}";
+ if (is_array($v))
+ foreach ($v as $w) {
+ $asubject = "{$a}={$w}";
+ $subject = (strlen($subject)) ? "{$asubject}, {$subject}" : $asubject;
+ }
+ else {
+ $asubject = "{$a}={$v}";
+ $subject = (strlen($subject)) ? "{$asubject}, {$subject}" : $asubject;
+ }
}
return $subject;
diff --git a/etc/inc/config.console.inc b/etc/inc/config.console.inc
index 5c5590c..1514926 100644
--- a/etc/inc/config.console.inc
+++ b/etc/inc/config.console.inc
@@ -38,7 +38,7 @@
POSSIBILITY OF SUCH DAMAGE.
- pfSense_BUILDER_BINARIES: /sbin/mount /sbin/sysctl /sbin/umount /sbin/halt /sbin/fsck /bin/sync
+ pfSense_BUILDER_BINARIES: /sbin/mount /sbin/sysctl /sbin/umount /sbin/halt /sbin/fsck
pfSense_MODULE: config
*/
diff --git a/etc/inc/config.gui.inc b/etc/inc/config.gui.inc
index b41073f..dda13cc 100644
--- a/etc/inc/config.gui.inc
+++ b/etc/inc/config.gui.inc
@@ -38,7 +38,7 @@
POSSIBILITY OF SUCH DAMAGE.
- pfSense_BUILDER_BINARIES: /sbin/mount /sbin/sysctl /sbin/umount /sbin/halt /sbin/fsck /bin/sync
+ pfSense_BUILDER_BINARIES: /sbin/mount /sbin/sysctl /sbin/umount /sbin/halt /sbin/fsck
pfSense_MODULE: config
*/
/*
@@ -49,10 +49,10 @@
require_once("globals.inc");
/* do not load this file twice. */
-if($config_inc_loaded == true)
+if($config_parsed == true)
return;
else
- $config_inc_loaded = true;
+ $config_parsed = true;
// Set the memory limit to 128M. When someone has something like 500+ tunnels
// the parser needs quite a bit of ram. Do not remove this line unless you
diff --git a/etc/inc/config.inc b/etc/inc/config.inc
index a00f910..1485669 100644
--- a/etc/inc/config.inc
+++ b/etc/inc/config.inc
@@ -38,7 +38,7 @@
POSSIBILITY OF SUCH DAMAGE.
- pfSense_BUILDER_BINARIES: /sbin/mount /sbin/sysctl /sbin/umount /sbin/halt /sbin/fsck /bin/sync
+ pfSense_BUILDER_BINARIES: /sbin/mount /sbin/sysctl /sbin/umount /sbin/halt /sbin/fsck
pfSense_MODULE: config
*/
@@ -48,10 +48,17 @@ if($g['booting']) echo ".";
//if (in_array("/etc/inc/config.inc", get_included_files()))
// return;
-// Set the memory limit to 128M. When someone has something like 500+ tunnels
+// Set the memory limit to 128M on i386. When someone has something like 500+ tunnels
// the parser needs quite a bit of ram. Do not remove this line unless you
// know what you are doing. If in doubt, check with dev@ _/FIRST/_!
-ini_set("memory_limit","128M");
+if(!$ARCH)
+ $ARCH = php_uname("m");
+
+// Set memory limit to 256M on amd64.
+if($ARCH == "amd64")
+ ini_set("memory_limit","256M");
+else
+ ini_set("memory_limit","128M");
/* include globals from notices.inc /utility/XML parser files */
require_once("notices.inc");
diff --git a/etc/inc/config.lib.inc b/etc/inc/config.lib.inc
index 4feef0f..ae7e445 100644
--- a/etc/inc/config.lib.inc
+++ b/etc/inc/config.lib.inc
@@ -39,7 +39,7 @@
POSSIBILITY OF SUCH DAMAGE.
- pfSense_BUILDER_BINARIES: /sbin/mount /sbin/sysctl /sbin/umount /sbin/halt /sbin/fsck /bin/sync
+ pfSense_BUILDER_BINARIES: /sbin/mount /sbin/sysctl /sbin/umount /sbin/halt /sbin/fsck
pfSense_MODULE: config
*/
@@ -148,7 +148,7 @@ function parse_config($parse = false) {
die("Config.xml is corrupted and is 0 bytes. Could not restore a previous backup.");
}
}
- $config = parse_xml_config($g['conf_path'] . '/config.xml', $g['xml_rootobj']);
+ $config = parse_xml_config($g['conf_path'] . '/config.xml', array($g['xml_rootobj'], 'pfsense'));
if($config == "-1") {
$last_backup = discover_last_backup();
if ($last_backup)
@@ -210,8 +210,9 @@ function restore_backup($file) {
conf_mount_rw();
unlink_if_exists("{$g['tmp_path']}/config.cache");
copy("$file","/cf/conf/config.xml");
+ disable_security_checks();
log_error("{$g['product_name']} is restoring the configuration $file");
- file_notice("config.xml", "{$g['product_name']} is restoring the configuration $file", "pfSenseConfigurator", "");
+ file_notice("config.xml", "{$g['product_name']} is restoring the configuration $file", "{$g['product_name']}Configurator", "");
conf_mount_ro();
}
}
@@ -352,7 +353,7 @@ function conf_mount_ro() {
clear_subsystem_dirty('mount');
/* sync data, then force a remount of /cf */
- mwexec("/bin/sync; /bin/sync");
+ pfSense_sync();
mwexec("/sbin/mount -u -r -f {$g['cf_path']}");
mwexec("/sbin/mount -u -r -f /");
}
@@ -411,9 +412,6 @@ function convert_config() {
if ($prev_version != $config['version'])
write_config("Upgraded config version level from {$prev_version} to {$config['version']}");
-
- if($g['booting'])
- echo "Loading new configuration...";
}
/****f* config/safe_write_file
@@ -432,27 +430,32 @@ function convert_config() {
* boolean - true if successful, false if not
******/
function safe_write_file($file, $content, $force_binary) {
- $tmp_file = $file . "." . getmypid();
- $write_mode = $force_binary ? "wb" : "w";
+ $tmp_file = $file . "." . getmypid();
+ $write_mode = $force_binary ? "wb" : "w";
- $fd = fopen($tmp_file, $write_mode);
- if (!$fd) {
- // Unable to open temporary file for writing
- return false;
- }
- if (!fwrite($fd, $content)) {
- // Unable to write to temporary file
- fclose($fd);
- return false;
+ $fd = fopen($tmp_file, $write_mode);
+ if (!$fd) {
+ // Unable to open temporary file for writing
+ return false;
}
- fclose($fd);
+ if (!fwrite($fd, $content)) {
+ // Unable to write to temporary file
+ fclose($fd);
+ return false;
+ }
+ fflush($fd);
+ fclose($fd);
- if (!rename($tmp_file, $file)) {
- // Unable to move temporary file to original
- unlink($tmp_file);
- return false;
- }
- return true;
+ if (!rename($tmp_file, $file)) {
+ // Unable to move temporary file to original
+ @unlink($tmp_file);
+ return false;
+ }
+
+ // Sync file before returning
+ pfSense_sync();
+
+ return true;
}
/****f* config/write_config
@@ -569,6 +572,8 @@ function reset_factory_defaults($lock = false) {
/* copy default configuration */
copy("{$g['conf_default_path']}/config.xml", "{$g['conf_path']}/config.xml");
+ disable_security_checks();
+
/* call the wizard */
touch("/conf/trigger_initial_wizard");
if (!$lock)
@@ -593,6 +598,8 @@ function config_restore($conffile) {
unlink_if_exists("{$g['tmp_path']}/config.cache");
copy($conffile, "{$g['cf_conf_path']}/config.xml");
+ disable_security_checks();
+
unlock($lockkey);
$config = parse_config(true);
@@ -623,6 +630,8 @@ function config_install($conffile) {
copy($conffile, "{$g['conf_path']}/config.xml");
+ disable_security_checks();
+
/* unlink cache file if it exists */
if(file_exists("{$g['tmp_path']}/config.cache"))
unlink("{$g['tmp_path']}/config.cache");
@@ -633,6 +642,31 @@ function config_install($conffile) {
return 0;
}
+/*
+ * Disable security checks for DNS rebind and HTTP referrer until next time
+ * they pass (or reboot), to aid in preventing accidental lockout when
+ * restoring settings like hostname, domain, IP addresses, and settings
+ * related to the DNS rebind and HTTP referrer checks.
+ * Intended for use when restoring a configuration or directly
+ * modifying config.xml without an unconditional reboot.
+ */
+function disable_security_checks() {
+ global $g;
+ touch("{$g['tmp_path']}/disable_security_checks");
+}
+
+/* Restores security checks. Should be called after all succeed. */
+function restore_security_checks() {
+ global $g;
+ unlink_if_exists("{$g['tmp_path']}/disable_security_checks");
+}
+
+/* Returns status of security check temporary disable. */
+function security_checks_disabled() {
+ global $g;
+ return file_exists("{$g['tmp_path']}/disable_security_checks");
+}
+
function config_validate($conffile) {
global $g, $xmlerr;
@@ -690,7 +724,7 @@ function cleanup_backupcache($revisions = 30, $lock = false) {
$i = true;
if($g['booting'])
echo ".";
- $newxml = parse_xml_config($backup, $g['xml_rootobj']);
+ $newxml = parse_xml_config($backup, array($g['xml_rootobj'], 'pfsense'));
if($newxml == "-1") {
log_error("The backup cache file $backup is corrupted. Unlinking.");
unlink($backup);
@@ -803,4 +837,4 @@ function set_device_perms() {
}
}
-?> \ No newline at end of file
+?>
diff --git a/etc/inc/dyndns.class b/etc/inc/dyndns.class
index 247fa68..785c902 100644
--- a/etc/inc/dyndns.class
+++ b/etc/inc/dyndns.class
@@ -92,8 +92,8 @@
global $config, $g;
- $this->_cacheFile = "{$g['conf_path']}/dyndns_{$dnsIf}{$dnsService}.cache";
- $this->_debugFile = "{$g['varetc_path']}/dyndns_{$dnsIf}{$dnsService}.debug";
+ $this->_cacheFile = "{$g['conf_path']}/dyndns_{$dnsIf}{$dnsService}" . escapeshellarg($dnsHost) . ".cache";
+ $this->_debugFile = "{$g['varetc_path']}/dyndns_{$dnsIf}{$dnsService}" . escapeshellarg($dnsHost) . ".debug";
log_error("DynDns: updatedns() starting");
@@ -175,7 +175,7 @@
curl_setopt($ch, CURLOPT_USERAGENT, $this->_UserAgent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_INTERFACE, $this->_ifIP);
- curl_setopt($ch, CURLOPT_TIMEOUT, 30); // Completely empirical
+ curl_setopt($ch, CURLOPT_TIMEOUT, 60); // Completely empirical
}
switch ($this->_dnsService) {
@@ -902,11 +902,23 @@
$this->_ifIP = $ip_address;
if (is_private_ip($ip_address)) {
$hosttocheck = "checkip.dyndns.org";
- $checkip = gethostbyname($hosttocheck);
+ $try = 0;
+ while ($try < 3) {
+ $checkip = gethostbyname($hosttocheck);
+ if (is_ipaddr($checkip))
+ break;
+ $try++;
+ }
+ if ($try >= 3) {
+ log_error("Dyndns debug information: Could not resolve {$hosttocheck} to ip using interface ip {$ip_address}.");
+ return $ip_address; /* XXX: Might return private ip address! */
+ }
$ip_ch = curl_init("http://{$checkip}");
curl_setopt($ip_ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ip_ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ip_ch, CURLOPT_INTERFACE, $ip_address);
+ curl_setopt($ip_ch, CURLOPT_CONNECTTIMEOUT, '30');
+ curl_setopt($ip_ch, CURLOPT_TIMEOUT, 60);
$ip_result_page = curl_exec($ip_ch);
curl_close($ip_ch);
$ip_result_decoded = urldecode($ip_result_page);
diff --git a/etc/inc/filter.inc b/etc/inc/filter.inc
index 063d0ec..6aaaeeb 100644
--- a/etc/inc/filter.inc
+++ b/etc/inc/filter.inc
@@ -39,6 +39,7 @@
*/
/* DISABLE_PHP_LINT_CHECKING */
+// vim: ts=4 sw=4 noexpandtab
/* include all configuration functions */
@@ -62,31 +63,27 @@ $aliases = "";
function flowtable_configure() {
global $config, $g;
- return;
+
+ if (empty($config['system']['flowtable'])) {
+ mwexec("/sbin/sysctl net.inet.flowtable.enable=0", true);
+ return;
+ }
+
// Figure out how many flows we should reserve
// sized 2x larger than the number of unique connection destinations.
if($config['system']['maximumstates'] <> "" && is_numeric($config['system']['maximumstates']))
$maxstates = $config['system']['maximumstates'];
else
- $maxstates = "150000";
+ $maxstates = 150000;
// nmbflows cpu count * ($maxstates * 2)
- $cpus = trim(`/sbin/sysctl kern.smp.cpus | /usr/bin/cut -d' ' -f2`);
+ $cpus = trim(`/sbin/sysctl -n kern.smp.cpus`, " \n");
$nmbflows = ($cpus*($maxstates*2));
- // flowtable is not enabled
- /*
- if($config['system']['flowtable'])
- $flowtable_enable = 1;
- else
- $flowtable_enable = 0;
// Flowtable currently only works on 8.0
if(get_freebsd_version() == "8") {
- if($flowtable_enable == 1) {
- mwexec("/sbin/sysctl net.inet.flowtable.nmbflows={$config['system']['maximumstates']}");
- mwexec("/sbin/sysctl net.inet.ip.output_flowtable_size={$nmbflows}");
- }
- mwexec("/sbin/sysctl net.inet.flowtable.enable={$flowtable_enable}");
+ mwexec("/sbin/sysctl net.inet.flowtable.nmbflows={$nmbflows}");
+ mwexec("/sbin/sysctl net.inet.ip.output_flowtable_size={$maxstates}");
+ mwexec("/sbin/sysctl net.inet.flowtable.enable=1");
}
- */
}
function filter_load_ipfw() {
@@ -135,16 +132,27 @@ function filter_pflog_start() {
/* reload filter async */
function filter_configure() {
+ global $g;
+
if(isset($config['system']['developerspew'])) {
$mt = microtime();
echo "filter_configure() being called $mt\n";
}
- send_event("filter reload");
+
+ /*
+ * NOTE: Check here for bootup status since this should not be triggered during bootup.
+ * The reason is that rc.bootup calls filter_configure_sync directly which does this too.
+ */
+ if (!$g['booting'])
+ send_event("filter reload");
}
function filter_delete_states_for_down_gateways() {
global $config, $GatewaysList;
+ if (isset($config['system']['kill_states']))
+ return;
+
$a_gateways = return_gateways_status();
if (is_array($GatewaysList)) {
foreach ($GatewaysList as $gwname => $gateway) {
@@ -177,8 +185,8 @@ function filter_configure_sync() {
global $config, $g, $after_filter_configure_run, $FilterIflist;
global $time_based_rules, $filterdns, $aliases;
- /* Use config lock to not allow recursion and config changes during this run. */
- $filterlck = lock('config');
+ /* Use filter lock to not allow concurrent filter reloads during this run. */
+ $filterlck = lock('filter', LOCK_EX);
filter_pflog_start();
@@ -355,7 +363,7 @@ function filter_configure_sync() {
* FilterDNS has three debugging levels. The default choosen is 1.
* Availabe are level 2 and greater then 2.
*/
- mwexec("/usr/local/sbin/filterdns {$g['tmp_path']}/filterdns.pid 300 {$g['varetc_path']}/filterdns.conf 1");
+ mwexec("/usr/local/sbin/filterdns -p {$g['tmp_path']}/filterdns.pid -i 300 -c {$g['varetc_path']}/filterdns.conf -d 1");
}
/* run items scheduled for after filter configure run */
@@ -375,8 +383,6 @@ function filter_configure_sync() {
fclose($fda);
}
- unlock($filterlck);
-
if(file_exists("{$g['tmp_path']}/commands.txt")) {
mwexec("sh {$g['tmp_path']}/commands.txt &");
unlink("{$g['tmp_path']}/commands.txt");
@@ -406,6 +412,7 @@ function filter_configure_sync() {
if($g['booting'] == true)
echo "done.\n";
+ unlock($filterlck);
return 0;
}
@@ -512,6 +519,7 @@ function filter_generate_aliases() {
$aliases .= "\n#SSH Lockout Table\n";
$aliases .= "table <sshlockout> persist\n";
+ $aliases .= "table <webConfiguratorlockout> persist\n";
$aliases .= "#Snort2C table\n";
$aliases .= "table <snort2c>\n";
@@ -847,7 +855,12 @@ function filter_get_reflection_interfaces($natif = "") {
return $nat_if_list;
}
-function filter_generate_reflection_nat($rule, $nat_ifs, $protocol, $target, $target_ip, $target_subnet = "") {
+function filter_generate_reflection_nat($rule, &$route_table, $nat_ifs, $protocol, $target, $target_ip, $target_subnet = "") {
+ global $config;
+
+ if(!isset($config['system']['enablenatreflectionhelper']))
+ return "";
+
// Initialize natrules holder string
$natrules = "";
@@ -866,21 +879,26 @@ function filter_generate_reflection_nat($rule, $nat_ifs, $protocol, $target, $ta
$protocol_text = "";
}
- $target_if_list = array();
- if(empty($target_subnet) || !is_numeric($target_subnet) || $target_subnet == 32) {
- $target_if_list[] = guess_interface_from_ip($target_ip);
- } else {
- $target_if_list[] = guess_interface_from_ip(gen_subnet_max($target_ip, $target_subnet));
- }
+ if(empty($target_subnet) || !is_numeric($target_subnet))
+ $target_subnet = 32;
- foreach ($target_if_list as $target_if) {
- /* Only install additional NAT rules if the
- * target is in the list of source networks */
- if(in_array($target_if, $nat_ifs)) {
- $target_networks = "{$target_if}:network";
+ if(!is_array($route_table)) {
+ $route_table = array();
+ /* create a route table we can search */
+ exec("netstat -rnWf inet", $route_table);
+ }
- $natrules .= "no nat on {$target_if}{$protocol_text} from {$target_if} to {$target}\n";
- $natrules .= "nat on {$target_if}{$protocol_text} from {$target_networks} to {$target} -> {$target_if}{$static_port}\n";
+ /* Search for matching subnets in the routing table */
+ foreach($route_table as $line) {
+ if(preg_match("/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\/[0-9]+[ ]+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|link[#])/", $line)) {
+ $fields = preg_split("/[ ]+/", $line);
+ $subnet = $fields[0];
+ $subnet_split = explode("/", $subnet);
+ $subnet_if = $fields[6];
+ if(in_array($subnet_if, $nat_ifs) && check_subnets_overlap($target_ip, $target_subnet, $subnet_split[0], $subnet_split[1])) {
+ $natrules .= "no nat on {$subnet_if}{$protocol_text} from {$subnet_if} to {$target}\n";
+ $natrules .= "nat on {$subnet_if}{$protocol_text} from {$subnet} to {$target} -> {$subnet_if}{$static_port}\n";
+ }
}
}
@@ -1145,6 +1163,7 @@ function filter_nat_rules_generate() {
update_filter_reload_status("Creating 1:1 rules...");
$reflection_txt = "";
+ $route_table = "";
/* any 1:1 mappings? */
if(is_array($config['nat']['onetoone'])) {
@@ -1202,7 +1221,7 @@ function filter_nat_rules_generate() {
}
$nat_if_list = array_merge(array($natif), $nat_if_list);
- $reflection_txt .= filter_generate_reflection_nat($rule, $nat_if_list, "", $srcaddr, $srcip, $sn);
+ $reflection_txt .= filter_generate_reflection_nat($rule, $route_table, $nat_if_list, "", $srcaddr, $srcip, $sn);
}
}
$natrules .= "\n# Outbound NAT rules\n";
@@ -1495,25 +1514,12 @@ function filter_nat_rules_generate() {
fclose($inetd_fd); // Close file handle
// Check if inetd is running, if not start it. If so, restart it gracefully.
$helpers = isvalidproc("inetd");
- if(!$helpers)
- mwexec("/usr/sbin/inetd -wW -R 0 -a 127.0.0.1 /var/etc/inetd.conf");
- else
- sigkillbypid("/var/run/inetd.pid", "HUP");
-
- $pptpdcfg = $config['pptpd'];
- if($pptpdcfg['mode'] && $pptpdcfg['mode'] == "redir") {
- $pptpdtarget = $pptpdcfg['redir'];
- if(is_ipaddr($pptpdtarget) && is_array($FilterIflist['wan'])) {
- $natrules .= <<<EOD
-
-# PPTP
-rdr on \${$FilterIflist['wan']['descr']} proto gre from any to any -> $pptpdtarget
-rdr on \${$FilterIflist['wan']['descr']} proto tcp from any to any port 1723 -> $pptpdtarget
-
-EOD;
- }
+ if(file_exists("/var/etc/inetd.conf")) {
+ if(!$helpers)
+ mwexec("/usr/sbin/inetd -wW -R 0 -a 127.0.0.1 /var/etc/inetd.conf");
+ else
+ sigkillbypid("/var/run/inetd.pid", "HUP");
}
-
$natrules .= discover_pkg_rules("nat");
$natrules .= filter_process_carp_nat_rules();
@@ -2027,46 +2033,9 @@ function filter_rules_generate() {
$ipfrules = "";
//$ipfrules .= discover_pkg_rules("filter");
- /* if captive portal is enabled, ensure that access to this port
- * is allowed on a locked down interface
- */
- if(isset($config['captiveportal']['enable'])) {
- $cpinterfaces = explode(",", $config['captiveportal']['interface']);
- $cpiflist = array();
- $cpiplist = array();
- foreach ($cpinterfaces as $cpifgrp) {
- if(!isset($FilterIflist[$cpifgrp]))
- continue;
- $tmpif = get_real_interface($cpifgrp);
- if(!empty($tmpif)) {
- $cpiflist[] = "{$tmpif}";
- $cpipm = get_interface_ip($cpifgrp);
- if(is_ipaddr($cpipm)) {
- $carpif = link_ip_to_carp_interface($cpipm);
- if (!empty($carpif)) {
- $cpiflist[] = $carpif;
- $carpsif = explode(" ", $carpif);
- foreach ($carpsif as $cpcarp) {
- $carpip = find_interface_ip($cpcarp);
- if (is_ipaddr($carpip))
- $cpiplist[] = $carpip;
- }
- }
- $cpiplist[] = $cpipm;
- }
- }
- }
- if (count($cpiplist) > 0 && count($cpiflist) > 0) {
- $cpinterface = implode(" ", $cpiflist);
- $cpaddresses = implode(" ", $cpiplist);
- $ipfrules .= "pass in quick on { {$cpinterface} } proto tcp from any to { {$cpaddresses} } port { 8000 8001 } keep state(sloppy)\n";
- $ipfrules .= "pass out quick on { {$cpinterface} } proto tcp from { {$cpaddresses} } port { 8000 8001 } to any keep state(sloppy)\n";
- }
- }
/* relayd */
$ipfrules .= "anchor \"relayd/*\"\n";
# BEGIN OF firewall rules
- $ipfrules .= "anchor \"firewallrules\"\n";
/* default block logging? */
if(!isset($config['syslog']['nologdefaultblock']))
$log = "log";
@@ -2100,16 +2069,6 @@ EOD;
block quick from <snort2c> to any label "Block snort2c hosts"
block quick from any to <snort2c> label "Block snort2c hosts"
-# package manager early specific hook
-anchor "packageearly"
-
-EOD;
-
- $ipfrules .= <<<EOD
-
-# carp
-anchor "carp"
-
EOD;
$ipfrules .= filter_process_carp_rules();
@@ -2124,15 +2083,65 @@ EOD;
$sshport = $config['system']['ssh']['port'];
else
$sshport = 22;
- $ipfrules .= "block in log quick proto tcp from <sshlockout> to any port {$sshport} label \"sshlockout\"\n";
+ if($sshport)
+ $ipfrules .= "block in log quick proto tcp from <sshlockout> to any port {$sshport} label \"sshlockout\"\n";
}
+ $ipfrules .= "\n# webConfigurator lockout\n";
+ if(!$config['system']['webgui']['port']) {
+ if($config['system']['webgui']['protocol'] == "http")
+ $webConfiguratorlockoutport = "80";
+ else
+ $webConfiguratorlockoutport = "443";
+ } else {
+ $webConfiguratorlockoutport = $config['system']['webgui']['port'];
+ }
+ if($webConfiguratorlockoutport)
+ $ipfrules .= "block in log quick proto tcp from <webConfiguratorlockout> to any port {$webConfiguratorlockoutport} label \"webConfiguratorlockout\"\n";
+
/*
* Support for allow limiting of TCP connections by establishment rate
* Useful for protecting against sudden outburts, etc.
*/
$ipfrules .= "block in quick from <virusprot> to any label \"virusprot overload table\"\n";
+ /* if captive portal is enabled, ensure that access to this port
+ * is allowed on a locked down interface
+ */
+ if(isset($config['captiveportal']['enable'])) {
+ $cpinterfaces = explode(",", $config['captiveportal']['interface']);
+ $cpiflist = array();
+ $cpiplist = array();
+ foreach ($cpinterfaces as $cpifgrp) {
+ if(!isset($FilterIflist[$cpifgrp]))
+ continue;
+ $tmpif = get_real_interface($cpifgrp);
+ if(!empty($tmpif)) {
+ $cpiflist[] = "{$tmpif}";
+ $cpipm = get_interface_ip($cpifgrp);
+ if(is_ipaddr($cpipm)) {
+ $carpif = link_ip_to_carp_interface($cpipm);
+ if (!empty($carpif)) {
+ $cpiflist[] = $carpif;
+ $carpsif = explode(" ", $carpif);
+ foreach ($carpsif as $cpcarp) {
+ $carpip = find_interface_ip($cpcarp);
+ if (is_ipaddr($carpip))
+ $cpiplist[] = $carpip;
+ }
+ }
+ $cpiplist[] = $cpipm;
+ }
+ }
+ }
+ if (count($cpiplist) > 0 && count($cpiflist) > 0) {
+ $cpinterface = implode(" ", $cpiflist);
+ $cpaddresses = implode(" ", $cpiplist);
+ $ipfrules .= "pass in {$log} quick on { {$cpinterface} } proto tcp from any to { {$cpaddresses} } port { 8000 8001 } keep state(sloppy)\n";
+ $ipfrules .= "pass out {$log} quick on { {$cpinterface} } proto tcp from any port { 8000 8001 80 } to any flags any keep state(sloppy)\n";
+ }
+ }
+
$bogontableinstalled = 0;
foreach ($FilterIflist as $on => $oc) {
/* block bogon networks */
@@ -2144,7 +2153,6 @@ EOD;
$ipfrules .= <<<EOD
# block bogon networks
# http://www.cymru.com/Documents/bogon-bn-nonagg.txt
-anchor "{$on}bogons"
block in $log quick on \${$oc['descr']} from <bogons> to any label "block bogon networks from {$oc['descr']}"
EOD;
@@ -2177,11 +2185,8 @@ EOD;
}
switch ($oc['type']) {
case "pptp":
- /* XXX: The proto gre rules should really be removed when the pptp patch is guaranted to work */
$ipfrules .= <<<EOD
# allow PPTP client
-anchor "pptpclient"
-pass in on \${$oc['descr']} proto gre from any to any modulate state label "allow PPTP client"
pass in on \${$oc['descr']} proto tcp from any to any port = 1723 flags S/SA modulate state label "allow PPTP client on {$oc['descr']}"
EOD;
@@ -2190,7 +2195,6 @@ EOD;
case "carpdev-dhcp":
$ipfrules .= <<<EOD
# allow our DHCP client out to the {$oc['descr']}
-anchor "{$on}dhcp"
pass in on \${$oc['descr']} proto udp from any port = 67 to any port = 68 label "allow dhcp client out {$oc['descr']}"
pass out on \${$oc['descr']} proto udp from any port = 68 to any port = 67 label "allow dhcp client out {$oc['descr']}"
# Not installing DHCP server firewall rules for {$oc['descr']} which is configured for DHCP.
@@ -2208,7 +2212,6 @@ EOD;
$ipfrules .= <<<EOD
# allow access to DHCP server on {$oc['descr']}
-anchor "dhcpserver{$oc['descr']}"
pass in on \${$oc['descr']} proto udp from any port = 68 to 255.255.255.255 port = 67 label "allow access to DHCP server"
pass in on \${$oc['descr']} proto udp from any port = 68 to {$oc['ip']} port = 67 label "allow access to DHCP server"
pass out on \${$oc['descr']} proto udp from {$oc['ip']} port = 67 to any port = 68 label "allow access to DHCP server"
@@ -2238,17 +2241,13 @@ EOD;
* rules before them.
*/
$ipfrules .= <<<EOD
-anchor "spoofing"
# loopback
-anchor "loopback"
pass in on \$loopback all label "pass loopback"
pass out on \$loopback all label "pass loopback"
pass in on \$loopback inet6 all label "pass loopback"
pass out on \$loopback inet6 all label "pass loopback"
-anchor "firewallout"
-
EOD;
$ipfrules .= <<<EOD
@@ -2302,7 +2301,6 @@ EOD;
$lanif = $FilterIflist['lan']['if'];
$ipfrules .= <<<EOD
# make sure the user cannot lock himself out of the webConfigurator or SSH
-anchor "anti-lockout"
pass in quick on {$lanif} proto tcp from any to ({$lanif}) port { $portarg $sshport } keep state label "anti-lockout rule"
EOD;
@@ -2311,7 +2309,6 @@ EOD;
$wanif = $FilterIflist["wan"]['if'];
$ipfrules .= <<<EOD
# make sure the user cannot lock himself out of the webConfigurator or SSH
-anchor "anti-lockout"
pass in quick on {$wanif} proto tcp from any to ({$wanif}) port { $portarg $sshport } keep state label "anti-lockout rule"
EOD;
@@ -2326,8 +2323,6 @@ EOD;
if(is_ipaddr($pptpdtarget) and is_array($FilterIflist['wan'])) {
$ipfrules .= <<<EOD
# PPTPd rules
-anchor "pptp"
-pass in on \${$FilterIflist['wan']['descr']} proto gre from any to $pptpdtarget keep state label "allow gre pptpd"
pass in on \${$FilterIflist['wan']['descr']} proto tcp from any to $pptpdtarget port = 1723 modulate state label "allow pptpd {$pptpdtarget}"
EOD;
@@ -2391,7 +2386,6 @@ EOD;
* topologies
*/
if(isset($config['filter']['bypassstaticroutes']) && is_array($config['staticroutes']['route']) && count($config['staticroutes']['route'])) {
- $ipfrules .= "anchor \"staticrouted\" \n";
foreach ($config['staticroutes']['route'] as $route) {
$friendly = $GatewaysList[$route['gateway']]['friendlyiface'];
if(is_array($FilterIflist[$friendly])) {
@@ -2436,13 +2430,8 @@ EOD;
$ipfrules .= filter_generate_ipsec_rules();
$ipfrules .= <<<EOD
-# package manager late specific hook
-anchor "packagelate"
-
anchor "tftp-proxy/*"
-anchor "limitingesr"
-
# uPnPd
anchor "miniupnpd"
@@ -2886,6 +2875,4 @@ function discover_pkg_rules($ruletype) {
return $rules;
}
-// vim: ts=4 sw=4 noexpandtab
-
?>
diff --git a/etc/inc/globals.inc b/etc/inc/globals.inc
index b8593dc..ba97ba0 100644
--- a/etc/inc/globals.inc
+++ b/etc/inc/globals.inc
@@ -41,7 +41,7 @@ function remove_numbers($string) {
}
function get_nics_with_capabilities($CAPABILITIES) {
- $ifs = `ifconfig -l`;
+ $ifs = `/sbin/ifconfig -l`;
$if_list = split(" ", $ifs);
$vlan_native_supp = array();
foreach($if_list as $if => $iface) {
@@ -113,7 +113,7 @@ $vlan_native_supp = get_nics_with_capabilities("vlanmtu");
if(count($vlan_native_supp) > 0)
$g['vlan_long_frame'] = $vlan_native_supp;
else
- $g['vlan_long_frame'] = array("vge", "bfe", "bge", "dc", "em", "fxp", "gem", "hme", "ixgb", "le", "nge", "re", "rl", "sis", "sk", "ste", "ti", "tl", "tx", "txp", "vr", "xl", "lagg");
+ $g['vlan_long_frame'] = array("vge", "bfe", "bge", "dc", "em", "fxp", "gem", "hme", "ixgb", "le", "lem", "nge", "re", "rl", "sis", "sk", "ste", "ti", "tl", "tx", "txp", "vr", "xl", "lagg");
/* IP TOS flags */
$iptos = array("lowdelay", "throughput", "reliability");
@@ -122,7 +122,7 @@ $iptos = array("lowdelay", "throughput", "reliability");
$tcpflags = array("syn", "ack", "fin", "rst", "psh", "urg");
if(file_exists("/etc/platform")) {
- $arch = trim(`uname -m`);
+ $arch = php_uname("m");
$g['platform'] = trim(file_get_contents("/etc/platform"));
if($g['platform'] == "nanobsd") {
$g['update_url']="http://snapshots.pfsense.org/FreeBSD_RELENG_8_1/{$arch}/pfSense_HEAD/.updaters/";
@@ -138,32 +138,33 @@ if(file_exists("/etc/platform")) {
/* Default sysctls */
$sysctls = array("net.inet.ip.portrange.first" => "1024",
- "net.inet.tcp.blackhole" => "2",
- "net.inet.udp.blackhole" => "1",
- "net.inet.ip.random_id" => "1",
- "net.inet.tcp.drop_synfin" => "1",
- "net.inet.ip.redirect" => "1",
- "net.inet6.ip6.redirect" => "1",
- "net.inet.tcp.syncookies" => "1",
- "net.inet.tcp.recvspace" => "65228",
- "net.inet.tcp.sendspace" => "65228",
- "net.inet.ip.fastforwarding" => "1",
- "net.inet.tcp.delayed_ack" => "0",
- "net.inet.udp.maxdgram" => "57344",
- "net.link.bridge.pfil_onlyip" => "0",
- "net.link.bridge.pfil_member" => "1",
- "net.link.bridge.pfil_bridge" => "0",
- "net.link.tap.user_open" => "1",
- "kern.rndtest.verbose" => "0",
- "kern.randompid" => "347",
- "net.inet.ip.intr_queue_maxlen" => "1000",
- "hw.syscons.kbd_reboot" => "0",
- "net.inet.tcp.inflight.enable" => "1",
- "net.inet.tcp.log_debug" => "0",
- "net.inet.tcp.tso" => "1",
- "net.inet.icmp.icmplim" => "0"
- );
-
-$config_inc_loaded = false;
-
-?> \ No newline at end of file
+ "net.inet.tcp.blackhole" => "2",
+ "net.inet.udp.blackhole" => "1",
+ "net.inet.ip.random_id" => "1",
+ "net.inet.tcp.drop_synfin" => "1",
+ "net.inet.ip.redirect" => "1",
+ "net.inet6.ip6.redirect" => "1",
+ "net.inet.tcp.syncookies" => "1",
+ "net.inet.tcp.recvspace" => "65228",
+ "net.inet.tcp.sendspace" => "65228",
+ "net.inet.ip.fastforwarding" => "0",
+ "net.inet.tcp.delayed_ack" => "0",
+ "net.inet.udp.maxdgram" => "57344",
+ "net.link.bridge.pfil_onlyip" => "0",
+ "net.link.bridge.pfil_member" => "1",
+ "net.link.bridge.pfil_bridge" => "0",
+ "net.link.tap.user_open" => "1",
+ "kern.rndtest.verbose" => "0",
+ "kern.randompid" => "347",
+ "net.inet.ip.intr_queue_maxlen" => "1000",
+ "hw.syscons.kbd_reboot" => "0",
+ "net.inet.tcp.inflight.enable" => "1",
+ "net.inet.tcp.log_debug" => "0",
+ "net.inet.tcp.tso" => "1",
+ "net.inet.icmp.icmplim" => "0",
+ "vfs.read_max" => "32"
+);
+
+$config_parsed = false;
+
+?>
diff --git a/etc/inc/gwlb.inc b/etc/inc/gwlb.inc
index 3d1ec93..cc9aa74 100644
--- a/etc/inc/gwlb.inc
+++ b/etc/inc/gwlb.inc
@@ -41,8 +41,6 @@ function setup_gateways_monitor() {
if (!is_array($gateways_arr)) {
log_error("No gateways to monitor. Apinger will not be run.");
killbypid("{$g['varrun_path']}/apinger.pid");
- // TEMPORARY XXX
- exec("/usr/bin/killall -9 apinger");
@unlink("{$g['tmp_path']}/apinger.status");
return;
}
@@ -220,7 +218,7 @@ EOD;
log_error("Removing static route for monitor {$gateway['monitor']} and adding a new route through {$gateway['gateway']}");
mwexec("/sbin/route delete -host " . escapeshellarg($gateway['monitor']), true);
mwexec("/sbin/route add -host " . escapeshellarg($gateway['monitor']) .
- " " . escapeshellarg($gateway['gateway']));
+ " " . escapeshellarg($gateway['gateway']), true);
}
$apingerconfig .= $alarmscfg;
@@ -230,8 +228,6 @@ EOD;
fclose($fd);
killbypid("{$g['varrun_path']}/apinger.pid");
- // TEMPORARY XXX
- exec("/usr/bin/killall -9 apinger");
if (is_dir("{$g['tmp_path']}"))
chmod("{$g['tmp_path']}", 01777);
if (!is_dir("{$g['vardb_path']}/rrd"))
@@ -241,6 +237,7 @@ EOD;
/* start a new apinger process */
@unlink("{$g['tmp_path']}/apinger.status");
+ sleep(1);
mwexec_bg("/usr/local/sbin/apinger -c {$g['varetc_path']}/apinger.conf");
return 0;
@@ -296,13 +293,14 @@ function return_gateways_array($disabled = false) {
$gateway['friendlyiface'] = $gateway['interface'];
$gateway['interface'] = get_real_interface($gateway['interface']);
- /* Some interface like wan might be default but have no info recorded
+ /* FIXME: Should this be enabled.
+ * Some interface like wan might be default but have no info recorded
* the config.
- */
if ($gateway['friendlyiface'] == "wan" && !isset($gateway['defaultgw'])) {
if (file_exists("{$g['tmp_path']}/{$gateway['interface']}_defaultgw"))
$gateway['defaultgw'] = true;
}
+ */
/* include the gateway index as the attribute */
$gateway['attribute'] = $i;
@@ -414,9 +412,11 @@ function return_gateway_groups_array() {
$tiers_count = count($tiers);
if($tiers_count == 0) {
/* Oh dear, we have no members! Engage Plan B */
- $msg = "Gateways status could not be determined, considering all as up/active.";
- log_error($msg);
- notify_via_growl($msg);
+ if (!$g['booting']) {
+ $msg = "Gateways status could not be determined, considering all as up/active.";
+ log_error($msg);
+ notify_via_growl($msg);
+ }
$tiers = $backupplan;
}
/* sort the tiers array by the tier key */
diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc
index 2bbc05b..4d47495 100644
--- a/etc/inc/interfaces.inc
+++ b/etc/inc/interfaces.inc
@@ -35,7 +35,7 @@
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
- pfSense_BUILDER_BINARIES: /usr/sbin/pppd /sbin/dhclient /bin/sh /usr/bin/grep /usr/bin/xargs /usr/bin/awk /usr/local/sbin/choparp
+ pfSense_BUILDER_BINARIES: /sbin/dhclient /bin/sh /usr/bin/grep /usr/bin/xargs /usr/bin/awk /usr/local/sbin/choparp
pfSense_BUILDER_BINARIES: /sbin/ifconfig /sbin/route /usr/sbin/ngctl /usr/sbin/arp /bin/kill /usr/local/sbin/mpd5
pfSense_MODULE: interfaces
@@ -84,6 +84,49 @@ function does_interface_exist($interface) {
return false;
}
+function interface_netgraph_needed($interface = "wan") {
+ global $config;
+
+ $found = false;
+ if (!empty($config['pptpd']) &&
+ $config['pptpd']['mode'] == "server")
+ $found = true;
+ if ($found == false && !empty($config['l2tp']) &&
+ $config['l2tp']['mode'] == "server")
+ $found = true;
+ if ($found == false && is_array($config['pppoes']['pppoe'])) {
+ foreach ($config['pppoes']['pppoe'] as $pppoe) {
+ if ($pppoe['mode'] != "server")
+ continue;
+ if ($pppoe['interface'] == $interface)
+ $found = true;
+ break;
+ }
+ }
+ if ($found == false && !empty($config['interfaces'][$interface])) {
+ switch ($config['interfaces'][$interface]['ipaddr']) {
+ case "ppp":
+ case "pppoe":
+ case "l2tp":
+ case "pptp":
+ $found = true;
+ break;
+ default:
+ $found = false;
+ break;
+ }
+ }
+
+ $realif = get_real_interface($interface);
+ if ($found == false)
+ pfSense_ngctl_detach("{$realif}:", $realif);
+ /* NOTE: We make sure for this on interface_ppps_configure()
+ * no need to do it here agan.
+ * else
+ * pfSense_ngctl_attach(".", $realif);
+ */
+}
+
function interfaces_loopback_configure() {
if($g['booting'])
echo "Configuring loopback interface...";
@@ -336,6 +379,12 @@ function interface_bridge_configure(&$bridge) {
$commontx = false;
if (!isset($opts['encaps']['rxcsum']))
$commonrx = false;
+ if (!isset($opts['encaps']['tso4']))
+ $commontso4 = false;
+ if (!isset($opts['encaps']['tso6']))
+ $commontso6 = false;
+ if (!isset($opts['encaps']['lro']))
+ $commonlro = false;
if ($smallermtu == 0 && !empty($mtu))
$smallermtu = $mtu;
else if (!empty($mtu) && $mtu < $smallermtu)
@@ -347,10 +396,16 @@ function interface_bridge_configure(&$bridge) {
$smallermtu = 1500;
$flags = 0;
- if ($commonrx == false)
+ if ($commonrx === false)
$flags |= IFCAP_RXCSUM;
- if ($commontx == false)
+ if ($commontx === false)
$flags |= IFCAP_TXCSUM;
+ if ($commontso4 === false)
+ $flags |= IFCAP_TSO4;
+ if ($commontso6 === false)
+ $flags |= IFCAP_TSO6;
+ if ($commonlro === false)
+ $flags |= IFCAP_LRO;
/* Add interfaces to bridge */
foreach ($members as $member) {
@@ -543,7 +598,18 @@ function interface_lagg_configure(&$lagg) {
/* Calculate smaller mtu and enforce it */
$smallermtu = 0;
foreach ($members as $member) {
- $mtu = get_interface_mtu($member);
+ $opts = pfSense_get_interface_addresses($member);
+ $mtu = $opts['mtu'];
+ if (!isset($opts['encaps']['txcsum']))
+ $commontx = false;
+ if (!isset($opts['encaps']['rxcsum']))
+ $commonrx = false;
+ if (!isset($opts['encaps']['tso4']))
+ $commontso4 = false;
+ if (!isset($opts['encaps']['tso6']))
+ $commontso6 = false;
+ if (!isset($opts['encaps']['lro']))
+ $commonlro = false;
if ($smallermtu == 0 && !empty($mtu))
$smallermtu = $mtu;
else if (!empty($mtu) && $mtu < $smallermtu)
@@ -554,11 +620,24 @@ function interface_lagg_configure(&$lagg) {
if ($smallermtu == 0)
$smallermtu = 1500;
+ $flags = 0;
+ if ($commonrx === false)
+ $flags |= IFCAP_RXCSUM;
+ if ($commontx === false)
+ $flags |= IFCAP_TXCSUM;
+ if ($commontso4 === false)
+ $flags |= IFCAP_TSO4;
+ if ($commontso6 === false)
+ $flags |= IFCAP_TSO6;
+ if ($commonlro === false)
+ $flags |= IFCAP_LRO;
+
foreach ($members as $member) {
if (!array_key_exists($member, $checklist))
continue;
/* make sure the parent interface is up */
pfSense_interface_mtu($member, $smallermtu);
+ pfSense_interface_capabilities($member, -$flags);
interfaces_bring_up($member);
mwexec("/sbin/ifconfig {$laggif} laggport {$member}");
}
@@ -573,19 +652,18 @@ function interface_lagg_configure(&$lagg) {
function interfaces_gre_configure() {
global $config;
- $i = 0;
if (is_array($config['gres']['gre']) && count($config['gres']['gre'])) {
- foreach ($config['gres']['gre'] as $gre) {
+ foreach ($config['gres']['gre'] as $i => $gre) {
if(empty($gre['greif']))
$gre['greif'] = "gre{$i}";
/* XXX: Maybe we should report any errors?! */
interface_gre_configure($gre);
- $i++;
}
}
}
-function interface_gre_configure(&$gre) {
+/* NOTE: $grekey is not used but useful for passing this function to array_walk. */
+function interface_gre_configure(&$gre, $grekey = "") {
global $config, $g;
if (!is_array($gre))
@@ -628,19 +706,19 @@ function interface_gre_configure(&$gre) {
function interfaces_gif_configure() {
global $config;
- $i = 0;
+
if (is_array($config['gifs']['gif']) && count($config['gifs']['gif'])) {
- foreach ($config['gifs']['gif'] as $gif) {
+ foreach ($config['gifs']['gif'] as $i => $gif) {
if(empty($gif['gifif']))
$gre['gifif'] = "gif{$i}";
/* XXX: Maybe we should report any errors?! */
interface_gif_configure($gif);
- $i++;
}
}
}
-function interface_gif_configure(&$gif) {
+/* NOTE: $gifkey is not used but useful for passing this function to array_walk. */
+function interface_gif_configure(&$gif, $gifkey = "") {
global $config, $g;
if (!is_array($gif))
@@ -787,9 +865,6 @@ function interfaces_configure() {
/* reload captive portal */
captiveportal_init_rules();
-
- /* set the reload filter dity flag */
- filter_configure();
}
return 0;
@@ -1089,6 +1164,7 @@ function interface_ppps_configure($interface) {
case "pppoe":
/* Bring the parent interface up */
interfaces_bring_up($port);
+ pfSense_ngctl_attach(".", $port);
break;
case "pptp":
case "l2tp":
@@ -1119,6 +1195,7 @@ function interface_ppps_configure($interface) {
log_error("Could not get a PPTP/L2TP Remote IP address from {$dhcp_gateway} for {$gway} in interfaces_ppps_configure.");
return 0;
}
+ pfSense_ngctl_attach(".", $port);
break;
case "ppp":
if (!file_exists("{$port}")) {
@@ -1414,7 +1491,7 @@ EOD;
conf_mount_ro();
}
}
-
+
/* fire up mpd */
mwexec("/usr/local/sbin/mpd5 -b -k -d {$g['varetc_path']} -f mpd_{$interface}.conf -p {$g['varrun_path']}/{$ppp['type']}_{$interface}.pid -s ppp {$ppp['type']}client");
@@ -1471,7 +1548,7 @@ function interfaces_carp_setup() {
} else
$cmdchain->add("Enable CARP preemption", "/sbin/sysctl net.inet.carp.preempt=1", true);
- $cmdchain->add("Enable CARP logging", "/sbin/sysctl net.inet.carp.log=2", true);
+ $cmdchain->add("Enable CARP logging", "/sbin/sysctl net.inet.carp.log=1", true);
if (!empty($pfsyncinterface))
$carp_sync_int = get_real_interface($pfsyncinterface);
@@ -1690,7 +1767,6 @@ function interface_carp_configure(&$vip) {
// set the vip interface to the vhid
$vipif = "vip{$vip['vhid']}";
- $interface = interface_translate_type_to_real($vip['interface']);
/*
* ensure the interface containing the VIP really exists
* prevents a panic if the interface is missing or invalid
@@ -1734,11 +1810,11 @@ function interface_carp_configure(&$vip) {
if(is_ipaddrv4($vip['subnet'])) {
$broadcast_address = gen_subnet_max($vip['subnet'], $vip['subnet_bits']);
- mwexec("/sbin/ifconfig {$vipif} {$vip['subnet']}/{$vip['subnet_bits']} vhid {$vip['vhid']} advskew {$vip['advskew']} {$password}");
+ mwexec("/sbin/ifconfig {$vipif} {$vip['subnet']}/{$vip['subnet_bits']} vhid {$vip['vhid']} advskew {$vip['advskew']} advbase {$vip['advbase']} {$password}");
}
if(is_ipaddrv6($vip['subnet'])) {
$broadcast_address = gen_subnet_max($vip['subnet'], $vip['subnet_bits']);
- mwexec("/sbin/ifconfig {$vipif} inet6 {$vip['subnet']} prefixlen {$vip['subnet_bits']} vhid {$vip['vhid']} advskew {$vip['advskew']} {$password}");
+ mwexec("/sbin/ifconfig {$vipif} inet6 {$vip['subnet']} prefixlen {$vip['subnet_bits']} vhid {$vip['vhid']} advskew {$vip['advskew']} advbase {$vip['advbase']} {$password}");
}
interfaces_bring_up($vipif);
@@ -1757,12 +1833,11 @@ function interface_carpdev_configure(&$vip) {
if($vip['password'] != "")
$password = " pass \"" . $vip_password . "\"";
- log_error("Found carpdev interface {$vip['interface']} on top of interface {$interface}");
if (empty($vip['interface']))
return;
$vipif = "vip" . $vip['vhid'];
- $realif = interface_translate_type_to_real($vip['interface']);
+ $realif = get_real_interface($vip['interface']);
interfaces_bring_up($realif);
/*
* ensure the interface containing the VIP really exists
@@ -1781,7 +1856,7 @@ function interface_carpdev_configure(&$vip) {
pfSense_ngctl_name("{$carpdevif}:", $vipif);
}
- mwexec("/sbin/ifconfig {$vipif} carpdev {$realif} vhid {$vip['vhid']} advskew {$vip['advskew']} {$password}");
+ mwexec("/sbin/ifconfig {$vipif} carpdev {$realif} vhid {$vip['vhid']} advskew {$vip['advskew']} advbase {$vip['advbase']} {$password}");
interfaces_bring_up($vipif);
/*
@@ -1813,7 +1888,7 @@ EOD;
fclose($fd);
/* fire up dhclient */
- mwexec("/sbin/dhclient -c {$g['varetc_path']}/dhclient_{$vipif}.conf {$vipif} > {$g['tmp_path']}/{$vipif}_output > {$g['tmp_path']}/{$vipif}_error_output", false);
+ mwexec("/sbin/dhclient -c {$g['varetc_path']}/dhclient_{$vipif}.conf {$vipif} >{$g['tmp_path']}/{$vipif}_output 2>{$g['tmp_path']}/{$vipif}_error_output", false);
} else {
log_error("Error: cannot open dhclient_{$vipif}.conf in interfaces_carpdev_configure() for writing.\n");
mwexec("/sbin/dhclient -b {$vipif}");
@@ -1881,6 +1956,7 @@ function interface_wireless_clone($realif, $wlcfg) {
pfSense_interface_rename($newif, $realif);
// FIXME: not sure what ngctl is for. Doesn't work.
// mwexec("/usr/sbin/ngctl name {$newif}: {$realif}", false);
+ file_put_contents("{$g['tmp_path']}/{$realif}_oldmac", get_interface_mac($realif));
}
return true;
}
@@ -2241,7 +2317,26 @@ EOD;
fwrite($fd_set, "{$wpa_supplicant} -B -i {$if} -c {$g['varetc_path']}/wpa_supplicant_{$if}.conf\n");
}
if ($wlcfg['mode'] == "hostap") {
+ /* add line to script to restore old mac to make hostapd happy */
+ if (file_exists("{$g['tmp_path']}/{$if}_oldmac")) {
+ $if_oldmac = file_get_contents("{$g['tmp_path']}/{$if}_oldmac");
+ if (is_macaddr($if_oldmac))
+ fwrite($fd_set, "{$ifconfig} " . escapeshellarg($if) .
+ " link " . escapeshellarg($if_oldmac) . "\n");
+ }
+
fwrite($fd_set, "{$hostapd} -B {$g['varetc_path']}/hostapd_{$if}.conf\n");
+
+ /* add line to script to restore spoofed mac after running hostapd */
+ if (file_exists("{$g['tmp_path']}/{$if}_oldmac")) {
+ if ($wl['spoofmac'])
+ $if_curmac = $wl['spoofmac'];
+ else
+ $if_curmac = get_interface_mac($if);
+ if (is_macaddr($if_curmac))
+ fwrite($fd_set, "{$ifconfig} " . escapeshellarg($if) .
+ " link " . escapeshellarg($if_curmac) . "\n");
+ }
}
}
@@ -2369,6 +2464,7 @@ function interface_configure($interface = "wan", $reloadall = false, $linkupeven
$wancfg = $config['interfaces'][$interface];
$realif = get_real_interface($interface);
+ $realhwif = interface_translate_type_to_real($interface);
if (!$g['booting']) {
/* remove all IPv4 addresses */
@@ -2393,7 +2489,7 @@ function interface_configure($interface = "wan", $reloadall = false, $linkupeven
interface_wireless_configure($realif, $wancfg, $wancfg['wireless']);
if ($wancfg['spoofmac']) {
- mwexec("/sbin/ifconfig " . escapeshellarg($realif) .
+ mwexec("/sbin/ifconfig " . escapeshellarg($realhwif) .
" link " . escapeshellarg($wancfg['spoofmac']));
/*
@@ -2402,20 +2498,20 @@ function interface_configure($interface = "wan", $reloadall = false, $linkupeven
*/
if (is_array($config['vlans']['vlan'])) {
foreach ($config['vlans']['vlan'] as $vlan) {
- if ($vlan['if'] == $realif)
+ if ($vlan['if'] == $realhwif)
mwexec("/sbin/ifconfig " . escapeshellarg($vlan['vlanif']) .
" link " . escapeshellarg($wancfg['spoofmac']));
}
}
} else {
- $mac = get_interface_mac(get_real_interface($wancfg['if']));
- if($mac == "ff:ff:ff:ff:ff:ff") {
+ $mac = get_interface_mac($realhwif);
+ if ($mac == "ff:ff:ff:ff:ff:ff") {
/* this is not a valid mac address. generate a
* temporary mac address so the machine can get online.
*/
echo "Generating new MAC address.";
$random_mac = generate_random_mac_address();
- mwexec("/sbin/ifconfig " . escapeshellarg(get_real_interface($wancfg['if'])) .
+ mwexec("/sbin/ifconfig " . escapeshellarg($realhwif) .
" link " . escapeshellarg($random_mac));
$wancfg['spoofmac'] = $random_mac;
write_config();
@@ -2425,7 +2521,7 @@ function interface_configure($interface = "wan", $reloadall = false, $linkupeven
/* media */
if ($wancfg['media'] || $wancfg['mediaopt']) {
- $cmd = "/sbin/ifconfig " . escapeshellarg(get_real_interface($wancfg['if']));
+ $cmd = "/sbin/ifconfig " . escapeshellarg($realhwif);
if ($wancfg['media'])
$cmd .= " media " . escapeshellarg($wancfg['media']);
if ($wancfg['mediaopt'])
@@ -2433,9 +2529,9 @@ function interface_configure($interface = "wan", $reloadall = false, $linkupeven
mwexec($cmd);
}
if (!empty($wancfg['mtu']))
- pfSense_interface_mtu($realif, $wancfg['mtu']);
+ pfSense_interface_mtu($realhwif, $wancfg['mtu']);
- $options = pfSense_get_interface_addresses($realif);
+ $options = pfSense_get_interface_addresses($realhwif);
if (is_array($options) && isset($options['caps']['polling'])) {
if (isset($config['system']['polling']))
pfSense_interface_capabilities($realif, IFCAP_POLLING);
@@ -2444,7 +2540,7 @@ function interface_configure($interface = "wan", $reloadall = false, $linkupeven
}
/* skip vlans for checksumming and polling */
- if (!stristr($realif, "vlan") && is_array($options)) {
+ if (!stristr($realhwif, "vlan") && is_array($options)) {
$flags = 0;
if(isset($config['system']['disablechecksumoffloading'])) {
if (isset($options['encaps']['txcsum']))
@@ -2482,7 +2578,7 @@ function interface_configure($interface = "wan", $reloadall = false, $linkupeven
if (!isset($config['system']['polling']) || !isset($options['caps']['polling'])) {
$flags |= IFCAP_POLLING;
}
- pfSense_interface_capabilities($realif, -$flags);
+ pfSense_interface_capabilities($realhwif, -$flags);
}
/* invalidate interface/ip/sn cache */
@@ -2540,19 +2636,21 @@ function interface_configure($interface = "wan", $reloadall = false, $linkupeven
if(does_interface_exist($wancfg['if']))
interfaces_bring_up($wancfg['if']);
+
+ interface_netgraph_needed($interface);
if (!$g['booting']) {
- interface_reload_carps($realif);
+ link_interface_to_vips($interface, "update");
unset($gre);
$gre = link_interface_to_gre($interface);
if (!empty($gre))
- interface_gre_configure($gre);
+ array_walk($gre, 'interface_gre_configure');
unset($gif);
$gif = link_interface_to_gif($interface);
if (!empty($gif))
- interface_gif_configure($gif);
+ array_walk($gif, 'interface_gif_configure');
if ($linkupevent == false) {
unset($bridgetmp);
@@ -2561,11 +2659,9 @@ function interface_configure($interface = "wan", $reloadall = false, $linkupeven
interface_bridge_add_member($bridgetmp, $realif);
}
- link_interface_to_vips($interface, "update");
-
$grouptmp = link_interface_to_group($interface);
if (!empty($grouptmp))
- interface_group_add_member($realif, $grouptmp);
+ array_walk($grouptmp, 'interface_group_add_member');
if ($interface == "lan")
/* make new hosts file */
@@ -2583,16 +2679,10 @@ function interface_configure($interface = "wan", $reloadall = false, $linkupeven
services_dnsmasq_configure();
/* update dyndns */
- services_dyndns_configure($interface);
-
- /* force DNS update */
- services_dnsupdate_process($interface);
+ send_event("service reload dyndns {$interface}");
/* reload captive portal */
captiveportal_init_rules();
-
- /* set the reload filter dity flag */
- filter_configure();
}
}
@@ -2707,6 +2797,7 @@ function interface_group_setup(&$groupname /* The parameter is an array */) {
}
function interface_group_add_member($interface, $groupname) {
+ $interface = get_real_interface($interface);
mwexec("/sbin/ifconfig {$interface} group {$groupname}", true);
}
@@ -2735,7 +2826,7 @@ function convert_real_interface_to_friendly_interface_name($interface = "wan") {
$index = intval(substr($interface, 3));
foreach ($config['virtualip']['vip'] as $counter => $vip) {
if ($vip['mode'] == "carpdev-dhcp" || $vip['mode'] == "carp") {
- if ($index == $counter)
+ if ($index == $vip['vhid'])
return $vip['interface'];
}
}
@@ -2764,22 +2855,22 @@ function convert_friendly_interface_to_friendly_descr($interface) {
global $config;
switch ($interface) {
- case "l2tp":
- $ifdesc = "L2TP";
- break;
- case "pptp":
- $ifdesc = "PPTP";
- break;
- case "pppoe":
- $ifdesc = "PPPoE";
- break;
- case "openvpn":
- $ifdesc = "OpenVPN";
- break;
- case "enc0":
- case "ipsec":
- $ifdesc = "IPsec";
- break;
+ case "l2tp":
+ $ifdesc = "L2TP";
+ break;
+ case "pptp":
+ $ifdesc = "PPTP";
+ break;
+ case "pppoe":
+ $ifdesc = "PPPoE";
+ break;
+ case "openvpn":
+ $ifdesc = "OpenVPN";
+ break;
+ case "enc0":
+ case "ipsec":
+ $ifdesc = "IPsec";
+ break;
default:
if (isset($config['interfaces'][$interface])) {
if (empty($config['interfaces'][$interface]['descr']))
@@ -2787,13 +2878,23 @@ function convert_friendly_interface_to_friendly_descr($interface) {
else
$ifdesc = strtoupper($config['interfaces'][$interface]['descr']);
break;
+ } else if (substr($interface, 0, 3) == "vip") {
+ if (is_array($config['virtualip']['vip'])) {
+ foreach ($config['virtualip']['vip'] as $counter => $vip) {
+ if ($vip['mode'] == "carpdev-dhcp" || $vip['mode'] == "carp") {
+ if ($interface == "vip{$vip['vhid']}")
+ return "{$vip['subnet']} - {$vip['descr']}";
+ }
+ }
+ }
+ } else {
+ /* if list */
+ $ifdescrs = get_configured_interface_with_descr(false, true);
+ foreach ($ifdescrs as $if => $ifname) {
+ if ($if == $interface || $ifname == $interface)
+ return $ifname;
+ }
}
- /* if list */
- $ifdescrs = get_configured_interface_with_descr(false, true);
- foreach ($ifdescrs as $if => $ifname) {
- if ($if == $interface || $ifname == $interface)
- return $ifname;
- }
break;
}
@@ -2820,10 +2921,31 @@ function convert_real_interface_to_friendly_descr($interface) {
function interface_translate_type_to_real($interface) {
global $config;
- if ($config['interfaces'][$interface]['if'] <> "")
- return $config['interfaces'][$interface]['if'];
- else
+ if (empty($config['interfaces'][$interface]))
return $interface;
+ $tmpif = $config['interfaces'][$interface];
+ switch ($tmpif['type']) {
+ case "ppp":
+ case "pppoe":
+ case "pptp":
+ case "l2tp":
+ if (is_array($config['ppps']['ppp'])) {
+ foreach ($config['ppps']['ppp'] as $pppidx => $ppp) {
+ if ($tmpif['if'] == $ppp['if']) {
+ $interface = $ppp['ports'];
+ break;
+ }
+ }
+ }
+ break;
+ case "dhcp":
+ case "static":
+ default:
+ $interface = $tmpif['if'];
+ break;
+ }
+
+ return $interface;
}
function interface_is_wireless_clone($wlif) {
@@ -3108,14 +3230,17 @@ function link_interface_to_vlans($int, $action = "") {
function link_interface_to_vips($int, $action = "") {
global $config;
- if (is_array($config['virtualip']['vip']))
- foreach ($config['virtualip']['vip'] as $vip)
- if ($int == $vip['interface']) {
- if ($action == "update")
+ if (is_array($config['virtualip']['vip'])) {
+ foreach ($config['virtualip']['vip'] as $vip) {
+ if ($int == $vip['interface']) {
+ if ($action == "update") {
+ interface_vip_bring_down($vip);
interfaces_vips_configure($int);
- else
- return $vip;
+ } else
+ return $vip;
}
+ }
+ }
}
/****f* interfaces/link_interface_to_bridge
@@ -3140,30 +3265,44 @@ function link_interface_to_bridge($int) {
function link_interface_to_group($int) {
global $config;
+ $result = array();
+
if (is_array($config['ifgroups']['ifgroupentry'])) {
foreach ($config['ifgroups']['ifgroupentry'] as $group) {
- if (in_array($int, explode(" ", $groupname['members'])))
- return "{$group['ifname']}";
+ if (in_array($int, explode(" ", $group['members'])))
+ $result[$group['ifname']] = $int;
}
}
+
+ return $result;
}
function link_interface_to_gre($interface) {
global $config;
- if (is_array($config['gres']['gre']))
+ $result = array();
+
+ if (is_array($config['gres']['gre'])) {
foreach ($config['gres']['gre'] as $gre)
if($gre['if'] == $interface)
- return $gre;
+ $result[] = $gre;
+ }
+
+ return $result;
}
function link_interface_to_gif($interface) {
global $config;
- if (is_array($config['gifs']['gif']))
+ $result = array();
+
+ if (is_array($config['gifs']['gif'])) {
foreach ($config['gifs']['gif'] as $gif)
if($gif['if'] == $interface)
- return $gif;
+ $result[] = $gif;
+ }
+
+ return $result;
}
/*
@@ -3427,7 +3566,7 @@ function is_altq_capable($int) {
*/
$capable = array("age", "ale", "an", "ath", "aue", "awi", "bce",
"bfe", "bge", "dc", "de", "ed", "em", "ep", "fxp", "gem",
- "hme", "igb", "ipw", "iwi", "jme", "le", "msk", "mxge", "my", "nfe",
+ "hme", "igb", "ipw", "iwi", "jme", "le", "lem", "msk", "mxge", "my", "nfe",
"npe", "nve", "ral", "re", "rl", "rum", "run", "bwn", "sf", "sis", "sk",
"ste", "stge", "txp", "udav", "ural", "vge", "vr", "wi", "xl",
"ndis", "tun", "ovpns", "ovpnc", "vlan", "pppoe", "pptp", "ng",
@@ -3606,4 +3745,15 @@ EOD;
unlink_if_exists($cron_file);
}
+function get_vip_descr($ipaddress) {
+ global $config;
+
+ foreach ($config['virtualip']['vip'] as $vip) {
+ if ($vip['subnet'] == $ipaddress) {
+ return ($vip['descr']);
+ }
+ }
+ return "";
+}
+
?>
diff --git a/etc/inc/ipsec.inc b/etc/inc/ipsec.inc
index a46e596..332f300 100644
--- a/etc/inc/ipsec.inc
+++ b/etc/inc/ipsec.inc
@@ -123,12 +123,18 @@ function ipsec_ikeid_next() {
*/
function ipsec_get_phase1_src(& $ph1ent) {
- if ($ph1ent['interface'])
- $if = $ph1ent['interface'];
- else
+ if ($ph1ent['interface']) {
+ if (!is_ipaddr($ph1ent['interface'])) {
+ $if = $ph1ent['interface'];
+ $interfaceip = get_interface_ip($if);
+ } else {
+ $interfaceip=$ph1ent['interface'];
+ }
+ }
+ else {
$if = "wan";
-
- $interfaceip = get_interface_ip($if);
+ $interfaceip = get_interface_ip($if);
+ }
return $interfaceip;
}
diff --git a/etc/inc/openvpn.auth-user.php b/etc/inc/openvpn.auth-user.php
index 460d681..9ca76cf 100755
--- a/etc/inc/openvpn.auth-user.php
+++ b/etc/inc/openvpn.auth-user.php
@@ -41,6 +41,7 @@
* in our config.xml file and check the credentials.
*/
+require_once("globals.inc");
require_once("config.inc");
require_once("radius.inc");
require_once("auth.inc");
@@ -95,6 +96,11 @@ if (!$username || !$password) {
/* Replaced by a sed with propper variables used below(ldap parameters). */
//<template>
+if (file_exists("{$g['varetc_path']}/openvpn/{$modeid}.ca")) {
+ putenv("LDAPTLS_CACERT={$g['varetc_path']}/openvpn/{$modeid}.ca");
+ putenv("LDAPTLS_REQCERT=never");
+}
+
$authenticated = false;
if (($strictusercn === true) && ($common_name != $username)) {
@@ -121,4 +127,4 @@ syslog(LOG_WARNING, "user {$username} authenticated\n");
exit(0);
-?> \ No newline at end of file
+?>
diff --git a/etc/inc/openvpn.inc b/etc/inc/openvpn.inc
index 2750d01..234f756 100644
--- a/etc/inc/openvpn.inc
+++ b/etc/inc/openvpn.inc
@@ -393,8 +393,9 @@ function openvpn_reconfigure($mode,& $settings) {
$sed .= "\"{$authcfg}\"";
}
$sed .= ");\\\n";
- if (isset($settings['strictusercn']))
+ if ($settings['strictusercn'])
$sed .= "\$strictusercn = true;";
+ $sed .= " \$modeid = \"{$mode_id}\";";
mwexec("/bin/cat /etc/inc/openvpn.auth-user.php | /usr/bin/sed 's/\/\/<template>/{$sed}/g' > {$g['varetc_path']}/openvpn/{$mode_id}.php");
mwexec("/bin/chmod a+x {$g['varetc_path']}/openvpn/{$mode_id}.php");
$conf .= "auth-user-pass-verify {$g['varetc_path']}/openvpn/{$mode_id}.php via-env\n";
@@ -445,19 +446,19 @@ function openvpn_reconfigure($mode,& $settings) {
break;
}
- // The port we'll listen at
- // If local_port is used, bind the management port
- if ($settings['local_port']) {
+ // If there is no bind option at all (ip and/or port), add "nobind" directive
+ // Otherwise, use the local port if defined, failing that, use lport 0 to
+ // ensure a random source port.
+ if ((empty($iface_ip)) && (!$settings['local_port']))
+ $conf .= "nobind\n";
+ elseif ($settings['local_port'])
$conf .= "lport {$settings['local_port']}\n";
- }
+ else
+ $conf .= "lport 0\n";
+
// Use unix socket to overcome the problem on any type of server
$conf .= "management {$g['varetc_path']}/openvpn/{$mode_id}.sock unix\n";
- // If there is no bind option at all (ip and/or port), add "nobind" directive
- if ((empty($iface_ip)) && (!$settings['local_port'])) {
- $conf .= "nobind\n";
- }
-
// The remote server
$conf .= "remote {$settings['server_addr']} {$settings['server_port']}\n";
@@ -576,7 +577,9 @@ function openvpn_restart($mode, & $settings) {
/* start the new process */
$fpath = $g['varetc_path']."/openvpn/{$mode_id}.conf";
mwexec_bg("nohup openvpn --config {$fpath}");
- send_event("filter reload");
+
+ if (!$g['booting'])
+ send_event("filter reload");
}
function openvpn_delete($mode, & $settings) {
@@ -935,4 +938,4 @@ function openvpn_refresh_crls() {
}
}
-?> \ No newline at end of file
+?>
diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc
index ccc9745..c68c3f7 100644
--- a/etc/inc/pfsense-utils.inc
+++ b/etc/inc/pfsense-utils.inc
@@ -320,9 +320,8 @@ function setup_microcode() {
******/
function get_carp_status() {
/* grab the current status of carp */
- $status = `/sbin/sysctl net.inet.carp.allow | cut -d" " -f2`;
- if(intval($status) == "0") return false;
- return true;
+ $status = `/sbin/sysctl -n net.inet.carp.allow`;
+ return (intval($status) > 0);
}
/*
@@ -339,11 +338,8 @@ function convert_ip_to_network_format($ip, $subnet) {
* get_carp_interface_status($carpinterface): returns the status of a carp ip
*/
function get_carp_interface_status($carpinterface) {
- /* basically cache the contents of ifconfig statement
- to speed up this routine */
- global $carp_query;
- if($carp_query == "")
- $carp_query = split("\n", `/sbin/ifconfig $carpinterface | grep carp`);
+ $carp_query = "";
+ exec("/sbin/ifconfig $carpinterface | /usr/bin/grep -v grep | /usr/bin/grep carp:", $carp_query);
foreach($carp_query as $int) {
if(stristr($int, "MASTER"))
return "MASTER";
@@ -377,17 +373,11 @@ function add_rule_to_anchor($anchor, $rule, $label) {
* remove $text from file $file
*/
function remove_text_from_file($file, $text) {
- global $fd_log;
- if($fd_log)
- fwrite($fd_log, "Adding needed text items:\n");
+ if(!file_exists($file) && !is_writable($file))
+ return;
$filecontents = file_get_contents($file);
- $textTMP = str_replace($text, "", $filecontents);
- $text = $textTMP;
- if($fd_log)
- fwrite($fd_log, $text);
- $fd = fopen($file, "w");
- fwrite($fd, $text);
- fclose($fd);
+ $text = str_replace($text, "", $filecontents);
+ @file_put_contents($file, $text);
}
/*
@@ -397,8 +387,6 @@ function remove_text_from_file($file, $text) {
function add_text_to_file($file, $text, $replace = false) {
if(file_exists($file) and is_writable($file)) {
$filecontents = file($file);
- $fout = fopen($file, "w");
-
$filecontents = array_map('rtrim', $filecontents);
array_push($filecontents, $text);
if ($replace)
@@ -406,12 +394,10 @@ function add_text_to_file($file, $text, $replace = false) {
$file_text = implode("\n", $filecontents);
- fwrite($fout, $file_text);
- fclose($fout);
+ @file_put_contents($file, $file_text);
return true;
- } else {
- return false;
}
+ return false;
}
/*
@@ -560,6 +546,7 @@ function restore_config_section($section, $new_contents) {
if(file_exists("{$g['tmp_path']}/config.cache"))
unlink("{$g['tmp_path']}/config.cache");
write_config("Restored {$section} of config file (maybe from CARP partner)");
+ disable_security_checks();
conf_mount_ro();
return;
}
@@ -581,6 +568,7 @@ function merge_config_section($section, $new_contents) {
$config[$section] = $section_xml;
unlink($fname);
write_config("Restored {$section} of config file (maybe from CARP partner)");
+ disable_security_checks();
conf_mount_ro();
return;
}
@@ -724,7 +712,7 @@ function call_pfsense_method($method, $params, $timeout = 0) {
$cli->setCredentials($username, $password);
}
$resp = $cli->send($msg, $timeout);
- if(!$resp) {
+ if(!is_object($resp)) {
log_error("XMLRPC communication error: " . $cli->errstr);
return false;
} elseif($resp->faultCode()) {
@@ -740,13 +728,16 @@ function call_pfsense_method($method, $params, $timeout = 0) {
*/
function check_firmware_version($tocheck = "all", $return_php = true) {
global $g, $config;
+
$ip = gethostbyname($g['product_website']);
if($ip == $g['product_website'])
return false;
+
$rawparams = array("firmware" => array("version" => trim(file_get_contents('/etc/version'))),
"kernel" => array("version" => trim(file_get_contents('/etc/version_kernel'))),
"base" => array("version" => trim(file_get_contents('/etc/version_base'))),
- "platform" => trim(file_get_contents('/etc/platform'))
+ "platform" => trim(file_get_contents('/etc/platform')),
+ "config_version" => $config['version']
);
if($tocheck == "all") {
$params = $rawparams;
@@ -756,22 +747,38 @@ function check_firmware_version($tocheck = "all", $return_php = true) {
$params['platform'] = $rawparams['platform'];
}
}
- if($config['system']['firmware']['branch']) {
+ if($config['system']['firmware']['branch'])
$params['branch'] = $config['system']['firmware']['branch'];
- }
- if(!$versions = call_pfsense_method('pfsense.get_firmware_version', $params)) {
+
+ /* XXX: What is this method? */
+ if(!($versions = call_pfsense_method('pfsense.get_firmware_version', $params))) {
return false;
} else {
$versions["current"] = $params;
}
+
return $versions;
}
+/*
+ * host_firmware_version(): Return the versions used in this install
+ */
+function host_firmware_version($tocheck = "") {
+ global $g, $config;
+
+ return array(
+ "firmware" => array("version" => trim(file_get_contents('/etc/version', " \n"))),
+ "kernel" => array("version" => trim(file_get_contents('/etc/version_kernel', " \n"))),
+ "base" => array("version" => trim(file_get_contents('/etc/version_base', " \n"))),
+ "platform" => trim(file_get_contents('/etc/platform', " \n")),
+ "config_version" => $config['version']
+ );
+}
+
function get_disk_info() {
$diskout = "";
exec("/bin/df -h | /usr/bin/grep -w '/' | /usr/bin/awk '{ print $2, $3, $4, $5 }'", $diskout);
return explode(' ', $diskout[0]);
- // $size, $used, $avail, $cap
}
/****f* pfsense-utils/strncpy
@@ -801,13 +808,6 @@ function strncpy(&$dst, $src, $length) {
function reload_interfaces_sync() {
global $config, $g;
- /* XXX: Use locks?! */
- if (file_exists("{$g['tmp_path']}/reloading_all")) {
- log_error("WARNING: Recursive call to interfaces sync!");
- return;
- }
- touch("{$g['tmp_path']}/reloading_all");
-
if($g['debug'])
log_error("reload_interfaces_sync() is starting.");
@@ -824,13 +824,6 @@ function reload_interfaces_sync() {
/* set up interfaces */
interfaces_configure();
-
- /* remove reloading_all trigger */
- if($g['debug'])
- log_error("Removing {$g['tmp_path']}/reloading_all");
-
- /* start devd back up */
- mwexec("/bin/rm {$g['tmp_path']}/reload*");
}
/****f* pfsense-utils/reload_all
@@ -842,7 +835,6 @@ function reload_interfaces_sync() {
* none
******/
function reload_all() {
- global $g;
send_event("service reload all");
}
@@ -855,8 +847,7 @@ function reload_all() {
* none
******/
function reload_interfaces() {
- global $g;
- touch("{$g['tmp_path']}/reload_interfaces");
+ send_event("interface all reload");
}
/****f* pfsense-utils/reload_all_sync
@@ -872,13 +863,6 @@ function reload_all_sync() {
$g['booting'] = false;
- /* XXX: Use locks?! */
- if (file_exists("{$g['tmp_path']}/reloading_all")) {
- log_error("WARNING: Recursive call to reload all sync!");
- return;
- }
- touch("{$g['tmp_path']}/reloading_all");
-
/* parse config.xml again */
$config = parse_config(true);
@@ -920,8 +904,6 @@ function reload_all_sync() {
/* restart webConfigurator if needed */
send_event("service restart webgui");
-
- mwexec("/bin/rm {$g['tmp_path']}/reload*");
}
function auto_login() {
@@ -990,21 +972,18 @@ function setup_serial_port() {
}
/* serial console - write out /boot/loader.conf */
$boot_config = file_get_contents("/boot/loader.conf");
- $boot_config_split = split("\n", $boot_config);
- $fd = fopen("/boot/loader.conf","w");
- if($fd) {
- foreach($boot_config_split as $bcs) {
- if(stristr($bcs, "console")) {
- /* DONT WRITE OUT, WE'LL DO IT LATER */
- } else {
- if($bcs <> "")
- fwrite($fd, "{$bcs}\n");
- }
- }
- if(isset($config['system']['enableserial'])) {
- fwrite($fd, "console=\"comconsole\"\n");
- }
- fclose($fd);
+ $boot_config_split = explode("\n", $boot_config);
+ if(count($boot_config_split) > 0) {
+ $new_boot_config = array();
+ // Loop through and only add lines that are not empty, and which
+ // do not contain a console directive.
+ foreach($boot_config_split as $bcs)
+ if(!empty($bcs) && (stripos($bcs, "console") === false))
+ $new_boot_config[] = $bcs;
+
+ if(isset($config['system']['enableserial']))
+ $new_boot_config[] = 'console="comconsole"';
+ file_put_contents("/boot/loader.conf", implode("\n", $new_boot_config));
}
}
$ttys = file_get_contents("/etc/ttys");
@@ -1445,8 +1424,8 @@ function isvm() {
}
function get_freebsd_version() {
- $version = trim(`/usr/bin/uname -r | /usr/bin/cut -d'.' -f1`);
- return $version;
+ $version = php_uname("r");
+ return $version[0];
}
function download_file_with_progress_bar($url_file, $destination_file, $readbody = 'read_body') {
@@ -1469,7 +1448,7 @@ function download_file_with_progress_bar($url_file, $destination_file, $readbody
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_WRITEFUNCTION, $readbody);
curl_setopt($ch, CURLOPT_NOPROGRESS, '1');
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, '5');
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, '60');
curl_setopt($ch, CURLOPT_TIMEOUT, 0);
curl_exec($ch);
@@ -1496,8 +1475,11 @@ function read_body($ch, $string) {
global $fout, $file_size, $downloaded, $sendto, $static_status, $static_output, $lastseen;
$length = strlen($string);
$downloaded += intval($length);
- $downloadProgress = round(100 * (1 - $downloaded / $file_size), 0);
- $downloadProgress = 100 - $downloadProgress;
+ if($file_size > 0) {
+ $downloadProgress = round(100 * (1 - $downloaded / $file_size), 0);
+ $downloadProgress = 100 - $downloadProgress;
+ } else
+ $downloadProgress = 0;
if($lastseen <> $downloadProgress and $downloadProgress < 101) {
if($sendto == "status") {
$tostatus = $static_status . $downloadProgress . "%";
@@ -1521,9 +1503,7 @@ function read_body($ch, $string) {
function update_output_window($text) {
global $pkg_interface;
$log = ereg_replace("\n", "\\n", $text);
- if($pkg_interface == "console") {
- /* too chatty */
- } else {
+ if($pkg_interface != "console") {
echo "\n<script language=\"JavaScript\">this.document.forms[0].output.value = \"" . $log . "\";</script>";
}
/* ensure that contents are written out */
diff --git a/etc/inc/pkg-utils.inc b/etc/inc/pkg-utils.inc
index 49fd2c5..2371939 100644
--- a/etc/inc/pkg-utils.inc
+++ b/etc/inc/pkg-utils.inc
@@ -8,6 +8,7 @@
* $Id$
******
*
+ * Copyright (C) 2010 Ermal Luçi
* Copyright (C) 2005-2006 Colin Smith (ethethlay@gmail.com)
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
@@ -34,12 +35,12 @@
*/
/*
- pfSense_BUILDER_BINARIES: /usr/bin/cd /usr/bin/tar /bin/cat /usr/sbin/fifolog_create /bin/chmod
- pfSense_BUILDER_BINARIES: /usr/bin/killall /usr/sbin/pkg_info /usr/sbin/pkg_delete /bin/rm /bin/ls
- pfSense_BUILDER_BINARIES: /sbin/pfctl
+ pfSense_BUILDER_BINARIES: /usr/bin/cd /usr/bin/tar /usr/sbin/fifolog_create /bin/chmod
+ pfSense_BUILDER_BINARIES: /usr/sbin/pkg_add /usr/sbin/pkg_info /usr/sbin/pkg_delete /bin/rm
pfSense_MODULE: pkg
*/
+require_once("globals.inc");
require_once("xmlrpc.inc");
if(file_exists("/cf/conf/use_xmlreader"))
require_once("xmlreader.inc");
@@ -47,7 +48,6 @@ else
require_once("xmlparse.inc");
require_once("service-utils.inc");
require_once("pfsense-utils.inc");
-require_once("globals.inc");
if(!function_exists("update_status")) {
function update_status($status) {
@@ -60,20 +60,33 @@ if(!function_exists("update_output_window")) {
}
}
-safe_mkdir("/var/db/pkg");
+if (!function_exists("pkg_debug")) {
+ /* set up logging if needed */
+ function pkg_debug($msg) {
+ global $g, $debug, $fd_log;
-conf_mount_rw();
+ if (!$debug)
+ return;
+
+ if (!$fd_log) {
+ if (!$fd_log = fopen("{$g['tmp_path']}/pkg_mgr_{$package}.log", "w"))
+ update_output_window("Warning, could not open log for writing.");
+ }
+ @fwrite($fd_log, $msg);
+ }
+}
+
+$vardb = "/var/db/pkg";
+safe_mkdir($vardb);
$g['platform'] = trim(file_get_contents("/etc/platform"));
+
+conf_mount_rw();
if(!is_dir("/usr/local/pkg") or !is_dir("/usr/local/pkg/pf")) {
safe_mkdir("/usr/local/pkg");
safe_mkdir("/usr/local/pkg/pf");
}
conf_mount_ro();
-$version = split("-", trim(file_get_contents("/etc/version")));
-$ver = split("\.", $version[0]);
-$g['version'] = intval($ver[1]);
-
/****f* pkg-utils/remove_package
* NAME
* remove_package - Removes package from FreeBSD if it exists
@@ -85,8 +98,7 @@ $g['version'] = intval($ver[1]);
*
******/
function remove_freebsd_package($packagestring) {
- $todel = substr(reverse_strrchr($packagestring, "."), 0, -1);
- exec("echo y | /usr/sbin/pkg_delete -x {$todel}");
+ exec("/usr/sbin/pkg_delete -x {$packagestring}");
}
/****f* pkg-utils/is_package_installed
@@ -117,12 +129,10 @@ function is_package_installed($packagename) {
function get_pkg_id($pkg_name) {
global $config;
- if(is_array($config['installedpackages']['package'])) {
- $i = 0;
- foreach($config['installedpackages']['package'] as $pkg) {
+ if (is_array($config['installedpackages']['package'])) {
+ foreach($config['installedpackages']['package'] as $idx => $pkg) {
if($pkg['name'] == $pkg_name)
- return $i;
- $i++;
+ return $idx;
}
}
return -1;
@@ -140,12 +150,12 @@ function get_pkg_id($pkg_name) {
function get_pkg_info($pkgs = 'all', $info = 'all') {
global $g;
- $freebsd_version = str_replace("\n", "", `uname -r | cut -d'-' -f1 | cut -d'.' -f1`);
- $freebsd_machine = str_replace("\n", "", `uname -m`);
+ $freebsd_version = php_uname("r");
+ $freebsd_machine = php_uname("m");
$params = array(
"pkg" => $pkgs,
"info" => $info,
- "freebsd_version" => $freebsd_version,
+ "freebsd_version" => $freebsd_version[0],
"freebsd_machine" => $freebsd_machine
);
$resp = call_pfsense_method('pfsense.get_pkgs', $params, 10);
@@ -153,14 +163,22 @@ function get_pkg_info($pkgs = 'all', $info = 'all') {
}
function get_pkg_sizes($pkgs = 'all') {
- global $g;
+ global $config, $g;
- $params = array("pkg" => $pkgs);
+ $freebsd_version = php_uname("r");
+ $freebsd_machine = php_uname("m");
+ $params = array(
+ "pkg" => $pkgs,
+ "freebsd_version" => $freebsd_version,
+ "freebsd_machine" => $freebsd_machine
+ );
$msg = new XML_RPC_Message('pfsense.get_pkg_sizes', array(php_value_to_xmlrpc($params)));
$xmlrpc_base_url = isset($config['system']['altpkgrepo']['enable']) ? $config['system']['altpkgrepo']['xmlrpcbaseurl'] : $g['xmlrpcbaseurl'];
$cli = new XML_RPC_Client($g['xmlrpcpath'], $xmlrpc_base_url);
$resp = $cli->send($msg, 10);
- if($resp and !$resp->faultCode()) {
+ if(!is_object($resp))
+ log_error("Could not get response from XMLRPC server!");
+ else if (!$resp->faultCode()) {
$raw_versions = $resp->value();
return xmlrpc_value_to_php($raw_versions);
}
@@ -173,35 +191,30 @@ function get_pkg_sizes($pkgs = 'all') {
* This function may also print output to the terminal indicating progress.
*/
function resync_all_package_configs($show_message = false) {
- global $config, $restart_sync, $pkg_interface;
+ global $config, $pkg_interface;
- $i = 0;
log_error("Resyncing configuration for all packages.");
- if(!$config['installedpackages']['package'])
+ if (!is_array($config['installedpackages']['package']))
return;
if($show_message == true)
echo "Syncing packages:";
- if (is_array($config['installedpackages']['package'])) {
- foreach($config['installedpackages']['package'] as $package) {
- if (empty($package['name']))
- continue;
- if($show_message == true)
- echo " " . $package['name'];
- get_pkg_depends($package['name'], "all");
- stop_service($package['name']);
- sync_package($i, true, true);
- if($restart_sync == true) {
- $restart_sync = false;
- if($pkg_interface == "console")
- echo "\nSyncing packages:";
- }
- $i++;
- }
+ conf_mount_rw();
+ foreach($config['installedpackages']['package'] as $idx => $package) {
+ if (empty($package['name']))
+ continue;
+ if($show_message == true)
+ echo " " . $package['name'];
+ get_pkg_depends($package['name'], "all");
+ stop_service($package['name']);
+ sync_package($idx, true, true);
+ if($pkg_interface == "console")
+ echo "\nSyncing packages:";
}
if($show_message == true)
echo " done.\n";
@unlink("/conf/needs_package_sync");
+ conf_mount_ro();
}
/*
@@ -209,11 +222,10 @@ function resync_all_package_configs($show_message = false) {
* package is installed.
*/
function is_freebsd_pkg_installed($pkg) {
- global $g;
+ $output = "";
+ exec("/usr/sbin/pkg_info -E \"{$pkg}*\"", $output, $retval);
- if(in_array($pkg, return_dir_as_array("{$g['vardb_path']}/pkg")))
- return true;
- return false;
+ return (intval($retval) == 0);
}
/*
@@ -226,7 +238,6 @@ function is_freebsd_pkg_installed($pkg) {
*/
function get_pkg_depends($pkg_name, $filetype = ".xml", $format = "files", $return_nosync = 1) {
global $config;
- require_once("notices.inc");
$pkg_id = get_pkg_id($pkg_name);
if($pkg_id == -1)
@@ -238,8 +249,10 @@ function get_pkg_depends($pkg_name, $filetype = ".xml", $format = "files", $retu
if(!file_exists("/usr/local/pkg/" . $package['configurationfile'])) {
log_error("The {$package['name']} package is missing required dependencies and is being reinstalled." . $package['configurationfile']);
uninstall_package($package['name']);
- if (install_package($package['name']) < 0)
+ if (install_package($package['name']) < 0) {
+ log_error("Failed reinstalling package {$package['name']}.");
return false;
+ }
}
$pkg_xml = parse_xml_config_pkg("/usr/local/pkg/" . $package['configurationfile'], "packagegui");
if (!empty($pkg_xml['additional_files_needed'])) {
@@ -289,21 +302,22 @@ function get_pkg_depends($pkg_name, $filetype = ".xml", $format = "files", $retu
}
function uninstall_package($pkg_name) {
- global $config;
+ global $config, $static_output;
$id = get_pkg_id($pkg_name);
if ($id >= 0) {
$pkg_depends =& $config['installedpackages']['package'][$id]['depends_on_package'];
+ $static_output .= "Removing package...\n";
+ update_output_window($static_output);
if (is_array($pkg_depends)) {
foreach ($pkg_depends as $pkg_depend)
- delete_package($pkg_depend, $id);
+ delete_package($pkg_depend);
}
}
delete_package_xml($pkg_name);
}
function force_remove_package($pkg_name) {
- global $config;
delete_package_xml($pkg_name);
}
@@ -311,8 +325,7 @@ function force_remove_package($pkg_name) {
* sync_package($pkg_name, $sync_depends = true, $show_message = false) Force a package to setup its configuration and rc.d files.
*/
function sync_package($pkg_name, $sync_depends = true, $show_message = false) {
- global $config;
- require_once("notices.inc");
+ global $config, $config_parsed;
if(empty($config['installedpackages']['package']))
return;
@@ -335,7 +348,8 @@ function sync_package($pkg_name, $sync_depends = true, $show_message = false) {
return -1;
}
$pkg_config = parse_xml_config_pkg("/usr/local/pkg/" . $package['configurationfile'], "packagegui");
-
+ if(isset($pkg_config['nosync']))
+ return;
/* Bring in package include files */
if (!empty($pkg_config['include_file'])) {
$include_file = $pkg_config['include_file'];
@@ -352,11 +366,6 @@ function sync_package($pkg_name, $sync_depends = true, $show_message = false) {
}
}
- /* XXX: Zend complains about the next line "Wrong break depth"
- * The code is obviously wrong, but I'm not sure what it's supposed to do?
- */
- if(isset($pkg_config['nosync']))
- continue;
if(!empty($pkg_config['custom_php_global_functions']))
eval($pkg_config['custom_php_global_functions']);
if(!empty($pkg_config['custom_php_resync_config_command']))
@@ -366,18 +375,30 @@ function sync_package($pkg_name, $sync_depends = true, $show_message = false) {
if(is_array($depends)) {
foreach($depends as $item) {
if(!file_exists($item)) {
+ require_once("notices.inc");
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);
log_error("Could not find {$item}. Reinstalling package.");
uninstall_package($pkg_name);
- install_package($pkg_name);
+ if (install_package($pkg_name) < 0) {
+ log_error("Reinstalling package {$package['name']} failed. Take appropriate measures!!!");
+ return -1;
+ }
} else {
$item_config = parse_xml_config_pkg($item, "packagegui");
if (empty($item_config))
continue;
if(isset($item_config['nosync']))
continue;
- if($item_config['custom_php_command_before_form'] <> "")
- eval($item_config['custom_php_command_before_form']);
+ if (!empty($item_config['include_file'])) {
+ if (file_exists($item_config['include_file']))
+ require_once($item_config['include_file']);
+ else {
+ log_error("Not calling package sync code for dependency {$item_config['name']} of {$package['name']} because some include files are missing.");
+ continue;
+ }
+ }
+ if($item_config['custom_php_global_functions'] <> "")
+ eval($item_config['custom_php_global_functions']);
if($item_config['custom_php_resync_config_command'] <> "")
eval($item_config['custom_php_resync_config_command']);
if($show_message == true)
@@ -391,87 +412,105 @@ function sync_package($pkg_name, $sync_depends = true, $show_message = false) {
/*
* pkg_fetch_recursive: Download and install a FreeBSD package and its dependencies. This function provides output to
* a progress bar and output window.
- *
- * XXX: This function needs to return where a pkg_add fails. Our current error messages aren't very descriptive.
*/
-function pkg_fetch_recursive($pkgname, $filename, $dependlevel = 0, $base_url = 'http://ftp2.freebsd.org/pub/FreeBSD/ports/i386/packages-8.1-release/Latest') {
- global $pkgent, $static_output, $g, $fd_log;
-
- $pkg_extension = strrchr($filename, '.');
+function pkg_fetch_recursive($pkgname, $filename, $dependlevel = 0, $base_url = "") {
+ global $static_output, $g;
+
+ $osname = php_uname("s");
+ $arch = php_uname("m");
+ $rel = php_uname("r");
+ $rel = strtolower(substr($rel, 0, strrpos($rel, "-")));
+ $priv_url = "http://ftp2.{$osname}.org/pub/{$osname}/ports/{$arch}/packages-{$rel}/All";
+ if (empty($base_url))
+ $base_url = $priv_url;
+ if (substr($base_url, -1) == "/")
+ $base_url = substr($base_url, 0, -1);
$static_output .= "\n" . str_repeat(" ", $dependlevel * 2) . $pkgname . " ";
- $fetchto = "{$g['tmp_path']}/apkg_{$pkgname}{$pkg_extension}";
- download_file_with_progress_bar("{$base_url}/{$filename}", $fetchto);
+ $fetchto = "{$g['tmp_path']}/apkg_{$filename}";
+ $static_output .= "\n" . str_repeat(" ", $dependlevel * 2 + 1) . "Trying to download {$base_url}/{$filename} ... ";
+ if (download_file_with_progress_bar("{$base_url}/{$filename}", $fetchto) !== true) {
+ if ($base_url != $priv_url && download_file_with_progress_bar("{$priv_url}/{$filename}", $fetchto) !== true) {
+ $static_output .= " could not download from there or {$priv_url}/{$filename}.\n";
+ update_output_window($static_output);
+ return false;
+ } else if ($base_url == $priv_url) {
+ $static_output .= " failed to download.\n";
+ update_output_window($static_output);
+ return false;
+ } else {
+ $static_output .= " downloaded from {$osname} repository instead of provided one.\n";
+ update_output_window($static_output);
+ }
+ }
$static_output .= " (extracting)";
update_output_window($static_output);
$slaveout = "";
exec("/usr/bin/tar --fast-read -O -f {$fetchto} -x +CONTENTS 2>&1", $slaveout);
- $workingdir = preg_grep("/instmp/", $slaveout);
- $workingdir = $workingdir[0];
$raw_depends_list = array_values(preg_grep("/\@pkgdep/", $slaveout));
- if($raw_depends_list != "") {
- if($pkgent['exclude_dependency'] != "")
- $raw_depends_list = array_values(preg_grep($pkgent['exclude_dependency'], PREG_GREP_INVERT));
+ if ($raw_depends_list != "") {
+ $pkg_extension = ".tbz";
foreach($raw_depends_list as $adepend) {
- $working_depend = explode(" ", $adepend);
- //$working_depend = explode("-", $working_depend[1]);
- $depend_filename = $working_depend[1] . $pkg_extension;
- if(is_freebsd_pkg_installed($working_depend[1]) === false) {
- pkg_fetch_recursive($working_depend[1], $depend_filename, $dependlevel + 1, $base_url);
+ $working_depend = explode(" ", trim($adepend, "\n"));
+ if (substr($working_depend[1], -4) != ".tbz")
+ $depend_filename = $working_depend[1] . $pkg_extension;
+ else
+ $depend_filename = $working_depend[1];
+ if (!is_freebsd_pkg_installed($working_depend[1])) {
+ if (pkg_fetch_recursive($working_depend[1], $depend_filename, $dependlevel + 1, $base_url) == false)
+ return false;
} else {
//$dependlevel++;
- $static_output .= "\n" . str_repeat(" ", $dependlevel * 2) . $working_depend[1] . " ";
- @fwrite($fd_log, $working_depend[1] . "\n");
+ $static_output .= "\n" . str_repeat(" ", $dependlevel * 2) . $working_depend[1] . " already installed.";
+ pkg_debug($working_depend[1] . "\n");
}
}
}
$pkgaddout = "";
- exec("/bin/cat {$g['tmp_path']}/y | /usr/sbin/pkg_add -fv {$fetchto} 2>&1", $pkgaddout);
- @fwrite($fd_log, $pkgname . " " . print_r($pkgaddout, true) . "\n");
+ exec("/usr/sbin/pkg_add -fv {$fetchto} 2>&1", $pkgaddout);
+ pkg_debug($pkgname . " " . print_r($pkgaddout, true) . "\npkg_add successfully completed.\n");
return true;
}
function install_package($package, $pkg_info = "") {
- global $g, $config, $pkg_interface, $fd_log, $static_output, $pkg_interface, $restart_sync;
+ global $g, $config, $static_output, $pkg_interface;
/* safe side. Write config below will send to ro again. */
conf_mount_rw();
if($pkg_interface == "console")
echo "\n";
- /* open logfiles and begin installation */
- if (!$fd_log) {
- if (!$fd_log = fopen("{$g['tmp_path']}/pkg_mgr_{$package}.log", "w"))
- update_output_window("Warning, could not open log for writing.");
- }
/* fetch package information if needed */
if(empty($pkg_info) or !is_array($pkg_info[$package])) {
$pkg_info = get_pkg_info(array($package));
$pkg_info = $pkg_info[$package]; // We're only dealing with one package, so we can strip away the extra array.
+ if (empty($pkg_info)) {
+ conf_mount_ro();
+ return -1;
+ }
}
- @fwrite($fd_log, "Beginning package installation.\n");
+ pkg_debug("Beginning package installation.\n");
log_error('Beginning package installation for ' . $pkg_info['name'] . '.');
- update_status("Beginning package installation for " . $pkg_info['name'] . "...");
+ $static_output .= "Beginning package installation for " . $pkg_info['name'] . "...";
+ update_status($static_output);
/* fetch the package's configuration file */
if($pkg_info['config_file'] != "") {
- $static_output .= "Downloading package configuration file... ";
+ $static_output .= "\nDownloading package configuration file... ";
update_output_window($static_output);
- @fwrite($fd_log, "Downloading package configuration file...\n");
+ pkg_debug("Downloading package configuration file...\n");
$fetchto = substr(strrchr($pkg_info['config_file'], '/'), 1);
download_file_with_progress_bar($pkg_info['config_file'], '/usr/local/pkg/' . $fetchto);
if(!file_exists('/usr/local/pkg/' . $fetchto)) {
- @fwrite($fd_log, "ERROR! Unable to fetch package configuration file. Aborting installation.\n");
- if($pkg_interface == "console") {
- conf_mount_ro();
+ pkg_debug("ERROR! Unable to fetch package configuration file. Aborting installation.\n");
+ if($pkg_interface == "console")
print "\nERROR! Unable to fetch package configuration file. Aborting package installation.\n";
- return;
- } else {
+ else {
$static_output .= "failed!\n\nInstallation aborted.";
update_output_window($static_output);
echo "<br>Show <a href=\"pkg_mgr_install.php?showlog=true\">install log</a></center>";
- conf_mount_ro();
- return -1;
}
+ conf_mount_ro();
+ return -1;
}
$static_output .= "done.\n";
update_output_window($static_output);
@@ -511,8 +550,6 @@ function install_package($package, $pkg_info = "") {
update_output_window($static_output);
if($pkg_info['after_install_info'])
update_output_window($pkg_info['after_install_info']);
- start_service($pkg_info['name']);
- $restart_sync = true;
}
}
@@ -539,7 +576,7 @@ function eval_once($toeval) {
}
function install_package_xml($pkg) {
- global $g, $config, $fd_log, $static_output, $pkg_interface;
+ global $g, $config, $static_output, $pkg_interface, $config_parsed;
if(($pkgid = get_pkg_id($pkg)) == -1) {
$static_output .= "The {$pkg} package is not installed.\n\nInstallation aborted.";
@@ -553,20 +590,6 @@ function install_package_xml($pkg) {
} else
$pkg_info = $config['installedpackages']['package'][$pkgid];
- /* set up logging if needed */
- if(!$fd_log) {
- if(!$fd_log = fopen("{$g['tmp_path']}/pkg_mgr_{$pkg}.log", "w")) {
- update_output_window("Warning, could not open log for writing.");
- }
- }
-
- /* make 'y' file */
- $fd = fopen("{$g['tmp_path']}/y", "w");
- for($line = 0; $line < 10; $line++) {
- fwrite($fd, "y\n");
- }
- fclose($fd);
-
/* pkg_add the package and its dependencies */
if($pkg_info['depends_on_package_base_url'] != "") {
if($pkg_interface == "console")
@@ -578,49 +601,36 @@ function install_package_xml($pkg) {
update_output_window($static_output);
foreach((array) $pkg_info['depends_on_package'] as $pkgdep) {
$pkg_name = substr(reverse_strrchr($pkgdep, "."), 0, -1);
- if(isset($pkg_info['skip_install_checks']))
- $pkg_installed = true;
- else
- $pkg_installed = is_freebsd_pkg_installed($pkg_name);
-
- if($pkg_installed == false)
- pkg_fetch_recursive($pkg_name, $pkgdep, 0, $pkg_info['depends_on_package_base_url']);
- $static_output = $static_orig . "done.\nChecking for successful package installation... ";
+ $static_output = $static_orig . "\nChecking for package installation... ";
update_output_window($static_output);
- /* make sure our package was successfully installed */
- if($pkg_installed == false)
- $pkg_installed = is_freebsd_pkg_installed($pkg_name);
- if($pkg_installed == true) {
- $static_output .= "done.\n";
- update_output_window($static_output);
- fwrite($fd_log, "pkg_add successfully completed.\n");
- } else {
- $static_output .= "of {$pkg_name} failed!\n\nInstallation aborted.";
- update_output_window($static_output);
- fwrite($fd_log, "Package WAS NOT installed properly.\n");
- fclose($fd_log);
- if($pkg_interface <> "console") {
- echo "\n<script language=\"JavaScript\">document.progressbar.style.visibility='hidden';</script>";
- echo "\n<script language=\"JavaScript\">document.progholder.style.visibility='hidden';</script>";
+ if (!is_freebsd_pkg_installed($pkg_name)) {
+ if (!pkg_fetch_recursive($pkg_name, $pkgdep, 0, $pkg_info['depends_on_package_base_url'])) {
+ $static_output .= "of {$pkg_name} failed!\n\nInstallation aborted.";
+ update_output_window($static_output);
+ pkg_debug("Package WAS NOT installed properly.\n");
+ if($pkg_interface <> "console") {
+ echo "\n<script language=\"JavaScript\">document.progressbar.style.visibility='hidden';</script>";
+ echo "\n<script language=\"JavaScript\">document.progholder.style.visibility='hidden';</script>";
+ }
+ sleep(1);
+ return false;
}
- sleep(1);
- return false;
}
}
}
$configfile = substr(strrchr($pkg_info['config_file'], '/'), 1);
if(file_exists("/usr/local/pkg/" . $configfile)) {
- $static_output .= "Loading package configuration... ";
+ $static_output .= "\nLoading package configuration... ";
update_output_window($static_output);
$pkg_config = parse_xml_config_pkg("/usr/local/pkg/" . $configfile, "packagegui");
$static_output .= "done.\n";
update_output_window($static_output);
- $static_output .= "Configuring package components...\n";
+ $static_output .= "\tConfiguring package components...\n";
if (!empty($pkg_config['filter_rules_needed']))
$config['installedpackages']['package'][$pkgid]['filter_rule_function'] = $pkg_config['filter_rules_needed'];
update_output_window($static_output);
/* modify system files */
- if(is_array($pkg_config['modify_system']['item'])) {
+ if(is_array($pkg_config['modify_system']) && is_array($pkg_config['modify_system']['item'])) {
$static_output .= "\tSystem files... ";
update_output_window($static_output);
foreach($pkg_config['modify_system']['item'] as $ms) {
@@ -652,15 +662,19 @@ function install_package_xml($pkg) {
safe_mkdir($prefix);
$static_output .= $filename . " ";
update_output_window($static_output);
- download_file_with_progress_bar($afn['item'][0], $prefix . $filename);
+ if (download_file_with_progress_bar($afn['item'][0], $prefix . $filename) !== true) {
+ $static_output .= "failed.\n";
+ update_output_window($static_output);
+ return false;
+ }
if(stristr($filename, ".tgz") <> "") {
- fwrite($fd_log, "Extracting tarball to -C for " . $filename . "...\n");
+ pkg_debug("Extracting tarball to -C for " . $filename . "...\n");
$tarout = "";
exec("/usr/bin/tar xvzf " . $prefix . $filename . " -C / 2>&1", $tarout);
- fwrite($fd_log, print_r($tarout, true) . "\n");
+ pkg_debug(print_r($tarout, true) . "\n");
}
if($pkg_chmod <> "") {
- fwrite($fd_log, "Changing file mode to {$pkg_chmod} for {$prefix}{$filename}\n");
+ pkg_debug("Changing file mode to {$pkg_chmod} for {$prefix}{$filename}\n");
@chmod($prefix . $filename, $pkg_chmod);
system("/bin/chmod {$pkg_chmod} {$prefix}{$filename}");
}
@@ -674,12 +688,20 @@ function install_package_xml($pkg) {
* show us where an error exists in a package
* instead of making us blindly guess
*/
+ $missing_include = false;
if($pkg_config['include_file'] <> "") {
- $static_output = "Loading package instructions...";
+ $static_output .= "Loading package instructions...\n";
update_output_window($static_output);
- fwrite($fd_log, "require_once('{$pkg_config['include_file']}')\n");
+ pkg_debug("require_once('{$pkg_config['include_file']}')\n");
if (file_exists($pkg_config['include_file']))
require_once($pkg_config['include_file']);
+ else {
+ $missing_include = true;
+ $static_output .= "\tInclude " . basename($pkg_config['include_file']) . " is missing!\n";
+ update_output_window($static_output);
+ /* XXX: Should undo the steps before this?! */
+ return false;
+ }
}
/* sidebar items */
if(is_array($pkg_config['menu'])) {
@@ -724,30 +746,35 @@ function install_package_xml($pkg) {
update_output_window($static_output);
}
/* custom commands */
- $static_output .= "\tCustom commands... ";
+ $static_output .= "Custom commands...\n";
update_output_window($static_output);
- if($pkg_config['custom_php_global_functions'] <> "") {
- $static_output = "Executing custom_php_global_functions()...";
- update_output_window($static_output);
- eval_once($pkg_config['custom_php_global_functions']);
- }
- if($pkg_config['custom_php_install_command']) {
- $static_output = "Executing custom_php_install_command()...";
- update_output_window($static_output);
- eval_once($pkg_config['custom_php_install_command']);
- }
- if($pkg_config['custom_php_resync_config_command'] <> "") {
- $static_output = "Executing custom_php_resync_config_command()...";
- update_output_window($static_output);
- eval_once($pkg_config['custom_php_resync_config_command']);
+ if ($missing_include == false) {
+ if($pkg_config['custom_php_global_functions'] <> "") {
+ $static_output .= "\tExecuting custom_php_global_functions()...";
+ update_output_window($static_output);
+ eval_once($pkg_config['custom_php_global_functions']);
+ $static_output .= "done.\n";
+ update_output_window($static_output);
+ }
+ if($pkg_config['custom_php_install_command']) {
+ $static_output .= "\tExecuting custom_php_install_command()...";
+ update_output_window($static_output);
+ eval_once($pkg_config['custom_php_install_command']);
+ $static_output .= "done.\n";
+ update_output_window($static_output);
+ }
+ if($pkg_config['custom_php_resync_config_command'] <> "") {
+ $static_output .= "\tExecuting custom_php_resync_config_command()...";
+ update_output_window($static_output);
+ eval_once($pkg_config['custom_php_resync_config_command']);
+ $static_output .= "done.\n";
+ update_output_window($static_output);
+ }
}
- $static_output .= "done.\n";
- update_output_window($static_output);
} else {
$static_output .= "Loading package configuration... failed!\n\nInstallation aborted.";
update_output_window($static_output);
- fwrite($fd_log, "Unable to load package configuration. Installation aborted.\n");
- fclose($fd_log);
+ pkg_debug("Unable to load package configuration. Installation aborted.\n");
if($pkg_interface <> "console") {
echo "\n<script language=\"JavaScript\">document.progressbar.style.visibility='hidden';</script>";
echo "\n<script language=\"JavaScript\">document.progholder.style.visibility='hidden';</script>";
@@ -760,64 +787,44 @@ function install_package_xml($pkg) {
if($pkg_info['logging']) {
mwexec("/usr/sbin/fifolog_create -s 32768 {$g['varlog_path']}/{$pkg_info['logging']['logfilename']}");
@chmod($g['varlog_path'] . '/' . $pkg_info['logging']['logfilename'], 0600);
- @fwrite($fd_log, "Adding text to file /etc/syslog.conf\n");
- if(is_process_running("syslogd"))
- mwexec("killall syslogd");
+ add_text_to_file("/etc/syslog.conf", $pkg_info['logging']['facilityname'] . "\t\t\t\t" . $pkg_info['logging']['logfilename']);
+ pkg_debug("Adding text to file /etc/syslog.conf\n");
system_syslogd_start();
}
return true;
}
-function delete_package($pkg, $pkgid) {
- global $g, $config, $fd_log, $static_output;
+function delete_package($pkg) {
+ global $config, $g, $static_output, $vardb;
- update_status("Removing package...");
- $static_output .= "Removing package... ";
- update_output_window($static_output);
- if (!is_array($config['installedpackages']['package']))
- return;
-
- $pkg_info =& $config['installedpackages']['package'][$pkgid];
- if (empty($pkg_info))
- return;
- if (empty($pkg_info['configurationfile']))
- return;
-
- $static_output .= "\nStarting package deletion for {$pkg_info['name']}...\n";
- update_output_window($static_output);
- if (!empty($pkg))
- delete_package_recursive($pkg);
- $static_output .= "done.\n";
- update_output_window($static_output);
-
- return;
-}
+ $pkg = substr(reverse_strrchr($pkg, "."), 0, -1);
-function delete_package_recursive($pkg) {
- global $config, $g;
- $fd = fopen("{$g['tmp_path']}/y", "w");
- for($line = 0; $line < 10; $line++) {
- fwrite($fd, "y\n");
+ if (file_exists("{$vardb}/{$pkg}/+REQUIRED_BY") && count(file("{$vardb}/{$pkg}/+REQUIRED_BY")) > 0) {
+ $static_output .= "\tSkipping package deletion for {$pkg} because it is required by other packages.\n";
+ update_output_window($static_output);
+ return;
+ } else {
+ if($pkg)
+ $static_output .= "\tStarting package deletion for {$pkg}...";
+ update_output_window($static_output);
}
- fclose($fd);
- $pkg = substr(reverse_strrchr($pkg, "."), 0, -1);
$info = "";
- exec("/usr/sbin/pkg_info -r {$pkg} 2>&1", $info);
+ exec("/usr/sbin/pkg_info -qrx {$pkg}", $info);
remove_freebsd_package($pkg);
- $pkgdb = "";
- exec("/bin/ls {$g['vardb_path']}/pkg", $pkgdb);
+ $static_output .= "done.\n";
+ update_output_window($static_output);
foreach($info as $line) {
- $depend = trim(array_pop(explode(":", $line)));
- if(in_array($depend, $pkgdb))
- delete_package_recursive($depend);
+ $depend = trim(str_replace("@pkgdep", "", $line), " \n");
+ delete_package($depend);
}
+
return;
}
function delete_package_xml($pkg) {
- global $g, $config, $fd_log, $static_output, $pkg_interface;
+ global $g, $config, $static_output, $pkg_interface;
conf_mount_rw();
@@ -834,14 +841,7 @@ function delete_package_xml($pkg) {
conf_mount_ro();
return;
}
- /* set up logging if needed */
- if(!$fd_log) {
- if(!$fd_log = fopen("{$g['tmp_path']}/pkg_mgr_{$pkg}.log", "w")) {
- update_output_window("Warning, could not open log for writing.");
- }
- }
- update_status("Removing {$pkg} components...");
- fwrite($fd_log, "Removing {$pkg} package... ");
+ pkg_debug("Removing {$pkg} package... ");
$static_output .= "Removing {$pkg} components...\n";
update_output_window($static_output);
/* parse package configuration */
@@ -849,7 +849,8 @@ function delete_package_xml($pkg) {
$tabs =& $config['installedpackages']['tab'];
$menus =& $config['installedpackages']['menu'];
$services = &$config['installedpackages']['service'];
- if(file_exists("/usr/local/pkg/" . $packages[$pkgid]['configurationfile'])) {
+ $pkg_info =& $packages[$pkgid];
+ if(file_exists("/usr/local/pkg/" . $pkg_info['configurationfile'])) {
$pkg_config = parse_xml_config_pkg("/usr/local/pkg/" . $packages[$pkgid]['configurationfile'], "packagegui");
/* remove tab items */
if(is_array($pkg_config['tabs'])) {
@@ -913,21 +914,32 @@ function delete_package_xml($pkg) {
* show us where an error exists in a package
* instead of making us blindly guess
*/
+ $missing_include = false;
if($pkg_config['include_file'] <> "") {
- $static_output = "Loading package instructions...";
+ $static_output .= "Loading package instructions...\n";
update_output_window($static_output);
- fwrite($fd_log, "require_once(\"{$pkg_config['include_file']}\")\n");
- if(file_exists($pkg_config['include_file']))
+ pkg_debug("require_once(\"{$pkg_config['include_file']}\")\n");
+ if (file_exists($pkg_config['include_file']))
require_once($pkg_config['include_file']);
- fwrite($fd_log, "require_once(\"{$pkg_config['include_file']}\") included\n");
+ else {
+ $missing_include = true;
+ update_output_window($static_output);
+ $static_output .= "\tInclude file " . basename($pkg_config['include_file']) . " could not be found for inclusion.\n";
+ }
+ }
+ /* ermal
+ * NOTE: It is not possible to handle parse errors on eval.
+ * So we prevent it from being run at all to not interrupt all the other code.
+ */
+ if ($missing_include == false) {
+ /* evalate this package's global functions and pre deinstall commands */
+ if($pkg_config['custom_php_global_functions'] <> "")
+ eval_once($pkg_config['custom_php_global_functions']);
+ if($pkg_config['custom_php_pre_deinstall_command'] <> "")
+ eval_once($pkg_config['custom_php_pre_deinstall_command']);
}
- /* evalate this package's global functions and pre deinstall commands */
- if($pkg_config['custom_php_global_functions'] <> "")
- eval_once($pkg_config['custom_php_global_functions']);
- if($pkg_config['custom_php_pre_deinstall_command'] <> "")
- eval_once($pkg_config['custom_php_pre_deinstall_command']);
/* system files */
- if(is_array($pkg_config['modify_system']['item'])) {
+ if(is_array($pkg_config['modify_system']) && is_array($pkg_config['modify_system']['item'])) {
$static_output .= "\tSystem files... ";
update_output_window($static_output);
foreach($pkg_config['modify_system']['item'] as $ms)
@@ -936,26 +948,21 @@ function delete_package_xml($pkg) {
$static_output .= "done.\n";
update_output_window($static_output);
}
- /* syslog */
- if($pkg_config['logging']['logfile_name'] <> "") {
- $static_output .= "\tSyslog entries... ";
- update_output_window($static_output);
- remove_text_from_file("/etc/syslog.conf", $pkg_config['logging']['facilityname'] . "\t\t\t\t" . $pkg_config['logging']['logfilename']);
- $static_output .= "done.\n";
- update_output_window($static_output);
- }
/* deinstall commands */
if($pkg_config['custom_php_deinstall_command'] <> "") {
$static_output .= "\tDeinstall commands... ";
update_output_window($static_output);
- eval_once($pkg_config['custom_php_deinstall_command']);
- $static_output .= "done.\n";
+ if ($missing_include == false) {
+ eval_once($pkg_config['custom_php_deinstall_command']);
+ $static_output .= "done.\n";
+ } else
+ $static_output .= "\n\tNot executing custom deinstall hook because an include is missing.\n";
update_output_window($static_output);
}
if($pkg_config['include_file'] <> "") {
- $static_output = "\tRemoving package instructions...";
+ $static_output .= "\tRemoving package instructions...";
update_output_window($static_output);
- fwrite($fd_log, "Remove '{$pkg_config['include_file']}'\n");
+ pkg_debug("Remove '{$pkg_config['include_file']}'\n");
unlink_if_exists("/usr/local/pkg/" . $pkg_config['include_file']);
$static_output .= "done.\n";
update_output_window($static_output);
@@ -984,29 +991,24 @@ function delete_package_xml($pkg) {
$static_output .= "done.\n";
update_output_window($static_output);
}
- /* remove config.xml entries */
+ /* syslog */
+ if(is_array($pkg_info['logging']) && $pkg_info['logging']['logfile_name'] <> "") {
+ $static_output .= "\tSyslog entries... ";
+ update_output_window($static_output);
+ remove_text_from_file("/etc/syslog.conf", $pkg_info['logging']['facilityname'] . "\t\t\t\t" . $pkg_info['logging']['logfilename']);
+ system_syslogd_start();
+ @unlink("{$g['varlog_path']}/{$pkg_info['logging']['logfilename']}");
+ $static_output .= "done.\n";
+ update_output_window($static_output);
+ }
conf_mount_ro();
+ /* remove config.xml entries */
$static_output .= "\tConfiguration... ";
update_output_window($static_output);
unset($config['installedpackages']['package'][$pkgid]);
$static_output .= "done.\n";
update_output_window($static_output);
- write_config("Removed {$pkg} package.");
- /* file cleanup */
- $ctag = file("/etc/crontab");
- foreach($ctag as $line)
- if(trim($line) != "")
- $towrite[] = $line;
-
- $tmptab = fopen("{$g['tmp_path']}/crontab", "w");
- foreach($towrite as $line)
- fwrite($tmptab, $line);
- fclose($tmptab);
-
- // Go RW again since the write_config above will put it back to RO
- conf_mount_rw();
- rename("{$g['tmp_path']}/crontab", "/etc/crontab");
- conf_mount_ro();
+ write_config("Removed {$pkg} package.\n");
}
function expand_to_bytes($size) {
@@ -1058,7 +1060,8 @@ function get_package_install_size($pkg = 'all', $pkg_info = "") {
if(!$pkg_info)
$pkg_info = get_pkg_sizes($pkg);
foreach($pkg as $apkg) {
- if(!$pkg_info[$apkg]) continue;
+ if(!$pkg_info[$apkg])
+ continue;
$toreturn[$apkg] = expand_to_bytes(walk_depend(array($pkg_info[$apkg]), $pkgdb));
}
return $toreturn;
@@ -1078,4 +1081,4 @@ function squash_from_bytes($size, $round = "") {
return;
}
-?> \ No newline at end of file
+?>
diff --git a/etc/inc/services.inc b/etc/inc/services.inc
index f4f05e1..79668f5 100644
--- a/etc/inc/services.inc
+++ b/etc/inc/services.inc
@@ -144,7 +144,7 @@ function services_dhcpd_configure() {
fwrite($fd, "mkdir -p {$g['dhcpd_chroot_path']}/etc\n");
fwrite($fd, "mkdir -p {$g['dhcpd_chroot_path']}/usr/local/sbin\n");
fwrite($fd, "mkdir -p {$g['dhcpd_chroot_path']}/var/db\n");
- fwrite($fd, "mkdir -p {$g['dhcpd_chroot_path']}/var/run\n");
+ fwrite($fd, "mkdir -p {$g['dhcpd_chroot_path']}/var/run\n");
fwrite($fd, "mkdir -p {$g['dhcpd_chroot_path']}/usr\n");
fwrite($fd, "mkdir -p {$g['dhcpd_chroot_path']}/lib\n");
fwrite($fd, "mkdir -p {$g['dhcpd_chroot_path']}/run\n");
diff --git a/etc/inc/shaper.inc b/etc/inc/shaper.inc
index 02a1cd7..7c61546 100644
--- a/etc/inc/shaper.inc
+++ b/etc/inc/shaper.inc
@@ -4004,6 +4004,4 @@ $dn_default_shaper_msg .= "buttons at the bottom represent queue actions and are
$dn_default_shaper_msg .= " </p></strong></span>";
$dn_default_shaper_msg .= "</td></tr>";
-
-
?> \ No newline at end of file
diff --git a/etc/inc/system.inc b/etc/inc/system.inc
index 9776966..5219c32 100644
--- a/etc/inc/system.inc
+++ b/etc/inc/system.inc
@@ -33,7 +33,7 @@
pfSense_BUILDER_BINARIES: /usr/sbin/powerd /usr/bin/killall /sbin/sysctl /sbin/route
pfSense_BUILDER_BINARIES: /bin/hostname /bin/ls /usr/bin/netstat /usr/sbin/syslogd
pfSense_BUILDER_BINARIES: /usr/sbin/pccardd /usr/local/sbin/lighttpd /bin/chmod /bin/mkdir
- pfSense_BUILDER_BINARIES: /usr/bin/tar /bin/sync /usr/local/sbin/ntpd /usr/sbin/ntpdate
+ pfSense_BUILDER_BINARIES: /usr/bin/tar /usr/local/sbin/ntpd /usr/sbin/ntpdate
pfSense_BUILDER_BINARIES: /usr/bin/nohup /sbin/dmesg /usr/local/sbin/atareinit /sbin/kldload
pfSense_MODULE: utils
*/
@@ -52,10 +52,9 @@ function activate_powerd() {
function get_default_sysctl_value($id) {
global $sysctls;
- foreach($sysctls as $sysctl => $value) {
- if($sysctl == $id)
- return $value;
- }
+
+ if (isset($sysctls[$id]))
+ return $sysctls[$id];
}
function activate_sysctls() {
@@ -307,11 +306,6 @@ function system_routing_configure($interface = "") {
echo "system_routing_configure() being called $mt\n";
}
- /* Enable fast routing, if enabled */
- /* XXX: More checks need to be done for subsystems that are not compatibel with fast routing. */
- if(isset($config['staticroutes']['enablefastrouting']) && !isset($config['ipsec']['enable']))
- mwexec("/sbin/sysctl net.inet.ip.fastforwarding=1");
-
$gatewayip = "";
$interfacegw = "";
$foundgw = false;
@@ -511,11 +505,9 @@ function system_syslogd_start() {
if($config['installedpackages']['package']) {
foreach($config['installedpackages']['package'] as $package) {
if($package['logging']) {
- $pkgfacilities[] = $package['logging']['facilityname'];
- $separatelogfacilities = $separatelogfacilities + $pkgfacilities;
- $facilitylist = implode(',', $pkgfacilities);
+ array_push($separatelogfacilities, $package['logging']['facilityname']);
mwexec("{$log_create_directive} 10240 {$g['varlog_path']}/{$package['logging']['logfilename']}");
- $syslogconf .= "!{$facilitylist}\n*.*\t\t\t\t\t\t {$log_directive}{$g['varlog_path']}/{$package['logging']['logfilename']}\n";
+ $syslogconf .= "!{$package['logging']['facilityname']}\n*.*\t\t\t\t\t\t {$log_directive}{$g['varlog_path']}/{$package['logging']['logfilename']}\n";
}
}
}
@@ -580,7 +572,7 @@ news.err;local0.none;local3.none;local4.none; {$log_directive}{$g['varlog_path
local7.none {$log_directive}{$g['varlog_path']}/system.log
security.* {$log_directive}{$g['varlog_path']}/system.log
auth.info;authpriv.info;daemon.info {$log_directive}{$g['varlog_path']}/system.log
-auth.info;authpriv.info |exec /usr/local/sbin/sshlockout_pf
+auth.info;authpriv.info |exec /usr/local/sbin/sshlockout_pf 15
*.emerg *
EOD;
@@ -677,14 +669,19 @@ EOD;
}
fwrite($fd, $syslogconf);
fclose($fd);
+
+ // Ensure that the log directory exists
+ if(!is_dir("{$g['dhcpd_chroot_path']}/var/run"))
+ exec("/bin/mkdir -p {$g['dhcpd_chroot_path']}/var/run");
+
// Are we logging to a least one remote server ?
if(strpos($syslogconf, "@") != false)
- $retval = system("/usr/sbin/syslogd -c -f {$g['varetc_path']}/syslog.conf");
+ $retval = system("/usr/sbin/syslogd -c -c -l /var/dhcpd/var/run/log -f {$g['varetc_path']}/syslog.conf");
else
- $retval = system("/usr/sbin/syslogd -c -f {$g['varetc_path']}/syslog.conf");
+ $retval = system("/usr/sbin/syslogd -c -c -l /var/dhcpd/var/run/log -f {$g['varetc_path']}/syslog.conf");
} else {
- $retval = mwexec("/usr/sbin/syslogd -c");
+ $retval = mwexec("/usr/sbin/syslogd -c -c -l /var/dhcpd/var/run/log");
}
if ($g['booting'])
@@ -753,7 +750,7 @@ function system_webgui_start() {
if (!is_array($config['cert']))
$config['cert'] = array();
$a_cert =& $config['cert'];
- echo "Creating SSL Certificate... ";
+ log_error("Creating SSL Certificate for this host");
$cert = array();
$cert['refid'] = uniqid();
$cert['descr'] = "webConfigurator default";
@@ -1426,7 +1423,7 @@ function system_set_harddisk_standby() {
// Check for a numeric value
if (is_numeric($standby)) {
// Sync the disk(s)
- mwexec('/bin/sync');
+ pfSense_sync();
if (!mwexec('/sbin/sysctl hw.ata.standby=' . ((int)$standby))) {
// Reinitialize ATA-drives
mwexec('/usr/local/sbin/atareinit');
diff --git a/etc/inc/upgrade_config.inc b/etc/inc/upgrade_config.inc
index 7bf8f2e..9f7be86 100644
--- a/etc/inc/upgrade_config.inc
+++ b/etc/inc/upgrade_config.inc
@@ -704,18 +704,14 @@ function upgrade_040_to_041() {
$config['sysctl']['item'][18]['tunable'] = "net.inet.tcp.tso";
$config['sysctl']['item'][18]['descr'] = "TCP Offload engine";
$config['sysctl']['item'][18]['value'] = "default";
-
- $config['sysctl']['item'][19]['tunable'] = "hw.bce.tso_enable";
- $config['sysctl']['item'][19]['descr'] = "TCP Offload engine - BCE";
- $config['sysctl']['item'][19]['value'] = "default";
- $config['sysctl']['item'][20]['tunable'] = "net.inet.ip.portrange.first";
- $config['sysctl']['item'][20]['descr'] = "Set the ephemeral port range starting port";
- $config['sysctl']['item'][20]['value'] = "default";
+ $config['sysctl']['item'][19]['tunable'] = "net.inet.ip.portrange.first";
+ $config['sysctl']['item'][19]['descr'] = "Set the ephemeral port range starting port";
+ $config['sysctl']['item'][19]['value'] = "default";
- $config['sysctl']['item'][21]['tunable'] = "hw.syscons.kbd_reboot ";
- $config['sysctl']['item'][21]['descr'] = "Enables ctrl+alt+delete";
- $config['sysctl']['item'][21]['value'] = "default";
+ $config['sysctl']['item'][20]['tunable'] = "hw.syscons.kbd_reboot ";
+ $config['sysctl']['item'][20]['descr'] = "Enables ctrl+alt+delete";
+ $config['sysctl']['item'][20]['value'] = "default";
}
}
@@ -1082,7 +1078,7 @@ function upgrade_047_to_048() {
if (!empty($config['dyndns'])) {
$config['dyndnses'] = array();
$config['dyndnses']['dyndns'] = array();
- if(isset($config['dyndns'][0]['enable'])) {
+ if(isset($config['dyndns'][0]['host'])) {
$tempdyn = array();
$tempdyn['enable'] = isset($config['dyndns'][0]['enable']);
$tempdyn['type'] = $config['dyndns'][0]['type'];
@@ -1671,10 +1667,11 @@ function upgrade_053_to_054() {
$monitor = $split[1];
/* on static upgraded configuration we automatically prepend GW_ */
$static_name = "GW_" . strtoupper($interface);
- if(is_ipaddr($monitor)) {
- $interface = $static_name;
- $config['interfaces'][$interface]['monitorip'] = $monitor;
- }
+ if(is_ipaddr($monitor))
+ foreach ($a_gateways as & $gw)
+ if ($gw['name'] == $static_name)
+ $gw['monitor'] = $monitor;
+
/* on failover increment tier. Else always assign 1 */
if($lbpool['behaviour'] == "failover") {
$i++;
@@ -1738,6 +1735,8 @@ function upgrade_054_to_055() {
}
/* the roundtrip times need to be divided by 1000 to get seconds, really */
$databases = array();
+ if (!file_exists($rrddbpath))
+ @mkdir($rrddbpath);
chdir($rrddbpath);
$databases = glob("*-quality.rrd");
rsort($databases);
@@ -1885,11 +1884,20 @@ function upgrade_055_to_056() {
function upgrade_056_to_057() {
global $config;
+ if (!is_array($config['system']['user']))
+ $config['system']['user'] = array();
/* migrate captivate portal to user manager */
if (is_array($config['captiveportal']['user'])) {
foreach($config['captiveportal']['user'] as $user) {
// avoid user conflicts
- if ($config['system']['user'][$user['name']])
+ $found = false;
+ foreach ($config['system']['user'] as $userent) {
+ if ($userent['name'] == $user['name']) {
+ $found = true;
+ break;
+ }
+ }
+ if ($found)
continue;
$user['scope'] = "user";
if (isset($user['expirationdate'])) {
@@ -1900,6 +1908,7 @@ function upgrade_056_to_057() {
$user['md5-hash'] = $user['password'];
unset($user['password']);
}
+ $user['uid'] = $config['system']['nextuid']++;
$config['system']['user'][] = $user;
}
unset($config['captiveportal']['user']);
@@ -2228,10 +2237,10 @@ function upgrade_070_to_071() {
function rename_field(& $section, $oldname, $newname) {
if (is_array($section)) {
foreach($section as & $item) {
- if (!empty($item[$oldname])) {
+ if (!empty($item[$oldname]))
$item[$newname] = $item[$oldname];
+ if (isset($item[$oldname]))
unset($item[$oldname]);
- }
}
}
}
@@ -2273,4 +2282,4 @@ function upgrade_074_to_075() {
rename_field($config['crl'], 'name', 'descr');
}
-?> \ No newline at end of file
+?>
diff --git a/etc/inc/util.inc b/etc/inc/util.inc
index 718a22b..494f81b 100644
--- a/etc/inc/util.inc
+++ b/etc/inc/util.inc
@@ -38,7 +38,7 @@
/* kill a process by pid file */
function killbypid($pidfile) {
- sigkillbypid($pidfile, "TERM");
+ return sigkillbypid($pidfile, "TERM");
}
function isvalidpid($pid) {
@@ -716,10 +716,16 @@ function get_configured_ip_addresses() {
require_once("interfaces.inc");
$ip_array = array();
$interfaces = get_configured_interface_list();
- foreach($interfaces as $int) {
- $ipaddr = get_interface_ip($int);
- $ip_array[$int] = $ipaddr;
+ if(is_array($interfaces)) {
+ foreach($interfaces as $int) {
+ $ipaddr = get_interface_ip($int);
+ $ip_array[$int] = $ipaddr;
+ }
}
+ $interfaces = get_configured_carp_interface_list();
+ if(is_array($interfaces))
+ foreach($interfaces as $int => $ipaddr)
+ $ip_array[$int] = $ipaddr;
return $ip_array;
}
@@ -851,6 +857,23 @@ function log_error($error) {
return;
}
+/****f* util/log_auth
+* NAME
+* log_error - Sends a string to syslog as LOG_AUTH facility
+* INPUTS
+* $error - string containing the syslog message.
+* RESULT
+* null
+******/
+function log_auth($error) {
+ global $g;
+ $page = $_SERVER['SCRIPT_NAME'];
+ syslog(LOG_AUTH, "$page: $error");
+ if ($g['debug'])
+ syslog(LOG_WARNING, var_dump(debug_backtrace()));
+ return;
+}
+
/****f* util/exec_command
* NAME
* exec_command - Execute a command and return a string of the result.
@@ -869,17 +892,16 @@ function exec_command($command) {
/* wrapper for exec() */
function mwexec($command, $mute = false) {
-
global $g;
- $oarr = array();
- $retval = 0;
+
if ($g['debug']) {
if (!$_SERVER['REMOTE_ADDR'])
echo "mwexec(): $command\n";
- exec("$command 2>&1", $oarr, $retval);
- } else {
- exec("$command 2>&1", $oarr, $retval);
}
+ $oarr = array();
+ $retval = 0;
+ $garbage = exec("$command 2>&1", $oarr, $retval);
+
if(isset($config['system']['developerspew']))
$mute = false;
if(($retval <> 0) && ($mute === false)) {
diff --git a/etc/inc/voucher.inc b/etc/inc/voucher.inc
index 3b8e1ac..5c1d132 100644
--- a/etc/inc/voucher.inc
+++ b/etc/inc/voucher.inc
@@ -63,14 +63,12 @@ EOF;
$cli = new XML_RPC_Client('/xmlrpc.php', $url, $port);
$cli->setCredentials($username, $password);
$resp = $cli->send($msg, "250");
- if(!$resp) {
+ if(!is_object($resp)) {
$error = "A communications error occurred while attempting CaptivePortalVoucherSync XMLRPC sync with {$url}:{$port} (pfsense.exec_php).";
log_error($error);
file_notice("CaptivePortalVoucherSync", $error, "Communications error occurred", "");
return array("timeleft" => "0");
} elseif($resp->faultCode()) {
- $cli->setDebug(1);
- $resp = $cli->send($msg, "250");
$error = "An error code was received while attempting CaptivePortalVoucherSync XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString();
log_error($error);
file_notice("CaptivePortalVoucherSync", $error, "Error code received", "");
@@ -84,25 +82,24 @@ EOF;
write_config("Captive Portal Voucher database synchronized with {$url}");
voucher_configure();
}
- return $toreturn['timeleft'];
+
+ return $toreturn['timeleft'];
}
/*
- *Authenticate a voucher and return the remaining time credit in minutes
+ * Authenticate a voucher and return the remaining time credit in minutes
* if $test is set, don't mark the voucher as used nor add it to the list
* of active vouchers
+ * If $test is set, simply test the voucher. Don't change anything
+ * but return a more verbose error and result message back
*/
function voucher_auth($voucher_received, $test = 0) {
-
global $g, $config;
- // if $test is set, simply test the voucher. Don't change anything
- // but return a more verbose error and result message back
-
$voucherlck = lock('voucher');
// XMLRPC Call over to the master Voucher node
- $a_voucher = &$config['voucher'];
+ $a_voucher = &$config['voucher'];
if($a_voucher['vouchersyncdbip']) {
$syncip = $a_voucher['vouchersyncdbip'];
$syncport = $a_voucher['vouchersyncport'];
@@ -111,12 +108,16 @@ function voucher_auth($voucher_received, $test = 0) {
$remote_time_used = xmlrpc_sync_used_voucher($voucher_received, $syncip, $syncport, $syncpass, $vouchersyncusername);
}
- // read rolls into assoc array with rollid as key and minutes as value
- $a_roll = &$config['voucher']['roll'];
- foreach ($a_roll as $rollent) {
- $tickets_per_roll[$rollent['number']] = $rollent['count'];
- $minutes_per_roll[$rollent['number']] = $rollent['minutes'];
- }
+ // read rolls into assoc array with rollid as key and minutes as value
+ $tickets_per_roll = array();
+ $minutes_per_roll = array();
+ if (is_array($config['voucher']['roll'])) {
+ $a_roll = &$config['voucher']['roll'];
+ foreach ($a_roll as $rollent) {
+ $tickets_per_roll[$rollent['number']] = $rollent['count'];
+ $minutes_per_roll[$rollent['number']] = $rollent['minutes'];
+ }
+ }
// split into an array. Useful for multiple vouchers given
$a_vouchers_received = split("[\t\n\r ]+",$voucher_received);
@@ -138,9 +139,9 @@ function voucher_auth($voucher_received, $test = 0) {
$result = exec("/usr/local/bin/voucher -c {$g['varetc_path']}/voucher.cfg -k {$g['varetc_path']}/voucher.public -- $v");
list($status, $roll, $nr) = explode(" ", $result);
if ($status == "OK") {
- if (!$first_voucher)
- {
- $first_voucher = $voucher; // store first voucher. Thats the one we give the timecredit
+ if (!$first_voucher) {
+ // store first voucher. Thats the one we give the timecredit
+ $first_voucher = $voucher;
$first_voucher_roll = $roll;
}
// check if we have this ticket on a registered roll for this ticket
@@ -191,7 +192,7 @@ function voucher_auth($voucher_received, $test = 0) {
} else {
$test_result[] = "Access granted for $total_minutes Minutes in total.";
}
- unlock($voucherlck);
+ unlock($voucherlck);
return $test_result;
}
@@ -200,7 +201,7 @@ function voucher_auth($voucher_received, $test = 0) {
// the user wouldn't know that he used at least one invalid voucher.
if ($error) {
- unlock($voucherlck);
+ unlock($voucherlck);
if ($total_minutes > 0) // probably not needed, but want to make sure
$total_minutes = 0; // we only report -1 (expired) or 0 (no access)
return $total_minutes; // well, at least one voucher had errors. Say NO ACCESS
@@ -240,9 +241,6 @@ function voucher_auth($voucher_received, $test = 0) {
$active_vouchers[$first_voucher_roll][$first_voucher] = "$timestamp,$minutes";
voucher_write_active_db($roll, $active_vouchers[$first_voucher_roll]);
- // mark the DB's as dirty.
- mark_subsystem_dirty('voucher');
-
unlock($voucherlck);
return $total_minutes;
@@ -250,15 +248,15 @@ function voucher_auth($voucher_received, $test = 0) {
function voucher_configure() {
global $config, $g;
-
- /* kill any running minicron */
- killbypid("{$g['varrun_path']}/vouchercron.pid");
- if (isset($config['voucher']['enable'])) {
+ /* kill any running minicron */
+ killbypid("{$g['varrun_path']}/vouchercron.pid");
+
+ if (!isset($config['voucher']['enable']))
+ return 0;
- if ($g['booting']) {
+ if ($g['booting'])
echo "Enabling voucher support... ";
- }
// start cron if we're asked to save runtime DB periodically
// to XML config if it changed
@@ -269,18 +267,19 @@ function voucher_configure() {
"/etc/rc.savevoucher");
}
- $voucherlck = lock('voucher');
+ $voucherlck = lock('voucher', LOCK_EX);
+
/* write public key used to verify vouchers */
$pubkey = base64_decode($config['voucher']['publickey']);
$fd = fopen("{$g['varetc_path']}/voucher.public", "w");
if (!$fd) {
- printf("Error: cannot write voucher.public\n");
+ log_error("Voucher error: cannot write voucher.public\n");
unlock($voucherlck);
return 1;
}
- chmod("{$g['varetc_path']}/voucher.public", 0600);
fwrite($fd, $pubkey);
fclose($fd);
+ @chmod("{$g['varetc_path']}/voucher.public", 0600);
/* write config file used by voucher binary to decode vouchers */
$fd = fopen("{$g['varetc_path']}/voucher.cfg", "w");
@@ -289,12 +288,12 @@ function voucher_configure() {
unlock($voucherlck);
return 1;
}
- chmod("{$g['varetc_path']}/voucher.cfg", 0600);
fwrite($fd, "{$config['voucher']['rollbits']},{$config['voucher']['ticketbits']},{$config['voucher']['checksumbits']},{$config['voucher']['magic']},{$config['voucher']['charset']}\n");
fclose($fd);
+ @chmod("{$g['varetc_path']}/voucher.cfg", 0600);
unlock($voucherlck);
- if ($g['booting']) {
+ if ($g['booting'] && is_array($config['voucher']['roll'])) {
// create active and used DB per roll on ramdisk from config
$a_roll = &$config['voucher']['roll'];
@@ -323,61 +322,56 @@ function voucher_configure() {
unlock($voucherlck);
echo "done\n";
}
- }
- return 0;
+
+ return 0;
}
/* write bitstring of used vouchers to ramdisk.
* Bitstring must already be base64_encoded!
*/
function voucher_write_used_db($roll, $vdb) {
-
- global $g;
-
- $fd = fopen("{$g['vardb_path']}/voucher_used_$roll.db", "w");
- if ($fd) {
- fwrite($fd, $vdb . "\n");
- fclose($fd);
- } else {
- voucher_log(LOG_ERR, "cant write {$g['vardb_path']}/voucher_used_$roll.db");
- }
+ global $g;
+
+ $fd = fopen("{$g['vardb_path']}/voucher_used_$roll.db", "w");
+ if ($fd) {
+ fwrite($fd, $vdb . "\n");
+ fclose($fd);
+ } else
+ voucher_log(LOG_ERR, "cant write {$g['vardb_path']}/voucher_used_$roll.db");
}
/* return assoc array of active vouchers with activation timestamp
* voucher is index.
*/
function voucher_read_active_db($roll) {
-
- global $g;
-
- $active = array();
- $dirty = 0;
- $file = "{$g['vardb_path']}/voucher_active_$roll.db";
- if (file_exists($file)) {
- $fd = fopen($file, "r");
- if ($fd) {
- while (!feof($fd)) {
- $line = trim(fgets($fd));
- if ($line) {
- list($voucher,$timestamp,$minutes) = explode(",", $line); // voucher,timestamp
- if ((($timestamp + 60*$minutes) - time()) > 0) {
- $active[$voucher] = "$timestamp,$minutes";
- } else {
- $dirty=1;
- }
- }
- }
- fclose($fd);
- if ($dirty) // if we found expired entries, lets save our snapshot
- voucher_write_active_db($roll, $active);
- }
- }
- return $active;
+ global $g;
+
+ $active = array();
+ $dirty = 0;
+ $file = "{$g['vardb_path']}/voucher_active_$roll.db";
+ if (file_exists($file)) {
+ $fd = fopen($file, "r");
+ if ($fd) {
+ while (!feof($fd)) {
+ $line = trim(fgets($fd));
+ if ($line) {
+ list($voucher,$timestamp,$minutes) = explode(",", $line); // voucher,timestamp
+ if ((($timestamp + 60*$minutes) - time()) > 0)
+ $active[$voucher] = "$timestamp,$minutes";
+ else
+ $dirty=1;
+ }
+ }
+ fclose($fd);
+ if ($dirty) // if we found expired entries, lets save our snapshot
+ voucher_write_active_db($roll, $active);
+ }
+ }
+ return $active;
}
/* store array of active vouchers back to DB */
function voucher_write_active_db($roll, $active) {
-
global $g;
$fd = fopen("{$g['vardb_path']}/voucher_active_$roll.db", "w");
@@ -390,7 +384,6 @@ function voucher_write_active_db($roll, $active) {
/* return how many vouchers are marked used on a roll */
function voucher_used_count($roll) {
-
global $g;
$bitstring = voucher_read_used_db($roll);
@@ -407,7 +400,6 @@ function voucher_used_count($roll) {
}
function voucher_read_used_db($roll) {
-
global $g;
$vdb = "";
@@ -425,10 +417,9 @@ function voucher_read_used_db($roll) {
}
function voucher_unlink_db($roll) {
-
global $g;
- unlink("{$g['vardb_path']}/voucher_used_$roll.db");
- unlink("{$g['vardb_path']}/voucher_active_$roll.db");
+ @unlink("{$g['vardb_path']}/voucher_used_$roll.db");
+ @unlink("{$g['vardb_path']}/voucher_active_$roll.db");
}
/* we share the log with captiveportal for now */
@@ -445,20 +436,15 @@ function voucher_log($priority, $message) {
* Called during reboot -> system_reboot_cleanup() and minicron
*/
function voucher_save_db_to_config() {
-
global $config, $g;
if (!isset($config['voucher']['enable']) || $config['voucher']['saveinterval'] == 0)
return; // no vouchers or don't want to save DB's
- if (!is_subsystem_dirty('voucher'))
- return; // nothing changed.
-
- $voucherlck = lock('voucher');
+ $voucherlck = lock('voucher', LOCK_EX);
// walk all active rolls and save runtime DB's to flash
$a_roll = &$config['voucher']['roll'];
-// foreach ($a_roll as $rollent) {
while (list($key, $value) = each($a_roll)) {
$rollent = &$a_roll[$key];
$roll = $rollent['number'];
@@ -477,10 +463,11 @@ function voucher_save_db_to_config() {
}
$rollent['active'] = $db;
}
- clear_subsystem_dirty('voucher');
+
unlock($voucherlck);
+
write_config();
return;
}
-?> \ No newline at end of file
+?>
diff --git a/etc/inc/vpn.inc b/etc/inc/vpn.inc
index 7c045d2..ef06f61 100644
--- a/etc/inc/vpn.inc
+++ b/etc/inc/vpn.inc
@@ -118,6 +118,7 @@ function vpn_ipsec_configure($ipchg = false)
return true;
} else {
mwexec("/sbin/ifconfig enc0 up");
+ mwexec("/sbin/sysctl net.inet.ip.ipsec_in_use=1");
if ($g['booting'])
echo "Configuring IPsec VPN... ";
@@ -635,15 +636,18 @@ EOD;
$localid_type = $ph2ent['localid']['type'];
$localid_data = ipsec_idinfo_to_cidr($ph2ent['localid']);
- /* Do not print localid in some cases, such as a pure-psk mobile tunnel */
- if (($localid_type == "none") || ($ph1ent['authentication_method'] == "pre_shared_key") && isset($ph1ent['mobile']))
+ /* Do not print localid in some cases, such as a pure-psk or psk/xauth mobile tunnel */
+ if (($localid_type == "none") ||
+ (($ph1ent['authentication_method'] == "xauth_psk_server") ||
+ ($ph1ent['authentication_method'] == "pre_shared_key"))
+ && isset($ph1ent['mobile']))
$localid_spec = " ";
else {
- if ($localid_type != "address") {
- $localid_type = "subnet";
- }
- $localid_spec = $localid_type." ".$localid_data." any";
- }
+ if ($localid_type != "address") {
+ $localid_type = "subnet";
+ }
+ $localid_spec = $localid_type." ".$localid_data." any";
+ }
if (!isset($ph2ent['mobile'])) {
$remoteid_type = $ph2ent['remoteid']['type'];
@@ -656,16 +660,23 @@ EOD;
$remoteid_spec = "anonymous";
} else {
-
$rgip = $rgmap[$ph1ent['remote-gateway']];
- $localid_data = ipsec_get_phase1_src($ph1ent);
- if($ph2ent['mode'] == 'transport') { $localid_data="$localid_data any"; }
- $localid_spec = "address {$localid_data}";
-
- $remoteid_data = $rgmap[$ph1ent['remote-gateway']];
- if($ph2ent['mode'] == 'transport') { $remoteid_data="$remoteid_data any"; }
- $remoteid_spec = "address {$remoteid_data}";
+ if ((($ph1ent['authentication_method'] == "xauth_psk_server") ||
+ ($ph1ent['authentication_method'] == "pre_shared_key"))
+ && isset($ph1ent['mobile']))
+ $localid_spec = " ";
+ else {
+ $localid_data = ipsec_get_phase1_src($ph1ent);
+ if($ph2ent['mode'] == 'transport') { $localid_data="$localid_data any"; }
+ $localid_spec = "address {$localid_data}";
+ }
+ if (!isset($ph2ent['mobile'])) {
+ $remoteid_data = $rgmap[$ph1ent['remote-gateway']];
+ if($ph2ent['mode'] == 'transport') { $remoteid_data="$remoteid_data any"; }
+ $remoteid_spec = "address {$remoteid_data}";
+ } else
+ $remoteid_spec = "anonymous";
}
if($ph2ent['protocol'] == 'esp') {
@@ -877,7 +888,6 @@ EOD;
sleep("0.1");
mwexec("/usr/local/sbin/setkey -F", false);
sleep("0.1");
- exec("/sbin/sysctl net.inet.ip.ipsec_in_use=1");
/* start racoon */
mwexec("/usr/local/sbin/racoon -f {$g['varetc_path']}/racoon.conf", false);
sleep("0.1");
@@ -953,6 +963,15 @@ function vpn_setup() {
vpn_l2tp_configure();
}
+function vpn_netgraph_support() {
+ $iflist = get_configured_interface_list();
+ foreach ($iflist as $iface) {
+ $realif = get_real_interface($iface);
+ /* Get support for netgraph(4) from the nic */
+ pfSense_ngctl_attach(".", $realif);
+ }
+}
+
function vpn_pptpd_configure() {
global $config, $g;
@@ -1143,6 +1162,8 @@ EOD;
fclose($fd);
chmod("{$g['varetc_path']}/pptp-vpn/mpd.secret", 0600);
+ vpn_netgraph_support();
+
/* fire up mpd */
mwexec("/usr/local/sbin/mpd4 -b -d {$g['varetc_path']}/pptp-vpn -p {$g['varrun_path']}/pptp-vpn.pid -s pptps pptps");
@@ -1346,6 +1367,8 @@ EOD;
chmod("{$g['varetc_path']}/pppoe{$pppoecfg['pppoeid']}-vpn/mpd.secret", 0600);
}
+ /* Get support for netgraph(4) from the nic */
+ pfSense_ngctl_attach(".", $pppoe_interface);
/* fire up mpd */
mwexec("/usr/local/sbin/mpd4 -b -d {$g['varetc_path']}/pppoe{$pppoecfg['pppoeid']}-vpn -p {$g['varrun_path']}/pppoe{$pppoecfg['pppoeid']}-vpn.pid -s poes poes");
@@ -1527,6 +1550,8 @@ EOD;
fclose($fd);
chmod("{$g['varetc_path']}/l2tp-vpn/mpd.secret", 0600);
+ vpn_netgraph_support();
+
/* fire up mpd */
mwexec("/usr/local/sbin/mpd4 -b -d {$g['varetc_path']}/l2tp-vpn -p {$g['varrun_path']}/l2tp-vpn.pid -s l2tps l2tps");
@@ -1721,4 +1746,4 @@ function vpn_ipsec_configure_preferoldsa() {
mwexec("/sbin/sysctl net.key.preferred_oldsa=0");
}
-?> \ No newline at end of file
+?>
diff --git a/etc/inc/vslb.inc b/etc/inc/vslb.inc
index 73d434e..5eb784a 100644
--- a/etc/inc/vslb.inc
+++ b/etc/inc/vslb.inc
@@ -206,7 +206,12 @@ function relayd_configure() {
if(is_array($pool_a)) {
for ($i = 0; isset($pool_a[$i]); $i++) {
if(is_array($pool_a[$i]['servers'])) {
- $srvtxt = implode(", ", $pool_a[$i]['servers']);
+ if (!empty($pool_a[$i]['retry'])) {
+ $retrytext = " retry {$pool_a[$i]['retry']}";
+ $srvtxt = implode("{$retrytext}, ", $pool_a[$i]['servers']) . "{$retrytext}";
+ } else {
+ $srvtxt = implode(", ", $pool_a[$i]['servers']);
+ }
$conf .= "table <{$pool_a[$i]['name']}> { $srvtxt }\n";
/* Index by name for easier fetching when we loop through the virtual servers */
$pools[$pool_a[$i]['name']] = $pool_a[$i];
@@ -283,4 +288,73 @@ function relayd_configure() {
}
+<<<<<<< HEAD
+?>
+=======
+function get_lb_redirects() {
+/*
+# relayctl show summary
+Id Type Name Avlblty Status
+1 redirect testvs2 active
+5 table test2:80 active (3 hosts up)
+11 host 192.168.1.2 91.55% up
+10 host 192.168.1.3 100.00% up
+9 host 192.168.1.4 88.73% up
+3 table test:80 active (1 hosts up)
+7 host 192.168.1.2 66.20% down
+6 host 192.168.1.3 97.18% up
+0 redirect testvs active
+3 table test:80 active (1 hosts up)
+7 host 192.168.1.2 66.20% down
+6 host 192.168.1.3 97.18% up
+4 table testvs-sitedown:80 active (1 hosts up)
+8 host 192.168.1.4 84.51% up
+# relayctl show redirects
+Id Type Name Avlblty Status
+1 redirect testvs2 active
+0 redirect testvs active
+# relayctl show redirects
+Id Type Name Avlblty Status
+1 redirect testvs2 active
+ total: 2 sessions
+ last: 2/60s 2/h 2/d sessions
+ average: 1/60s 0/h 0/d sessions
+0 redirect testvs active
+*/
+ $rdr_a = array();
+ exec('/usr/local/sbin/relayctl show redirects 2>&1', $rdr_a);
+ $vs = array();
+ for ($i = 0; isset($rdr_a[$i]); $i++) {
+ $line = $rdr_a[$i];
+ if (preg_match("/^[0-9]+/", $line)) {
+ $regs = array();
+ if($x = preg_match("/^[0-9]+\s+redirect\s+([^\s]+)\s+([^\s]+)/", $line, $regs)) {
+ $vs[trim($regs[1])] = array();
+ $vs[trim($regs[1])]['status'] = trim($regs[2]);
+ }
+ }
+ }
+ return $vs;
+}
+
+function get_lb_summary() {
+ $relayctl = array();
+ exec('/usr/local/sbin/relayctl show summary 2>&1', $relayctl);
+ $relay_hosts=Array();
+ foreach( (array) $relayctl as $line) {
+ $t=split("\t", $line);
+ switch (trim($t[1])) {
+ case "table":
+ $curpool=trim($t[2]);
+ break;
+ case "host":
+ $curhost=trim($t[2]);
+ $relay_hosts[$curpool][$curhost]['avail']=trim($t[3]);
+ $relay_hosts[$curpool][$curhost]['state']=trim($t[4]);
+ break;
+ }
+ }
+ return $relay_hosts;
+}
+
?>
diff --git a/etc/inc/xmlparse.inc b/etc/inc/xmlparse.inc
index 582f9b4..75871a9 100644
--- a/etc/inc/xmlparse.inc
+++ b/etc/inc/xmlparse.inc
@@ -179,20 +179,27 @@ function parse_xml_config_raw($cffile, $rootobj, $isstring = "false") {
while ($data = fread($fp, 4096)) {
if (!xml_parse($xml_parser, $data, feof($fp))) {
- log_error(sprintf("XML error: %s at line %d\n",
+ log_error(sprintf("XML error: %s at line %d in %s\n",
xml_error_string(xml_get_error_code($xml_parser)),
- xml_get_current_line_number($xml_parser)));
+ xml_get_current_line_number($xml_parser),
+ $cffile));
return -1;
}
}
xml_parser_free($xml_parser);
- if (!$parsedcfg[$rootobj]) {
- log_error("XML error: no $rootobj object found!\n");
+ if (!is_array($rootobj))
+ $rootobj = array($rootobj);
+ foreach ($rootobj as $rootobj_name)
+ if ($parsedcfg[$rootobj_name])
+ break;
+
+ if (!$parsedcfg[$rootobj_name]) {
+ log_error("XML error: no $rootobj_name object found!\n");
return -1;
}
- return $parsedcfg[$rootobj];
+ return $parsedcfg[$rootobj_name];
}
function dump_xml_config_sub($arr, $indent) {
diff --git a/etc/inc/xmlreader.inc b/etc/inc/xmlreader.inc
index a228cd0..0beeb74 100644
--- a/etc/inc/xmlreader.inc
+++ b/etc/inc/xmlreader.inc
@@ -128,7 +128,13 @@ function parse_xml_config_raw($cffile, $rootobj, $isstring = "false") {
} else
log_error("Error returned while trying to parse {$cffile}");
- return $parsedcfg[$rootobj];
+ if (!is_array($rootobj))
+ $rootobj = array($rootobj);
+ foreach ($rootobj as $rootobj_name)
+ if ($parsedcfg[$rootobj_name])
+ break;
+
+ return $parsedcfg[$rootobj_name];
}
function dump_xml_config_sub(& $writer, $arr) {
diff --git a/etc/inc/xmlrpc.inc b/etc/inc/xmlrpc.inc
index 61167bf..ef4fc19 100644
--- a/etc/inc/xmlrpc.inc
+++ b/etc/inc/xmlrpc.inc
@@ -107,17 +107,36 @@ function php_value_to_xmlrpc($value, $force_array = false) {
* the array before returning it.
*/
function xmlrpc_auth(&$params) {
- global $config;
+ global $config, $_SERVER;
+
+ if (!is_array($config['system']['user'])) {
+ array_shift($params);
+ unset($params['xmlrpcauth']);
+ log_error("webConfigurator authentication error for 'admin' from {$_SERVER['REMOTE_ADDR']} during sync settings.");
+ return false;
+ }
+ if (!isset($config['system']['user'][0]['password'])) {
+ array_shift($params);
+ unset($params['xmlrpcauth']);
+ log_error("webConfigurator authentication error for 'admin' from {$_SERVER['REMOTE_ADDR']} during sync settings.");
+ return false;
+ }
+
$localpass = $config['system']['user'][0]['password'];
if(crypt($params[0], $localpass) == $localpass) {
array_shift($params);
+ unset($params['xmlrpcauth']);
return true;
- } else if(crypt($params['xmlrpcauth'], $localpass) != $localpass) {
+ } else if(crypt($params['xmlrpcauth'], $localpass) == $localpass) {
+ array_shift($params);
unset($params['xmlrpcauth']);
- return false;
+ return true;
}
+
+ array_shift($params);
unset($params['xmlrpcauth']);
+ log_error("webConfigurator authentication error for 'admin' from {$_SERVER['REMOTE_ADDR']} during sync settings.");
return false;
}
-?> \ No newline at end of file
+?>
diff --git a/etc/inc/xmlrpc_client.inc b/etc/inc/xmlrpc_client.inc
index 462917b..39d6d70 100644
--- a/etc/inc/xmlrpc_client.inc
+++ b/etc/inc/xmlrpc_client.inc
@@ -190,7 +190,7 @@ $GLOBALS['XML_RPC_backslash'] = chr(92) . chr(92);
* which can cause PHP's SAX-based XML parser to break?
* @global boolean $GLOBALS['XML_RPC_auto_base64']
*/
-$GLOBALS['XML_RPC_auto_base64'] = false;
+$GLOBALS['XML_RPC_auto_base64'] = true;
/**
diff --git a/etc/phpshellsessions/externalconfiglocator b/etc/phpshellsessions/externalconfiglocator
new file mode 100644
index 0000000..84534b3
--- /dev/null
+++ b/etc/phpshellsessions/externalconfiglocator
@@ -0,0 +1,3 @@
+
+include("/etc/ecl.php");
+
diff --git a/etc/rc b/etc/rc
index ab1b460..15f058a 100755
--- a/etc/rc
+++ b/etc/rc
@@ -115,6 +115,7 @@ else
fi
if [ "$PLATFORM" = "cdrom" ] ; then
+ echo -n "Mounting unionfs directories..."
/bin/mkdir /tmp/unionfs
/bin/mkdir /tmp/unionfs/usr
/bin/mkdir /tmp/unionfs/root
@@ -122,21 +123,13 @@ if [ "$PLATFORM" = "cdrom" ] ; then
/bin/mkdir /tmp/unionfs/bin
/bin/mkdir /tmp/unionfs/boot
/bin/mkdir /tmp/unionfs/confdefault
- echo -n "Mounting unionfs directories:"
- echo -n " usr"
/sbin/mount_unionfs /tmp/unionfs/usr /usr/
- echo -n " root"
/sbin/mount_unionfs /tmp/unionfs/root /root/
- echo -n " bin"
/sbin/mount_unionfs /tmp/unionfs/bin /bin/
- echo -n " sbin"
/sbin/mount_unionfs /tmp/unionfs/sbin /sbin/
- echo -n " boot"
/sbin/mount_unionfs /tmp/unionfs/boot /boot/
- echo -n " conf.default"
/sbin/mount_unionfs /tmp/unionfs/confdefault /conf.default/
- echo -n " installer"
- echo "... done."
+ echo "done."
fi
echo -n "Creating symlinks..."
@@ -332,16 +325,31 @@ echo "done."
if [ `/bin/ls -la /etc/gettytab | /usr/bin/awk '{ print $5'}` -lt 512 ]; then
echo ">>> Restoring /etc/gettytab due to unusal size"
echo ">>> Restoring /etc/gettytab due to unusal size" | /usr/bin/logger
- cp /etc/gettytab.bak /etc/gettytab
+ /bin/cp /etc/gettytab.bak /etc/gettytab
fi
# Recreate capabilities DB
-cap_mkdb /etc/login.conf
+/usr/bin/cap_mkdb /etc/login.conf
# Run the php.ini setup file and populate
# /usr/local/etc/php.ini and /usr/local/lib/php.ini
/etc/rc.php_ini_setup
+# Launch external configuration loader for supported platforms
+if [ "$PLATFORM" = "embedded" ]; then
+ /usr/local/bin/php -q /etc/ecl.php
+fi
+
+# Launch external configuration loader for supported platforms
+if [ "$PLATFORM" = "nanobsd" ]; then
+ /usr/local/bin/php -q /etc/ecl.php
+fi
+
+# Launch external configuration loader for supported platforms
+if [ "$PLATFORM" = "pfSense" ]; then
+ /usr/local/bin/php -q /etc/ecl.php
+fi
+
nohup /usr/bin/nice -n20 /usr/local/sbin/check_reload_status
# let the PHP-based configuration subsystem set up the system now
@@ -379,12 +387,12 @@ echo "done."
/bin/chmod a+rw /tmp/.
echo "Bootup complete"
-rm $varrunpath/booting
+/bin/rm $varrunpath/booting
/usr/local/bin/beep.sh start 2>&1 >/dev/null
# Reset the cache. read-only requires this.
-rm /tmp/config.cache
+/bin/rm /tmp/config.cache
/etc/rc.conf_mount_ro
diff --git a/etc/rc.banner b/etc/rc.banner
index 9b32334..6f81cb9 100755
--- a/etc/rc.banner
+++ b/etc/rc.banner
@@ -45,7 +45,7 @@
if(!$hideplatform)
$platformbanner = "-{$platform}";
- print "\n*** Welcome to {$product} {$version}{$platformbanner} ({$machine}) on {$hostname} ***\n";
+ print "*** Welcome to {$product} {$version}{$platformbanner} ({$machine}) on {$hostname} ***\n";
$iflist = get_configured_interface_with_descr(false, true);
foreach($iflist as $ifname => $friendly) {
diff --git a/etc/rc.bootup b/etc/rc.bootup
index 2d39df6..fe1faa3 100755
--- a/etc/rc.bootup
+++ b/etc/rc.bootup
@@ -249,9 +249,6 @@ echo "Starting PFLOG...";
filter_pflog_start();
echo "done.\n";
-/* start load balancer daemon */
-relayd_configure();
-
/* reconfigure our gateway monitor */
echo "Setting up gateway monitors...";
setup_gateways_monitor();
@@ -282,6 +279,9 @@ system_routing_configure();
/* enable routing */
system_routing_enable();
+/* start load balancer daemon */
+relayd_configure();
+
/* configure console menu */
system_console_configure();
@@ -293,10 +293,6 @@ echo "done.\n";
/* Launch on bootup and keep trying to sync. Exit once time/date has been sync'd. */
mwexec_bg("/usr/local/sbin/ntpdate_sync_once.sh");
-/* static IP address? -> attempt DNS update */
-if (is_ipaddr($config['interfaces']['wan']['ipaddr']))
- services_dnsupdate_process();
-
/* start DHCP service */
services_dhcpd_configure();
@@ -306,12 +302,15 @@ services_dnsmasq_configure();
/* start dhcpleases dhpcp hosts leases program */
system_dhcpleases_configure();
-/* start dyndns service */
-send_event("service reload dyndnsall");
-
/* start DHCP relay */
services_dhcrelay_configure();
+/* dyndns service updates */
+send_event("service reload dyndnsall");
+
+/* Run a filter configure now that most all services have started */
+filter_configure_sync();
+
/* setup pppoe and pptp */
vpn_setup();
@@ -336,9 +335,6 @@ system_set_harddisk_standby();
/* lock down console if necessary */
auto_login();
-/* Run a filter configure now that most all services have started */
-filter_configure_sync();
-
/* load graphing functions */
enable_rrd_graphing();
@@ -361,16 +357,16 @@ if($config['system']['afterbootupshellcmd'] <> "") {
if($avail < $g['minimum_ram_warning']) {
require_once("/etc/inc/notices.inc");
file_notice("{$g['product_name']}MemoryRequirements", "{$g['product_name']} requires at least {$g['minimum_ram_warning_text']} of RAM. Expect unusual performance. This platform is not supported.", "Memory", "", 1);
- mwexec("sysctl net.inet.tcp.recvspace=4096");
- mwexec("sysctl net.inet.tcp.sendspace=4096");
+ mwexec("/sbin/sysctl net.inet.tcp.recvspace=4096");
+ mwexec("/sbin/sysctl net.inet.tcp.sendspace=4096");
}
/* if we are operating at 1000 then increase timeouts.
this was never accounted for after moving to 1000 hz */
-$kern_hz = `sysctl kern.clockrate | awk '{ print $5 }' | cut -d"," -f1`;
+$kern_hz = `/sbin/sysctl kern.clockrate | /usr/bin/awk '{ print $5 }' | /usr/bin/cut -d"," -f1`;
$kern_hz = trim($kern_hz, "\r\n");
if($kern_hz == "1000")
- mwexec("sysctl net.inet.tcp.rexmit_min=30");
+ mwexec("/sbin/sysctl net.inet.tcp.rexmit_min=30");
/* start the igmpproxy daemon */
services_igmpproxy_configure();
@@ -383,7 +379,7 @@ activate_powerd();
/* Remove the old shutdown binary if we kept it. */
if (file_exists("/sbin/shutdown.old"))
- unlink("/sbin/shutdown.old");
+ @unlink("/sbin/shutdown.old");
/* done */
unset($g['booting']);
diff --git a/etc/rc.dyndns.update b/etc/rc.dyndns.update
index a84cadd..557113c 100755
--- a/etc/rc.dyndns.update
+++ b/etc/rc.dyndns.update
@@ -38,9 +38,12 @@ require_once("shaper.inc");
$argument = trim($argv[1], " \n");
-if(empty($argument))
+if(empty($argument)) {
services_dyndns_configure();
-else
+ services_dnsupdate_process();
+} else {
services_dyndns_configure($argument);
+ services_dnsupdate_process($argument);
+}
?>
diff --git a/etc/rc.filter_configure_xmlrpc b/etc/rc.filter_configure_xmlrpc
index 4a42df7..bd1f785 100755
--- a/etc/rc.filter_configure_xmlrpc
+++ b/etc/rc.filter_configure_xmlrpc
@@ -43,7 +43,6 @@ require_once("shaper.inc");
require_once("xmlrpc.inc");
require_once("interfaces.inc");
-filter_configure();
system_routing_configure();
setup_gateways_monitor();
relayd_configure();
@@ -51,4 +50,4 @@ require_once("openvpn.inc");
openvpn_resync_all();
services_dhcpd_configure();
-?> \ No newline at end of file
+?>
diff --git a/etc/rc.filter_synchronize b/etc/rc.filter_synchronize
index 15131b0..31843af 100755
--- a/etc/rc.filter_synchronize
+++ b/etc/rc.filter_synchronize
@@ -64,6 +64,13 @@ function backup_vip_config_section() {
$section_val = 255;
$section['advskew'] = $section_val;
}
+ if($section['advbase'] <> "") {
+ $section_val = intval($section['advbase']);
+ $section_val=$section_val+1;
+ if($section_val > 255)
+ $section_val = 255;
+ $section['advbase'] = $section_val;
+ }
$temp['vip'][] = $section;
}
return $temp;
@@ -81,10 +88,59 @@ function remove_special_characters($string) {
return $string;
}
+function carp_check_version($url, $password, $port = 80, $method = 'pfsense.host_firmware_version') {
+ global $config, $g;
+
+ if(file_exists("{$g['varrun_path']}/booting") || $g['booting'])
+ return;
+
+ $params = array(
+ XML_RPC_encode($password)
+ );
+
+ $numberofruns = 0;
+ while ($numberofruns < 2) {
+ $msg = new XML_RPC_Message($method, $params);
+ $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port);
+ $username = $config['system']['user'][0]['name'];
+ $cli->setCredentials($username, $password);
+ if($numberofruns > 1)
+ $cli->setDebug(1);
+ /* send our XMLRPC message and timeout after 240 seconds */
+ $resp = $cli->send($msg, "240");
+ if(!is_object($resp)) {
+ $error = "A communications error occured while attempting XMLRPC sync with username {$username} {$url}:{$port}.";
+ } elseif($resp->faultCode()) {
+ $error = "An error code was received while attempting XMLRPC sync with username {$username} {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString();
+ } else {
+ $parsed_response = XML_RPC_decode($resp->value());
+ if(!is_array($parsed_response)) {
+ if (trim($parsed_response) == "Authentication failed") {
+ $error = "A authentication failure occurred while trying to access {$url}:{$port} ({$method}).";
+ log_error($error);
+ file_notice("sync_settings", $error, "Settings Sync", "");
+ exit;
+ }
+ } else {
+ if (!isset($parsed_response['config_version']) ||
+ $parsed_response['config_version'] < $config['version'])
+ return false;
+ else
+ return true;
+ }
+ }
+ log_error($error);
+ file_notice("sync_settings", $error, "Settings Sync", "");
+ $numberofruns++;
+ }
+
+ return false;
+}
+
function carp_sync_xml($url, $password, $sections, $port = 80, $method = 'pfsense.restore_config_section') {
global $config, $g;
- if(file_exists("{$g['varrun_path']}/booting"))
+ if(file_exists("{$g['varrun_path']}/booting") || $g['booting'])
return;
update_filter_reload_status("Syncing CARP data to {$url}");
@@ -185,12 +241,7 @@ function carp_sync_xml($url, $password, $sections, $port = 80, $method = 'pfsens
$cli->setDebug(1);
/* send our XMLRPC message and timeout after 240 seconds */
$resp = $cli->send($msg, "240");
- if($resp->faultCode()) {
- $error = "A communications error occurred while attempting communication with {$url}:{$port} (pfsense.exec_php).";
- log_error($error);
- return;
- }
- if(!$resp) {
+ if(!is_object($resp)) {
$error = "A communications error occured while attempting XMLRPC sync with username {$username} {$url}:{$port}.";
log_error($error);
file_notice("sync_settings", $error, "Settings Sync", "");
@@ -199,39 +250,43 @@ function carp_sync_xml($url, $password, $sections, $port = 80, $method = 'pfsens
log_error($error);
file_notice("sync_settings", $error, "Settings Sync", "");
} else {
- log_error("XMLRPC sync successfully completed with {$url}:{$port}.");
+ $parsed_response = XML_RPC_decode($resp->value());
+ if(!is_array($parsed_response) && trim($parsed_repsonse) == "Authentication failed") {
+ $error = "A authentication failure occurred while trying to access {$url}:{$port} ($method).";
+ log_error($error);
+ file_notice("sync_settings", $error, "Settings Sync", "");
+ exit;
+ } else
+ log_error("XMLRPC sync successfully completed with {$url}:{$port}.");
$numberofruns = 3;
}
- $parsed_response = XML_RPC_Decode($resp->value());
- if(!is_array($firewall_info) && trim($firewall_info) == "Authentication failed") {
- $error = "A authentication failure occurred while trying to access {$url}:{$port} (pfsense.exec_php).";
- log_error($error);
- $numberofruns = 5;
- }
$numberofruns++;
}
}
global $g;
-if (file_exists("{$g['varrun_path']}/booting"))
+if (file_exists("{$g['varrun_path']}/booting") || $g['booting'])
return;
if (is_array($config['installedpackages']['carpsettings']['config'])) {
update_filter_reload_status("Building CARP sync information");
foreach($config['installedpackages']['carpsettings']['config'] as $carp) {
- if ($carp['synchronizetoip'] != "" ) {
- /*
- * XXX: The way we're finding the port right now is really suboptimal -
- * we can't assume that the other machine is setup identically.
- */
- if ($config['system']['webgui']['protocol'] != "") {
+ if (empty($carp['synchronizetoip'])) {
+ log_error("CARP sync not being done because of missing sync ip!");
+ break;
+ }
+ /*
+ * XXX: The way we're finding the port right now is really suboptimal -
+ * we can't assume that the other machine is setup identically.
+ */
+ if (!empty($config['system']['webgui']['protocol'])) {
$synchronizetoip = $config['system']['webgui']['protocol'];
$synchronizetoip .= "://";
}
/* if port is empty lets rely on the protocol selection */
$port = $config['system']['webgui']['port'];
- if ($port == "") {
+ if (empty($port)) {
if ($config['system']['webgui']['protocol'] == "http")
$port = "80";
else
@@ -328,6 +383,12 @@ if (is_array($config['installedpackages']['carpsettings']['config'])) {
if ($carp['synchronizecaptiveportal'] != "" and is_array($config['vouchers']))
$sections[] = 'vouchers';
if (count($sections) > 0) {
+ if (!carp_check_version($synchronizetoip, $carp['password'], $port)) {
+ update_filter_reload_status("The other member is on older version of {$g['product']}. Sync will not be done to prevent problems!");
+ log_error("The other member is on older version of {$g['product']}. Sync will not be done to prevent problems!");
+ break;
+ }
+
update_filter_reload_status("Signaling CARP reload signal...");
carp_sync_xml($synchronizetoip, $carp['password'], $sections, $port);
if (is_array($mergesections))
@@ -356,7 +417,6 @@ if (is_array($config['installedpackages']['carpsettings']['config'])) {
}
}
break;
- }
}
}
diff --git a/etc/rc.initial b/etc/rc.initial
index 13fcbba..3d600f1 100755
--- a/etc/rc.initial
+++ b/etc/rc.initial
@@ -3,7 +3,7 @@
# $Id$
# /etc/rc.initial
# part of pfSense by Scott Ullrich
-# Copyright (C) 2004 Scott Ullrich, All rights reserved.
+# Copyright (C) 2004-2010 Scott Ullrich, All rights reserved.
# originally based on m0n0wall (http://neon1.net/m0n0wall)
# Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
# All rights reserved.
@@ -43,42 +43,39 @@ fi
product=`grep product_name /etc/inc/globals.inc | cut -d'"' -f4`
hidebanner=`grep hidebanner /etc/inc/globals.inc | cut -d'"' -f4`
-# display a cheap menu
-echo
-echo
-echo " ${product} console setup "
-echo "***************************"
-echo " 0) Logout (SSH only)"
-echo " 1) Assign Interfaces"
-echo " 2) Set interface(s) IP address"
-echo " 3) Reset webConfigurator password"
-echo " 4) Reset to factory defaults"
-echo " 5) Reboot system"
-echo " 6) Halt system"
-echo " 7) Ping host"
-echo " 8) Shell"
-echo " 9) PFtop"
-echo "10) Filter Logs"
-echo "11) Restart webConfigurator"
-echo "12) ${product} Developer Shell"
-echo "13) Upgrade from console"
+# Check to see if SSH is listening.
SSHD=`/usr/bin/sockstat -4l | grep "*.22" | wc -l`
if [ "$SSHD" -gt 0 ]; then
- echo "14) Disable Secure Shell (sshd)";
+ sshd_option="14) Disable Secure Shell (sshd)";
else
- echo "14) Enable Secure Shell (sshd)";
+ sshd_option="14) Enable Secure Shell (sshd)";
fi
for i in /var/db/pfi/capable_*; do
if [ -f $i -a ! -L /cf/conf ]; then
- echo "98) Move configuration file to removable device"
+ option98="98) Move configuration file to removable device"
break
fi
done
if [ "$PLATFORM" = "cdrom" ]; then
- echo "99) Install ${product} to a hard drive/memory drive, etc."
- echo
+ option99="99) Install ${product} to a hard drive, etc."
+fi
+
+# display a cheap menu
+echo ""
+echo ""
+echo " 0) Logout (SSH only) 8) Shell"
+echo " 1) Assign Interfaces 9) pfTop"
+echo " 2) Set interface(s) IP address 10) Filter Logs"
+echo " 3) Reset webConfigurator password 11) Restart webConfigurator"
+echo " 4) Reset to factory defaults 12) ${product} Developer Shell"
+echo " 5) Reboot system 13) Upgrade from console"
+echo " 6) Halt system ${sshd_option}"
+echo " 7) Ping host ${option98}"
+
+if [ "${option99}" != "" ]; then
+ /bin/echo "${option99}"
fi
echo
diff --git a/etc/rc.newwanip b/etc/rc.newwanip
index 347ccd0..a31cddc 100755
--- a/etc/rc.newwanip
+++ b/etc/rc.newwanip
@@ -41,6 +41,10 @@ require_once("ipsec.inc");
require_once("vpn.inc");
require_once("openvpn.inc");
+// Do not process while booting
+if($g['booting'])
+ exit;
+
/* Interface IP address has changed */
$argument = str_replace("\n", "", $argv[1]);
@@ -71,6 +75,10 @@ $oldip = "0.0.0.0";
if (file_exists("{$g['vardb_path']}/{$interface}_cacheip"))
$oldip = file_get_contents("{$g['vardb_path']}/{$interface}_cacheip");
+$grouptmp = link_interface_to_group($interface);
+if (!empty($grouptmp))
+ array_walk($grouptmp, 'interface_group_add_member');
+
/* regenerate resolv.conf if DNS overrides are allowed */
system_resolvconf_generate(true);
@@ -84,8 +92,20 @@ system_routing_configure($interface);
/* reconfigure our gateway monitor */
setup_gateways_monitor();
-if (is_ipaddr($oldip) && $curwanip == $oldip)
+/* signal filter reload */
+filter_configure();
+
+if (is_ipaddr($oldip) && $curwanip == $oldip) {
+ // Still need to sync VPNs on PPPoE and such, as even with the same IP the VPN software is unhappy with the IP disappearing.
+ if (in_array($config['interfaces'][$interface]['ipaddr'], array('pppoe', 'pptp', 'ppp'))) {
+ /* reconfigure IPsec tunnels */
+ vpn_ipsec_force_reload();
+
+ /* start OpenVPN server & clients */
+ openvpn_resync_all($interface);
+ }
exit;
+}
/* perform RFC 2136 DNS update */
services_dnsupdate_process($interface);
@@ -99,10 +119,6 @@ vpn_ipsec_force_reload();
/* start OpenVPN server & clients */
openvpn_resync_all($interface);
-/* signal filter reload */
-unlink_if_exists("/tmp/config.cache");
-filter_configure();
-
/* reload graphing functions */
enable_rrd_graphing();
@@ -111,5 +127,4 @@ mwexec_bg("/usr/local/sbin/ntpdate_sync_once.sh");
mwexec_bg("/etc/rc.start_packages");
log_error("{$g['product_name']} package system has detected an ip change $oldip -> $curwanip ... Restarting packages.");
-return 0;
?>
diff --git a/etc/rc.php_ini_setup b/etc/rc.php_ini_setup
index b2b6320..6fc7589 100755
--- a/etc/rc.php_ini_setup
+++ b/etc/rc.php_ini_setup
@@ -26,7 +26,7 @@
# POSSIBILITY OF SUCH DAMAGE.
# Set our operating platform
-PLATFORM=`cat /etc/platform`
+PLATFORM=`/bin/cat /etc/platform`
EXTENSIONSDIR="/usr/local/lib/php/20060613/"
# Grab amount of memory that is detected
@@ -37,8 +37,8 @@ else
fi
if [ -z "$AVAILMEM" ]; then
- MEM=`sysctl hw.physmem | cut -d':' -f2`
- AVAILMEM=`expr $MEM / 1048576`
+ MEM=`/sbin/sysctl hw.physmem | cut -d':' -f2`
+ AVAILMEM=`/bin/expr $MEM / 1048576`
fi
# Calculate APC SHM size according
@@ -132,18 +132,18 @@ PHPMODULES="$PHPMODULES pfSense"
# Clear the .ini file to make sure we are clean
if [ -f /usr/local/etc/php.ini ]; then
- rm /usr/local/etc/php.ini
+ /bin/rm /usr/local/etc/php.ini
fi
if [ -f /usr/local/lib/php.ini ]; then
- rm /usr/local/lib/php.ini
+ /bin/rm /usr/local/lib/php.ini
fi
-LOADED_MODULES=`/usr/local/bin/php -m | grep -v "\["`
+LOADED_MODULES=`/usr/local/bin/php -m | /usr/bin/grep -v "\["`
# Get a loaded module list in the stock php
# Populate a dummy php.ini to avoid
# the file being clobbered and the firewall
# not being able to boot back up.
-cat >/usr/local/lib/php.ini <<EOF
+/bin/cat >/usr/local/lib/php.ini <<EOF
; File generated from /etc/rc.php_ini_setup
output_buffering = "0"
expose_php = Off
@@ -168,16 +168,16 @@ extension_dir=${EXTENSIONSDIR}
EOF
# Copy php.ini file to etc/ too (cli)
-cp /usr/local/lib/php.ini /usr/local/etc/php.ini
+/bin/cp /usr/local/lib/php.ini /usr/local/etc/php.ini
# Ensure directory exists
if [ ! -d /etc/php_dynamodules ]; then
- mkdir /etc/php_dynamodules
+ /bin/mkdir /etc/php_dynamodules
fi
# Read in dynamodules
if [ -d /etc/php_dynamodules ]; then
- DYNA_MODULES=`ls /etc/php_dynamodules/`
+ DYNA_MODULES=`/bin/ls /etc/php_dynamodules/`
PHPMODULES="$PHPMODULES $DYNA_MODULES"
fi
@@ -200,12 +200,12 @@ for EXT in $PHPMODULES; do
done
# Get amount of ram installed on this system
-RAM=`sysctl hw.realmem | awk '{print $2/1000000}' | awk -F '.' '{print $1}'`
+RAM=`/sbin/sysctl hw.realmem | /usr/bin/awk '{print $2/1000000}' | /usr/bin/awk -F '.' '{print $1}'`
export RAM
export LOWMEM
if [ "$RAM" -gt 96 ]; then
- cat >>/usr/local/lib/php.ini <<EOF
+ /bin/cat >>/usr/local/lib/php.ini <<EOF
; APC Settings
apc.enabled="1"
@@ -217,10 +217,10 @@ EOF
else
LOWMEM="TRUE"
echo ">>> WARNING! under 128 megabytes of ram detected. Not enabling APC."
- echo ">>> WARNING! under 128 megabytes of ram detected. Not enabling APC." | logger -p daemon.info -i -t rc.php_ini_setup
+ echo ">>> WARNING! under 128 megabytes of ram detected. Not enabling APC." | /usr/bin/logger -p daemon.info -i -t rc.php_ini_setup
fi
- cat >>/usr/local/lib/php.ini <<EOF
+ /bin/cat >>/usr/local/lib/php.ini <<EOF
[suhosin]
suhosin.get.max_array_depth = 5000
@@ -235,24 +235,25 @@ suhosin.request.max_array_depth = 5000
suhosin.request.max_array_index_length = 256
suhosin.request.max_vars = 5000
suhosin.request.max_value_length = 500000
+suhosin.memory_limit = 512435456
EOF
# Copy php.ini file to etc/ too (cli)
-cp /usr/local/lib/php.ini /usr/local/etc/php.ini
+/bin/cp /usr/local/lib/php.ini /usr/local/etc/php.ini
# Remove old log file if it exists.
if [ -f /var/run/php_modules_load_errors.txt ]; then
- rm /var/run/php_modules_load_errors.txt
+ /bin/rm /var/run/php_modules_load_errors.txt
fi
for EXT in $PHPMODULES; do
- PHPMODULESLC="$PHPMODULESLC `echo "$EXT" | tr '[:upper:]' '[:lower:]'`"
+ PHPMODULESLC="$PHPMODULESLC `echo "$EXT" | /usr/bin/tr '[:upper:]' '[:lower:]'`"
done
# Check loaded modules and remove anything that did not load correctly
-LOADED_MODULES=`/usr/local/bin/php -m | tr '[:upper:]' '[:lower:]' 2>/dev/null | grep -v "\["`
+LOADED_MODULES=`/usr/local/bin/php -m | /usr/bin/tr '[:upper:]' '[:lower:]' 2>/dev/null | /usr/bin/grep -v "\["`
for EXT in $PHPMODULESLC; do
SHOULDREMOVE="true"
for LM in $LOADED_MODULES; do
@@ -272,12 +273,12 @@ for EXT in $PHPMODULESLC; do
if [ "$SHOULDREMOVE" = "true" ]; then
if [ -f "${EXTENSIONSDIR}${EXT}.so" ]; then
echo ">>> ${EXT} did not load correctly. Removing from php.ini..." >> /var/run/php_modules_load_errors.txt
- cat /usr/local/lib/php.ini | grep -v $EXT > /tmp/php.ini
- rm -f /usr/local/lib/php.ini
- mv /tmp/php.ini /usr/local/lib/php.ini
+ /bin/cat /usr/local/lib/php.ini | /usr/bin/grep -v $EXT > /tmp/php.ini
+ /bin/rm -f /usr/local/lib/php.ini
+ /bin/mv /tmp/php.ini /usr/local/lib/php.ini
fi
fi
done
# Copy php.ini file to etc/ too (cli)
-cp /usr/local/lib/php.ini /usr/local/etc/php.ini
+/bin/cp /usr/local/lib/php.ini /usr/local/etc/php.ini
diff --git a/etc/sshd b/etc/sshd
index 4052423..28c8e55 100755
--- a/etc/sshd
+++ b/etc/sshd
@@ -53,7 +53,14 @@
if($g['platform'] == "nanobsd" and file_exists("/conf/sshd/ssh_host_key")) {
if(!file_exists("/etc/ssh/ssh_host_key.pub")) {
echo "Restoring SSH from /conf/sshd/";
- exec("cp /conf/sshd/* /etc/ssh/");
+ exec("/bin/cp -p /conf/sshd/* /etc/ssh/");
+
+ /* make sure host private key permissions aren't too open so sshd won't complain */
+ $files_to_check = array('ssh_host_dsa_key','ssh_host_key','ssh_host_rsa_key');
+ foreach($files_to_check as $f2c) {
+ if(file_exists("/etc/ssh/{$f2c}"))
+ chmod("/etc/ssh/{$f2c}", 0600);
+ }
}
}
@@ -176,7 +183,7 @@
if($g['platform'] == "nanobsd") {
if(!is_dir("/conf/sshd"))
exec("mkdir /conf/sshd");
- exec("cp /etc/ssh/ssh_host* /conf/sshd");
+ exec("/bin/cp -p /etc/ssh/ssh_host* /conf/sshd");
}
conf_mount_ro();
diff --git a/sbin/dhclient-script b/sbin/dhclient-script
index 01dfc78..ee98fa0 100755
--- a/sbin/dhclient-script
+++ b/sbin/dhclient-script
@@ -59,7 +59,7 @@ arp_flush() {
}
delete_old_address() {
- rm -f /var/db/${interface}_ip
+ /bin/rm -f /var/db/${interface}_ip
$IFCONFIG $interface inet -alias $old_ip_address $medium
}
@@ -82,8 +82,6 @@ add_new_address() {
echo $new_routers > /tmp/${interface}_router
echo $new_ip_address > /var/db/${interface}_ip
- /usr/local/sbin/pfSctl -c "interface newip $interface"
-
}
delete_old_alias() {
@@ -185,6 +183,7 @@ add_new_routes() {
return
fi
+ ADDED_ROUTE=no
# Only allow the default route to be overridden if it's on our own interface
if [ -f "/tmp/${interface}_defaultgw" ]; then
$ROUTE delete default
@@ -193,13 +192,12 @@ add_new_routes() {
$ROUTE add default -iface $interface
echo $ROUTE add default -iface $interface | $LOGGER
echo $router > /tmp/${interface}_router
- echo $router > /tmp/${interface}_defaultgw
else
$ROUTE add default $router
echo $ROUTE add default $router | $LOGGER
echo $router > /tmp/${interface}_router
- echo $router > /tmp/${interface}_defaultgw
fi
+ ADDED_ROUTE=yes
# 2nd and subsequent default routers error out, so explicitly
# stop processing the list after the first one.
break
@@ -211,8 +209,10 @@ add_new_routes() {
set $new_static_routes
while [ $# -gt 1 ]; do
$ROUTE add $1 $2
+ if [ "$ADDED_ROUTE" = "no" ]; then
+ echo $2 > /tmp/${interface}_router
+ fi
shift; shift
- echo $new_routers > /tmp/${interface}_router
done
fi
}
@@ -226,7 +226,7 @@ add_new_resolv_conf() {
done
fi
if [ -n "$new_domain_name_servers" ]; then
- rm -f /var/etc/nameserver_$interface
+ /bin/rm -f /var/etc/nameserver_$interface
for nameserver in $new_domain_name_servers; do
# Add a route to the nameserver out the correct interface
# so that mulitple wans work correctly with multiple dns
@@ -235,7 +235,6 @@ add_new_resolv_conf() {
$ROUTE add $nameserver -iface $interface
done
echo $new_domain_name >/var/etc/searchdomain_$interface
- /usr/local/sbin/pfSctl -c 'service reload dns'
fi
return 0
@@ -243,6 +242,7 @@ add_new_resolv_conf() {
# Notify rc.newwanip of changes to an interface
notify_rc_newwanip() {
+ /usr/local/sbin/pfSctl -c "interface newip $interface"
}
#
@@ -261,12 +261,12 @@ if [ -f /etc/dhclient-enter-hooks ]; then
fi
fi
-if [ -x $ROUTE ]; then
- if_defaultroute=`$ROUTE get default | $GREP interface | $AWK '{print $2}'`
-else
- $LOGGER "if_defaultroute"
- if_defaultroute="x"
-fi
+#if [ -x $ROUTE ]; then
+# if_defaultroute=`$ROUTE -n get -inet default | $GREP interface | $AWK '{print $2}'`
+#else
+# $LOGGER "if_defaultroute"
+# if_defaultroute="x"
+#fi
$LOGGER $reason
case $reason in
@@ -287,17 +287,17 @@ ARPCHECK|ARPSEND)
BOUND|RENEW|REBIND|REBOOT)
check_hostname
- changes=no
+ changes="no"
if [ -n "$old_ip_address" ]; then
if [ -n "$alias_ip_address" ] && \
[ "$old_ip_address" != "$alias_ip_address" ]; then
delete_old_alias
- changes=yes
+ changes="yes"
fi
if [ "$old_ip_address" != "$new_ip_address" ]; then
delete_old_address
delete_old_routes
- changes=yes
+ changes="yes"
fi
fi
if [ "$reason" = BOUND ] || \
@@ -306,12 +306,12 @@ BOUND|RENEW|REBIND|REBOOT)
[ "$old_ip_address" != "$new_ip_address" ]; then
add_new_address
add_new_routes
- changes=yes
+ changes="yes"
fi
if [ -n "$alias_ip_address" ] && \
[ "$new_ip_address" != "$alias_ip_address" ]; then
add_new_alias
- changes=yes
+ changes="yes"
fi
add_new_resolv_conf
if [ "$changes" = "yes" ] ; then
@@ -334,7 +334,7 @@ TIMEOUT)
if [ -n "$new_routers" ]; then
$LOGGER "New Routers ($interface): $new_routers"
set "$new_routers"
- if /sbin/ping -q -c 1 -w 1 "$1"; then
+ if /sbin/ping -q -c 1 -t 1 "$1"; then
if [ "$new_ip_address" != "$alias_ip_address" ]; then
add_new_alias
fi
diff --git a/usr/local/bin/beep.sh b/usr/local/bin/beep.sh
index ca39a07..febb222 100755
--- a/usr/local/bin/beep.sh
+++ b/usr/local/bin/beep.sh
@@ -9,14 +9,14 @@ if [ "$PFSENSETYPE" = "embedded" ]; then
fi
# this is super annoying in VMware, exit if in VMware
-VMWCOUNT=`dmesg -a | grep VMware | wc -l | awk '{ print $1 }'`
+VMWCOUNT=`/usr/bin/grep -c VMware /var/log/dmesg.boot`
if [ $VMWCOUNT -gt 0 ]; then
exit;
fi
# Check for different HZ
if [ -f /boot/loader.conf ]; then
- HZ=`cat /boot/loader.conf | grep kern.hz | wc -l | awk '{ print $1 }'`
+ HZ=`/usr/bin/grep -c kern.hz /boot/loader.conf`
if [ "$HZ" = "1" ]; then
NOTELENGTH="10"
fi
diff --git a/usr/local/pkg/carp_settings.xml b/usr/local/pkg/carp_settings.xml
index de0d226..19db7e7 100644
--- a/usr/local/pkg/carp_settings.xml
+++ b/usr/local/pkg/carp_settings.xml
@@ -3,58 +3,54 @@
<name>carpsettings</name>
<version>0.1.0</version>
<title>Services: CARP Settings</title>
- <!-- configpath gets expanded out automatically and config items will be
- stored in that location -->
<configpath>['installedpackages']['carpsettings']['config']</configpath>
<aftersaveredirect>pkg_edit.php?xml=carp_settings.xml&amp;id=0</aftersaveredirect>
- <!-- Menu is where this packages menu will appear -->
<menu>
- <name>CARP (failover)</name>
- <tooltiptext>CARP is a tool to help achieve system redundancy, by having multiple computers creating a single, virtual network interface between them, so that if any machine fails, another can respond instead. CARP is an improvement over the Virtual Router Redundancy Protocol (VRRP) standard. It was developed after VRRP was deemed to be not free enough because of a possibly-overlapping Cisco patent.</tooltiptext>
- <section>Firewall</section>
- <configfile>carp_settings.xml</configfile>
+ <name>CARP (failover)</name>
+ <tooltiptext>CARP is a tool to help achieve system redundancy, by having multiple computers creating a single, virtual network interface between them, so that if any machine fails, another can respond instead. CARP is an improvement over the Virtual Router Redundancy Protocol (VRRP) standard. It was developed after VRRP was deemed to be not free enough because of a possibly-overlapping Cisco patent.</tooltiptext>
+ <section>Firewall</section>
+ <configfile>carp_settings.xml</configfile>
</menu>
<tabs>
-<!-- <tab>
- <text>CARP Virtual IPs</text>
- <url>/pkg.php?xml=carp.xml</url>
- </tab>
--->
- <tab>
- <text>Virtual IPs</text>
- <url>firewall_virtual_ip.php</url>
- </tab>
- <tab>
- <text>CARP Settings</text>
- <url>pkg_edit.php?xml=carp_settings.xml&amp;id=0</url>
- <active/>
- </tab>
+ <tab>
+ <text>Virtual IPs</text>
+ <url>firewall_virtual_ip.php</url>
+ </tab>
+ <tab>
+ <text>CARP Settings</text>
+ <url>pkg_edit.php?xml=carp_settings.xml&amp;id=0</url>
+ <active/>
+ </tab>
</tabs>
<adddeleteeditpagefields>
- <columnitem>
- <fielddescr>PFSync Enabled</fielddescr>
- <fieldname>pfsyncenabled</fieldname>
- </columnitem>
- <columnitem>
- <fielddescr>PFSync IP</fielddescr>
- <fieldname>pfsyncip</fieldname>
- </columnitem>
- <columnitem>
- <fielddescr>PFSync Interface</fielddescr>
- <fieldname>pfsyncinterface</fieldname>
- </columnitem>
+ <columnitem>
+ <fielddescr>PFSync Enabled</fielddescr>
+ <fieldname>pfsyncenabled</fieldname>
+ </columnitem>
+ <columnitem>
+ <fielddescr>PFSync IP</fielddescr>
+ <fieldname>pfsyncip</fieldname>
+ </columnitem>
+ <columnitem>
+ <fielddescr>PFSync Interface</fielddescr>
+ <fieldname>pfsyncinterface</fieldname>
+ </columnitem>
</adddeleteeditpagefields>
- <!-- fields gets invoked when the user adds or edits a item. the following items
- will be parsed and rendered for the user as a gui with input, and selectboxes. -->
<fields>
<field>
- <fielddescr>Synchronize Enabled</fielddescr>
+ <name>State Synchronization Settings (pfsync)</name>
+ <type>listtopic</type>
+ </field>
+ <field>
+ <fielddescr>Synchronize States</fielddescr>
<fieldname>pfsyncenabled</fieldname>
- <description>
- PFSync transfers state insertion, update, and deletion messages between firewalls. Each firewall sends these messages out via multicast on a specified interface, using the PFSYNC protocol (IP Protocol 240). It also listens on that interface for similar messages from other firewalls, and imports them into the local state table.
+ <description>
+ pfsync transfers state insertion, update, and deletion messages between firewalls. Each firewall sends these messages out via multicast on a specified interface, using the PFSYNC protocol (IP Protocol 240). It also listens on that interface for similar messages from other firewalls, and imports them into the local state table.
+ &lt;p&gt;
+ This setting should be enabled on all members of a failover group.
&lt;p&gt;
- NOTE: Clicking save will force a configuration sync!
- </description>
+ NOTE: Clicking save will force a configuration sync if it is enabled! (see Configuration Synchronization Settings below)
+ </description>
<type>checkbox</type>
</field>
<field>
@@ -62,14 +58,14 @@
<fieldname>pfsyncinterface</fieldname>
<type>interfaces_selection</type>
<description>
- If Synchronize State is enabled, it will utilize this interface for communication.
- &lt;br&gt;&lt;b&gt;NOTE:&lt;/b&gt; We recommend setting this to a interface other than LAN! A dedicated interface works the best.
- &lt;br&gt;&lt;b&gt;NOTE:&lt;/b&gt; You must define a IP on each machine participating in this failover group.
- &lt;br&gt;&lt;b&gt;NOTE:&lt;/b&gt; You must have an IP assigned to the interface on any participating sync nodes.
+ If Synchronize States is enabled, it will utilize this interface for communication.
+ &lt;br&gt;&lt;b&gt;NOTE:&lt;/b&gt; We recommend setting this to a interface other than LAN! A dedicated interface works the best.
+ &lt;br&gt;&lt;b&gt;NOTE:&lt;/b&gt; You must define a IP on each machine participating in this failover group.
+ &lt;br&gt;&lt;b&gt;NOTE:&lt;/b&gt; You must have an IP assigned to the interface on any participating sync nodes.
</description>
</field>
<field>
- <fielddescr>pfSync sync peer IP</fielddescr>
+ <fielddescr>pfsync Synchronize Peer IP</fielddescr>
<fieldname>pfsyncpeerip</fieldname>
<type>input</type>
<description>
@@ -77,6 +73,26 @@
</description>
</field>
<field>
+ <name>Configuration Synchronization Settings (XMLRPC Sync)</name>
+ <type>listtopic</type>
+ </field>
+ <field>
+ <fielddescr>Synchronize Config to IP</fielddescr>
+ <fieldname>synchronizetoip</fieldname>
+ <description>Enter the IP address of the firewall to which the selected configuration sections should be synchronized.
+ &lt;br&gt;&lt;br&gt;NOTE: XMLRPC sync is currently only supported over connections using the same protocol and port as this system - make sure the remote system's port and protocol are set accordingly!
+ &lt;br&gt;&lt;br&gt;NOTE: &lt;b&gt;Do not use the Synchronize Config to IP and password option on backup cluster members!&lt;/b&gt;
+ </description>
+ <type>input</type>
+ </field>
+ <field>
+ <fielddescr>Remote System Password</fielddescr>
+ <fieldname>password</fieldname>
+ <description>Enter the webConfigurator password of the system entered above for synchronizing your configuration.
+ &lt;br&gt;&lt;br&gt;NOTE: &lt;b&gt;Do not use the Synchronize Config to IP and password option on backup cluster members!&lt;/b&gt;</description>
+ <type>password</type>
+ </field>
+ <field>
<fielddescr>Synchronize Users and Groups</fielddescr>
<fieldname>synchronizeusers</fieldname>
<description>When this option is enabled, this system will automatically sync the users and groups over to the other CARP host when changes are made.</description>
@@ -166,20 +182,6 @@
<description>When this option is enabled, this system will automatically sync the Captive Portal configuration to the other CARP host when changes are made.</description>
<type>checkbox</type>
</field>
- <field>
- <fielddescr>Synchronize to IP</fielddescr>
- <fieldname>synchronizetoip</fieldname>
- <description>Enter the IP address of the firewall you are synchronizing with.</description>
- <type>input</type>
- <note>Note: CARP sync is currently only supported over connections using the same protocol and port as this system - make sure the remote system's port and protocol are set accordingly! Also note that you will not use the Synchronize to IP and password option on backup cluster members!</note>
- </field>
- <field>
- <fielddescr>Remote System Password</fielddescr>
- <fieldname>password</fieldname>
- <description>Enter the webConfigurator password of the system that you would like to synchronize with.</description>
- <type>password</type>
- <note>NOTE: You will not use the Synchronize to IP and password option on backup cluster members!</note>
- </field>
</fields>
<custom_php_validation_command>
if($_POST["synchronizetoip"]) {
diff --git a/usr/local/www/carp_status.php b/usr/local/www/carp_status.php
index 543d3d7..187736b 100755
--- a/usr/local/www/carp_status.php
+++ b/usr/local/www/carp_status.php
@@ -47,13 +47,11 @@ function gentitle_pkg($pgname) {
unset($interface_arr_cache);
unset($carp_interface_count_cache);
-unset($carp_query);
unset($interface_ip_arr_cache);
$status = get_carp_status();
if($_POST['disablecarp'] <> "") {
if($status == true) {
- $carp_ints = get_all_carp_interfaces();
mwexec("/sbin/sysctl net.inet.carp.allow=0");
if(is_array($config['virtualip']['vip'])) {
$viparr = &$config['virtualip']['vip'];
@@ -110,10 +108,13 @@ include("head.inc");
<tr>
<td>
<?php
+ $carpcount = 0;
if(is_array($config['virtualip']['vip'])) {
foreach($config['virtualip']['vip'] as $carp) {
- if ($carp['mode'] == "carp")
+ if ($carp['mode'] == "carp") {
$carpcount++;
+ break;
+ }
}
}
if($carpcount > 0) {
@@ -146,13 +147,15 @@ include("head.inc");
if(is_array($config['virtualip']['vip'])) {
foreach($config['virtualip']['vip'] as $carp) {
- if ($carp['mode'] != "carp") continue;
+ if ($carp['mode'] != "carp")
+ continue;
$ipaddress = $carp['subnet'];
$password = $carp['password'];
$netmask = $carp['subnet_bits'];
$vhid = $carp['vhid'];
$advskew = $carp['advskew'];
- $carp_int = find_carp_interface($ipaddress);
+ $advbase = $carp['advbase'];
+ $carp_int = "vip{$vhid}";
$status = get_carp_interface_status($carp_int);
echo "<tr>";
$align = "valign='middle'";
diff --git a/usr/local/www/diag_backup.php b/usr/local/www/diag_backup.php
index ad96ed3..410fb0b 100755
--- a/usr/local/www/diag_backup.php
+++ b/usr/local/www/diag_backup.php
@@ -49,6 +49,7 @@ ini_set('max_input_time', '0');
/* omit no-cache headers because it confuses IE with file downloads */
$omit_nocacheheaders = true;
+$nocsrf = true;
require("guiconfig.inc");
require_once("functions.inc");
require_once("filter.inc");
diff --git a/usr/local/www/diag_limiter_info.php b/usr/local/www/diag_limiter_info.php
new file mode 100644
index 0000000..1d4ca28
--- /dev/null
+++ b/usr/local/www/diag_limiter_info.php
@@ -0,0 +1,116 @@
+<?php
+/* $Id$ */
+/*
+ diag_limiter_info.php
+ Copyright (C) 2010 Scott Ullrich
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/*
+ pfSense_BUILDER_BINARIES: /usr/bin/top
+ pfSense_MODULE: system
+*/
+
+##|+PRIV
+##|*IDENT=page-diag-system-activity
+##|*NAME=Diagnostics: System Activity
+##|*DESCR=Allows access to the 'Diagnostics: System Activity' page
+##|*MATCH=diag_system_activity*
+##|-PRIV
+
+require("guiconfig.inc");
+
+$pfSversion = str_replace("\n", "", file_get_contents("/etc/version"));
+
+$pgtitle = gettext("Diagnostics: Limiter Info");
+
+if($_REQUEST['getactivity']) {
+ $text = `/sbin/ipfw pipe show`;
+ if($text == "")
+ $text = "We could not find any limiters on this system.";
+ echo $text;
+ exit;
+}
+
+include("head.inc");
+
+?>
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+
+<script type="text/javascript">
+ function getlimiteractivity() {
+ var url = "/diag_limiter_info.php";
+ var pars = 'getactivity=yes';
+ var myAjax = new Ajax.Request(
+ url,
+ {
+ method: 'post',
+ parameters: pars,
+ onComplete: activitycallback
+ });
+ }
+ function activitycallback(transport) {
+ $('limiteractivitydiv').innerHTML = '<font face="Courier"><font size="2"><b><pre>' + transport.responseText + '</pre></font>';
+ setTimeout('getlimiteractivity()', 2000);
+ }
+ setTimeout('getlimiteractivity()', 5000);
+</script>
+<div id='maincontent'>
+<?php
+ include("fbegin.inc");
+ if(strstr($pfSversion, "1.2"))
+ echo "<p class=\"pgtitle\">{$pgtitle}</p>";
+ if($savemsg) {
+ echo "<div id='savemsg'>";
+ print_info_box($savemsg);
+ echo "</div>";
+ }
+ if ($input_errors)
+ print_input_errors($input_errors);
+?>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td>
+ <table id="backuptable" class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td>
+ <center>
+ <table>
+ <tr><td>
+ <div name='limiteractivitydiv' id='limiteractivitydiv'>
+ <b><?=gettext("Gathering Limiter information, please wait...");?>
+ </div>
+ </td></tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </td>
+ </tr>
+</table>
+</form>
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/usr/local/www/diag_pf_info.php b/usr/local/www/diag_pf_info.php
new file mode 100644
index 0000000..633cd1e
--- /dev/null
+++ b/usr/local/www/diag_pf_info.php
@@ -0,0 +1,120 @@
+<?php
+/* $Id$ */
+/*
+ diag_pf_info.php
+ Copyright (C) 2010 Scott Ullrich
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/*
+ pfSense_BUILDER_BINARIES: /usr/bin/top
+ pfSense_MODULE: system
+*/
+
+##|+PRIV
+##|*IDENT=page-diag-system-activity
+##|*NAME=Diagnostics: System Activity
+##|*DESCR=Allows access to the 'Diagnostics: System Activity' page
+##|*MATCH=diag_system_activity*
+##|-PRIV
+
+require("guiconfig.inc");
+
+$pfSversion = str_replace("\n", "", file_get_contents("/etc/version"));
+
+$pgtitle = gettext("Diagnostics: pfInfo");
+
+if($_REQUEST['getactivity']) {
+ $text = `/sbin/pfctl -vvsi`;
+ $text .= "<p/>";
+ $text .= `/sbin/pfctl -vvsm`;
+ $text .= "<p/>";
+ $text .= `/sbin/pfctl -vvst`;
+ $text .= "<p/>";
+ $text .= `/sbin/pfctl -vvsI`;
+ echo $text;
+ exit;
+}
+
+include("head.inc");
+
+?>
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+
+<script type="text/javascript">
+ function getcpuactivity() {
+ var url = "/diag_pf_info.php";
+ var pars = 'getactivity=yes';
+ var myAjax = new Ajax.Request(
+ url,
+ {
+ method: 'post',
+ parameters: pars,
+ onComplete: activitycallback
+ });
+ }
+ function activitycallback(transport) {
+ $('cpuactivitydiv').innerHTML = '<font face="Courier"><font size="2"><b><pre>' + transport.responseText + '</pre></font>';
+ setTimeout('getcpuactivity()', 2000);
+ }
+ setTimeout('getcpuactivity()', 5000);
+</script>
+<div id='maincontent'>
+<?php
+ include("fbegin.inc");
+ if(strstr($pfSversion, "1.2"))
+ echo "<p class=\"pgtitle\">{$pgtitle}</p>";
+ if($savemsg) {
+ echo "<div id='savemsg'>";
+ print_info_box($savemsg);
+ echo "</div>";
+ }
+ if ($input_errors)
+ print_input_errors($input_errors);
+?>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td>
+ <table id="backuptable" class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td>
+ <center>
+ <table>
+ <tr><td>
+ <div name='cpuactivitydiv' id='cpuactivitydiv'>
+ <b><?=gettext("Gathering PF information, please wait...");?>
+ </div>
+ </td></tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </td>
+ </tr>
+</table>
+</form>
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/usr/local/www/diag_pkglogs.php b/usr/local/www/diag_pkglogs.php
index 9fb2b8f..17459c4 100755
--- a/usr/local/www/diag_pkglogs.php
+++ b/usr/local/www/diag_pkglogs.php
@@ -50,6 +50,7 @@
##|-PRIV
require("guiconfig.inc");
+require("pkg-utils.inc");
if(!($nentries = $config['syslog']['nentries'])) $nentries = 50;
@@ -58,7 +59,7 @@ if(!($nentries = $config['syslog']['nentries'])) $nentries = 50;
$i = 0;
$pkgwithlogging = false;
-$apkg = $_POST['pkg'];
+$apkg = $_GET['pkg'];
if(!$apkg) { // If we aren't looking for a specific package, locate the first package that handles logging.
if($config['installedpackages']['package'] <> "") {
foreach($config['installedpackages']['package'] as $package) {
@@ -84,8 +85,8 @@ include("head.inc");
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
<?php include("fbegin.inc"); ?>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
- <tr><td>
- <ul id="tabnav">
+ <tr>
+ <td>
<?php
if($pkgwithlogging == false) {
print_info_box(gettext("No packages with logging facilities are currently installed."));
@@ -93,23 +94,25 @@ include("head.inc");
include("fend.inc");
exit;
}
+ $tab_array = array();
foreach($config['installedpackages']['package'] as $package) {
if(is_array($package['logging'])) {
if(!($logtab = $package['logging']['logtab'])) $logtab = $package['name'];
if($apkg == $package['name']) {
$curtab = $logtab;
- echo '<li class="tabact">' . $logtab . '</li>';
+ $tab_array[] = array(sprintf(gettext("%s"),$logtab), true, "diag_pkglogs.php?pkg=".$package['name']);
} else {
- Echo '<li class="tabinact"><a href="diag_pkglogs.php?pkg=' . htmlspecialchars($package['name']) . '">' . $logtab . '</a></li>';
+ $tab_array[] = array(sprintf(gettext("%s"),$logtab), false, "diag_pkglogs.php?pkg=".$package['name']);
}
}
}
+ display_top_tabs($tab_array);
?>
- </ul>
</td></tr>
<tr>
- <td class="tabcont">
- <table width="100%" border="0" cellspacing="0" cellpadding="0">
+ <td>
+ <div id="mainarea">
+ <table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2" class="listtopic">
<?php printf(gettext('Last %1$s %2$s log entries'),$nentries,$curtab); ?></td>
@@ -119,12 +122,12 @@ include("head.inc");
dump_clog($g['varlog_path'] . '/' . $package['logging']['logfilename'], $nentries);
?>
</table>
- <br>
<!--
<form action="diag_pkglogs.php" method="post">
<input name="clear" type="submit" class="formbtn" value="Clear log">
</form>
-->
+ </div>
</td>
</tr>
</table>
diff --git a/usr/local/www/diag_system_pftop.php b/usr/local/www/diag_system_pftop.php
index a3e6680..a064f27 100644
--- a/usr/local/www/diag_system_pftop.php
+++ b/usr/local/www/diag_system_pftop.php
@@ -42,7 +42,7 @@ require("guiconfig.inc");
$pfSversion = str_replace("\n", "", file_get_contents("/etc/version"));
-$pgtitle = gettext("Diagnostics: PFTop");
+$pgtitle = gettext("Diagnostics: pfTop");
if($_REQUEST['getactivity']) {
if($_REQUEST['sorttype'])
diff --git a/usr/local/www/edit.php b/usr/local/www/edit.php
index 9236c3f..3b94d69 100644
--- a/usr/local/www/edit.php
+++ b/usr/local/www/edit.php
@@ -58,9 +58,11 @@ if($_REQUEST['action']) {
$_REQUEST['data'] = str_replace("\r", "", base64_decode($_REQUEST['data']));
$ret = file_put_contents($_REQUEST['file'], $_REQUEST['data']);
conf_mount_ro();
- if($_REQUEST['file'] == "config.xml")
+ if($_REQUEST['file'] == "/conf/config.xml" || $_REQUEST['file'] == "/cf/conf/config.xml") {
if(file_exists("/tmp/config.cache"))
unlink("/tmp/config.cache");
+ disable_security_checks();
+ }
if($ret === false) {
echo "|" . gettext("Failed to write file") . ".|";
} elseif($ret <> strlen($_REQUEST['data'])) {
diff --git a/usr/local/www/fbegin.inc b/usr/local/www/fbegin.inc
index d9c7641..c2d5955 100755
--- a/usr/local/www/fbegin.inc
+++ b/usr/local/www/fbegin.inc
@@ -171,9 +171,9 @@ $ifentries = get_configured_interface_with_descr();
foreach ($ifentries as $ent => $entdesc) {
if (is_array($config['interfaces'][$ent]['wireless']) &&
preg_match($g['wireless_regex'], $config['interfaces'][$ent]['if']))
- $ifdescrs[$ent] = $entdesc;
+ $wifdescrs[$ent] = $entdesc;
}
-if (count($ifdescrs) > 0)
+if (count($wifdescrs) > 0)
$status_menu[] = array("Wireless", "/status_wireless.php");
$status_menu = msort(array_merge($status_menu, return_ext_menu("Status")),0);
@@ -187,9 +187,12 @@ $diagnostics_menu[] = array("DNS Lookup", "/diag_dns.php");
$diagnostics_menu[] = array("Edit File", "/edit.php");
$diagnostics_menu[] = array("Factory Defaults", "/diag_defaults.php");
$diagnostics_menu[] = array("Halt System", "/halt.php" );
+$diagnostics_menu[] = array("Limiter Info", "/diag_limiter_info.php" );
+
$diagnostics_menu[] = array("Tables", "/diag_tables.php");
$diagnostics_menu[] = array("Ping", "/diag_ping.php");
-$diagnostics_menu[] = array("pfTOP", "/diag_system_pftop.php");
+$diagnostics_menu[] = array("pfInfo", "/diag_pf_info.php");
+$diagnostics_menu[] = array("pfTop", "/diag_system_pftop.php");
$diagnostics_menu[] = array("Reboot", "/reboot.php");
$diagnostics_menu[] = array("Routes", "/diag_routes.php");
$diagnostics_menu[] = array("SMART Status", "/diag_smart.php");
diff --git a/usr/local/www/firewall_aliases_edit.php b/usr/local/www/firewall_aliases_edit.php
index ec7572f..516956c 100755
--- a/usr/local/www/firewall_aliases_edit.php
+++ b/usr/local/www/firewall_aliases_edit.php
@@ -584,7 +584,7 @@ EOD;
<option value="network" <?php if ($pconfig['type'] == "network") echo "selected"; ?>><?=gettext("Network(s)"); ?></option>
<option value="port" <?php if ($pconfig['type'] == "port") echo "selected"; ?>><?=gettext("Port(s)"); ?></option>
<option value="openvpn" <?php if ($pconfig['type'] == "openvpn") echo "selected"; ?>><?=gettext("OpenVPN Users"); ?></option>
- <option value="url" <?php if ($pconfig['type'] == "url") echo "selected"; ?>><?=gettext("URL");?></option>
+ <option value="url" <?php if ($pconfig['type'] == "url") echo "selected"; ?>><?=gettext("URL");?></option>
<option value="urltable" <?php if ($pconfig['type'] == "urltable") echo "selected"; ?>><?=gettext("URL Table"); ?></option>
</select>
</td>
diff --git a/usr/local/www/firewall_nat_1to1.php b/usr/local/www/firewall_nat_1to1.php
index 94132f2..306c811 100755
--- a/usr/local/www/firewall_nat_1to1.php
+++ b/usr/local/www/firewall_nat_1to1.php
@@ -114,27 +114,43 @@ include("head.inc");
</table>
</td>
</tr>
- <?php $i = 0; foreach ($a_1to1 as $natent): ?>
+ <?php
+ $textse = "</span>";
+
+ $i = 0; foreach ($a_1to1 as $natent):
+
+ if (isset($natent['disabled']))
+ $textss = "<span class=\"gray\">";
+ else
+ $textss = "<span>"; ?>
<tr>
<td class="listlr" ondblclick="document.location='firewall_nat_1to1_edit.php?id=<?=$i;?>';">
<?php
+ echo $textss;
if (!$natent['interface'])
echo htmlspecialchars(convert_friendly_interface_to_friendly_descr("wan"));
else
echo htmlspecialchars(convert_friendly_interface_to_friendly_descr($natent['interface']));
+ echo $textse;
?>
</td>
<td class="listr" ondblclick="document.location='firewall_nat_1to1_edit.php?id=<?=$i;?>';">
- <?php echo $natent['external']; ?>
+ <?php
+ $source_net = pprint_address($natent['source']);
+ $source_cidr = strstr($source_net, '/');
+ echo $textss . $natent['external'] . $source_cidr . $textse;
+ ?>
</td>
<td class="listr" ondblclick="document.location='firewall_nat_1to1_edit.php?id=<?=$i;?>';">
- <?php echo pprint_address($natent['source']); ?>
+ <?php echo $textss . $source_net . $textse; ?>
</td>
<td class="listr" ondblclick="document.location='firewall_nat_1to1_edit.php?id=<?=$i;?>';">
- <?php echo pprint_address($natent['destination']); ?>
+ <?php echo $textss . pprint_address($natent['destination']) . $textse; ?>
</td>
<td class="listbg" ondblclick="document.location='firewall_nat_1to1_edit.php?id=<?=$i;?>';">
+ <?=$textss;?>
<?=htmlspecialchars($natent['descr']);?>&nbsp;
+ <?=$textse;?>
</td>
<td class="list" nowrap>
<table border="0" cellspacing="0" cellpadding="1">
diff --git a/usr/local/www/firewall_nat_out_edit.php b/usr/local/www/firewall_nat_out_edit.php
index 3484755..2910c08 100755
--- a/usr/local/www/firewall_nat_out_edit.php
+++ b/usr/local/www/firewall_nat_out_edit.php
@@ -113,13 +113,15 @@ if ($_POST) {
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
- if($_POST['sourceport'] <> "" && !is_port($_POST['sourceport']))
+ $protocol_uses_ports = in_array($_POST['protocol'], explode(" ", "any tcp udp tcp/udp"));
+
+ if($protocol_uses_ports && $_POST['sourceport'] <> "" && !is_port($_POST['sourceport']))
$input_errors[] = gettext("You must supply either a valid port for the source port entry.");
- if($_POST['dstport'] <> "" and !is_port($_POST['dstport']))
+ if($protocol_uses_ports and $_POST['dstport'] <> "" and !is_port($_POST['dstport']))
$input_errors[] = gettext("You must supply either a valid port for the destination port entry.");
- if($_POST['natport'] <> "" and !is_port($_POST['natport']))
+ if($protocol_uses_ports and $_POST['natport'] <> "" and !is_port($_POST['natport']) and !isset($_POST['nonat']))
$input_errors[] = gettext("You must supply either a valid port for the nat port entry.");
if ($_POST['source_type'] != "any") {
@@ -130,7 +132,7 @@ if ($_POST) {
if ($_POST['source_subnet'] && !is_numericint($_POST['source_subnet'])) {
$input_errors[] = gettext("A valid source bit count must be specified.");
}
- if ($_POST['sourceport'] && !is_numericint($_POST['sourceport'])) {
+ if ($protocol_uses_ports && $_POST['sourceport'] && !is_numericint($_POST['sourceport'])) {
$input_errors[] = gettext("A valid source port must be specified.");
}
if ($_POST['destination_type'] != "any") {
@@ -147,11 +149,7 @@ if ($_POST) {
}
}
- if ($_POST['nonat'] && $_POST['staticnatport']) {
- $input_errors[] = gettext("Static port cannot be used with No NAT.");
- }
-
- if ($_POST['target'] && !is_ipaddr($_POST['target'])) {
+ if ($_POST['target'] && !is_ipaddr($_POST['target']) && !isset($_POST['nonat'])) {
$input_errors[] = gettext("A valid target IP address must be specified.");
}
@@ -182,13 +180,13 @@ if ($_POST) {
if (!$input_errors) {
$natent = array();
$natent['source']['network'] = $osn;
- $natent['sourceport'] = $_POST['sourceport'];
+ $natent['sourceport'] = ($protocol_uses_ports) ? $_POST['sourceport'] : "";
$natent['descr'] = $_POST['descr'];
- $natent['target'] = $_POST['target'];
+ $natent['target'] = (!isset($_POST['nonat'])) ? $_POST['target'] : "";
$natent['interface'] = $_POST['interface'];
/* static-port */
- if(isset($_POST['staticnatport'])) {
+ if(isset($_POST['staticnatport']) && $protocol_uses_ports && !isset($_POST['nonat'])) {
$natent['staticnatport'] = true;
} else {
unset($natent['staticnatport']);
@@ -211,12 +209,12 @@ if ($_POST) {
} else {
$natent['destination']['address'] = $ext;
}
- if($_POST['natport'] != "") {
+ if($_POST['natport'] != "" && $protocol_uses_ports && !isset($_POST['nonat'])) {
$natent['natport'] = $_POST['natport'];
} else {
unset($natent['natport']);
}
- if($_POST['dstport'] != "") {
+ if($_POST['dstport'] != "" && $protocol_uses_ports) {
$natent['dstport'] = $_POST['dstport'];
} else {
unset($natent['dstport']);
diff --git a/usr/local/www/firewall_rules.php b/usr/local/www/firewall_rules.php
index 2cbc908..4072383 100755
--- a/usr/local/www/firewall_rules.php
+++ b/usr/local/www/firewall_rules.php
@@ -379,7 +379,22 @@ if($_REQUEST['undodrag']) {
<?php // Show the anti-lockout rule if it's enabled, and we are on LAN with an if count > 1, or WAN with an if count of 1.
if (!isset($config['system']['webgui']['noantilockout']) &&
(((count($config['interfaces']) > 1) && ($if == 'lan'))
- || ((count($config['interfaces']) == 1) && ($if == 'wan')))): ?>
+ || ((count($config['interfaces']) == 1) && ($if == 'wan')))):
+
+ $guiport = "80";
+ if (isset($config['system']['webgui']['port']) && $config['system']['webgui']['port'] <> "")
+ $guiport = "{$config['system']['webgui']['port']}";
+ if ($config['system']['webgui']['protocol'] == "https")
+ $guiport .= "<br/>443";
+
+ $sshport = "";
+ if (isset($config['system']['enablesshd'])) {
+ $sshport = 22;
+ if($config['system']['ssh']['port'] <> "")
+ $sshport = $config['system']['ssh']['port'];
+ }
+ $sshport = "22<br/>";
+?>
<tr valign="top" id="antilockout">
<td class="list">&nbsp;</td>
<td class="listt" align="center"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_pass.gif" width="11" height="11" border="0"></td>
@@ -388,7 +403,7 @@ if($_REQUEST['undodrag']) {
<td class="listr" style="background-color: #E0E0E0">*</td>
<td class="listr" style="background-color: #E0E0E0">*</td>
<td class="listr" style="background-color: #E0E0E0"><?=$iflist[$if];?> Address</td>
- <td class="listr" style="background-color: #E0E0E0">*</td>
+ <td class="listr" style="background-color: #E0E0E0"><?= $sshport . $guiport ?></td>
<td class="listr" style="background-color: #E0E0E0">*</td>
<td class="listr" style="background-color: #E0E0E0">*</td>
<td class="listr" style="background-color: #E0E0E0"></td>
@@ -535,7 +550,7 @@ if($_REQUEST['undodrag']) {
$schedstatus = false;
$dayArray = array (gettext('Mon'),gettext('Tues'),gettext('Wed'),gettext('Thur'),gettext('Fri'),gettext('Sat'),gettext('Sun'));
$monthArray = array (gettext('January'),gettext('February'),gettext('March'),gettext('April'),gettext('May'),gettext('June'),gettext('July'),gettext('August'),gettext('September'),gettext('October'),gettext('November'),gettext('December'));
- if($config['schedules']['schedule'] <> "" and is_array($config['schedules']['schedule'])){
+ if($config['schedules']['schedule'] <> "" and is_array($config['schedules']['schedule'])) {
foreach ($a_schedules as $schedule)
{
if ($schedule['name'] == $filterent['sched'] ){
@@ -838,6 +853,7 @@ if($_REQUEST['undodrag']) {
<script type="text/javascript">
var number_of_rules = <?=$nrules?>;
<?php $nrules = 0; for ($i = 0; isset($a_filter[$i]); $i++): ?>
+/*
Sortable.create("dragtable", {
tag:"tr",
format:"fr([0-9999999])",
@@ -850,6 +866,7 @@ if($_REQUEST['undodrag']) {
updateOrder(Sortable.serialize('dragtable', 'tr'));
}
});
+*/
<?php endfor; ?>
function updateOrder(order) {
if(document.getElementById("redboxtable"))
diff --git a/usr/local/www/firewall_rules_edit.php b/usr/local/www/firewall_rules_edit.php
index e348c15..1c625c6 100755
--- a/usr/local/www/firewall_rules_edit.php
+++ b/usr/local/www/firewall_rules_edit.php
@@ -365,6 +365,10 @@ if ($_POST) {
else if ($_POST['ackqueue'] == $_POST['defaultqueue'])
$input_errors[] = gettext("Acknowledge queue and Queue cannot be the same.");
}
+ if (isset($_POST['floating']) && $_POST['pdnpipe'] != "none" && (empty($_POST['direction']) || $_POST['direction'] == "any"))
+ $input_errors[] = gettext("You can not use limiters in Floating rules without choosing a direction.");
+ if (isset($_POST['floating']) && $_POST['gateway'] != "" && (empty($_POST['direction']) || $_POST['direction'] == "any"))
+ $input_errors[] = gettext("You can not use gateways in Floating rules without choosing a direction.");
if ($_POST['pdnpipe'] && $_POST['pdnpipe'] != "none") {
if ($_POST['dnpipe'] == "none" )
$input_errors[] = gettext("You must select a queue for the In direction before selecting one for Out too.");
diff --git a/usr/local/www/firewall_shaper_layer7.php b/usr/local/www/firewall_shaper_layer7.php
index 0a73a84..b1d8353 100755
--- a/usr/local/www/firewall_shaper_layer7.php
+++ b/usr/local/www/firewall_shaper_layer7.php
@@ -166,7 +166,7 @@ else if ($_POST) {
}
unset($dupes);
unset($dupe_error);
- //Even if there are repeated protocols, we won't loose any previous values
+ //Even if there are repeated protocols, we won't lose any previous values
//The user will be able to solve the situation
$output_form .= $l7r->build_form();
//Necessary to correctly build the proto form
diff --git a/usr/local/www/firewall_virtual_ip.php b/usr/local/www/firewall_virtual_ip.php
index c3607ec..63d0f7e 100755
--- a/usr/local/www/firewall_virtual_ip.php
+++ b/usr/local/www/firewall_virtual_ip.php
@@ -117,6 +117,12 @@ if ($_GET['act'] == "del") {
if (ip_in_subnet($vip['subnet'], gen_subnet($a_vip[$_GET['id']]['subnet'], $a_vip[$_GET['id']]['subnet_bits']) . "/" . $a_vip[$_GET['id']]['subnet_bits']))
$input_errors[] = gettext("This entry cannot be deleted because it is still referenced by CARP") . " {$vip['descr']}.";
}
+ } else if ($a_vip[$_GET['id']]['mode'] == "carp") {
+ $vipiface = $a_vip[$_GET['id']]['interface'];
+ foreach ($a_vip as $vip) {
+ if ($vipiface == "vip{$vip['vhid']}" && $vip['mode'] == "ipalias")
+ $input_errors[] = gettext("This entry cannot be deleted because it is still referenced by ip alias entry") . " {$vip['descr']}.";
+ }
}
diff --git a/usr/local/www/firewall_virtual_ip_edit.php b/usr/local/www/firewall_virtual_ip_edit.php
index a35c264..34ac040 100755
--- a/usr/local/www/firewall_virtual_ip_edit.php
+++ b/usr/local/www/firewall_virtual_ip_edit.php
@@ -82,6 +82,7 @@ if (isset($id) && $a_vip[$id]) {
$pconfig['mode'] = $a_vip[$id]['mode'];
$pconfig['vhid'] = $a_vip[$id]['vhid'];
$pconfig['advskew'] = $a_vip[$id]['advskew'];
+ $pconfig['advbase'] = $a_vip[$id]['advbase'];
$pconfig['password'] = $a_vip[$id]['password'];
$pconfig['range'] = $a_vip[$id]['range'];
$pconfig['subnet'] = $a_vip[$id]['subnet'];
@@ -138,7 +139,9 @@ if ($_POST) {
/* make sure new ip is within the subnet of a valid ip
* on one of our interfaces (wan, lan optX)
*/
- if ($_POST['mode'] == "carp" or $_POST['mode'] == "carpdev-dhcp") {
+ switch ($_POST['mode']) {
+ case "carp":
+ case "carpdev-dhcp":
/* verify against reusage of vhids */
$idtracker = 0;
foreach($config['virtualip']['vip'] as $vip) {
@@ -166,8 +169,26 @@ if ($_POST) {
$input_errors[] = sprintf(gettext("Sorry, we could not locate an interface with a matching subnet for %s. Please add an IP alias in this subnet on this interface."),$cannot_find);
}
}
+ if (substr($_POST['interface'], 0, 3) == "vip")
+ $input_errors[] = gettext("For this type of vip a carp parent is not allowed.");
+ break;
+ case "ipalias":
+ if (substr($_POST['interface'], 0, 3) == "vip") {
+ $parent_ip = get_interface_ip($_POST['interface']);
+ $parent_sn = get_interface_subnet($_POST['interface']);
+ if (!ip_in_subnet($_POST['subnet'], gen_subnet($parent_ip, $parent_sn) . "/" . $parent_sn) && !ip_in_interface_alias_subnet($_POST['interface'], $_POST['subnet'])) {
+ $cannot_find = $_POST['subnet'] . "/" . $_POST['subnet_bits'] ;
+ $input_errors[] = sprintf(gettext("Sorry, we could not locate an interface with a matching subnet for %s. Please add an IP alias in this subnet on this interface."),$cannot_find);
+ }
+ }
+ break;
+ default:
+ if (substr($_POST['interface'], 0, 3) == "vip")
+ $input_errors[] = gettext("For this type of vip a carp parent is not allowed.");
+ break;
}
+
if (isset($id) && ($a_vip[$id])) {
if ($a_vip[$id]['mode'] != $_POST['mode']) {
$bringdown = false;
@@ -201,6 +222,7 @@ if ($_POST) {
if ($_POST['mode'] === "carp" or $_POST['mode'] == "carpdev-dhcp") {
$vipent['vhid'] = $_POST['vhid'];
$vipent['advskew'] = $_POST['advskew'];
+ $vipent['advbase'] = $_POST['advbase'];
$vipent['password'] = $_POST['password'];
}
@@ -278,28 +300,30 @@ function enable_change(enable_over) {
document.iform.vhid.disabled = 0;
document.iform.password.disabled = 0;
document.iform.advskew.disabled = 0;
+ document.iform.advbase.disabled = 0;
document.iform.type.disabled = 1;
document.iform.subnet_bits.disabled = 0;
- document.iform.subnet.disabled = 0;
- if (note.firstChild == null) {
- note.appendChild(carpnote);
- } else {
- note.removeChild(note.firstChild);
- note.appendChild(carpnote);
- }
+ document.iform.subnet.disabled = 0;
+ if (note.firstChild == null) {
+ note.appendChild(carpnote);
+ } else {
+ note.removeChild(note.firstChild);
+ note.appendChild(carpnote);
+ }
} else {
document.iform.vhid.disabled = 1;
document.iform.password.disabled = 1;
document.iform.advskew.disabled = 1;
+ document.iform.advbase.disabled = 1;
document.iform.type.disabled = 0;
document.iform.subnet_bits.disabled = 1;
- document.iform.subnet.disabled = 0;
- if (note.firstChild == null) {
- note.appendChild(proxyarpnote);
- } else {
- note.removeChild(note.firstChild);
- note.appendChild(proxyarpnote);
- }
+ document.iform.subnet.disabled = 0;
+ if (note.firstChild == null) {
+ note.appendChild(proxyarpnote);
+ } else {
+ note.removeChild(note.firstChild);
+ note.appendChild(proxyarpnote);
+ }
}
if (get_radio_value(document.iform.mode) == "other") {
document.iform.type.disabled = 1;
@@ -323,9 +347,10 @@ function enable_change(enable_over) {
document.iform.subnet.disabled = 1;
document.iform.subnet.value = '';
document.iform.subnet_bits.value = '';
- document.iform.vhid.disabled = 0;
- document.iform.password.disabled = 0;
- document.iform.advskew.disabled = 0;
+ document.iform.vhid.disabled = 0;
+ document.iform.password.disabled = 0;
+ document.iform.advskew.disabled = 0;
+ document.iform.advbase.disabled = 0;
}
}
function typesel_change() {
@@ -389,6 +414,9 @@ function typesel_change() {
<select name="interface" class="formselect">
<?php
$interfaces = get_configured_interface_with_descr(false, true);
+ $carplist = get_configured_carp_interface_list();
+ foreach ($carplist as $cif => $carpip)
+ $interfaces[$cif] = $carpip." (".get_vip_descr($carpip).")";
foreach ($interfaces as $iface => $ifacename): ?>
<option value="<?=$iface;?>" <?php if ($iface == $pconfig['interface']) echo "selected"; ?>>
<?=htmlspecialchars($ifacename);?>
@@ -447,7 +475,7 @@ function typesel_change() {
<tr valign="top">
<td width="22%" class="vncellreq"><?=gettext("VHID Group");?></td>
<td class="vtable"><select id='vhid' name='vhid'>
- <?php for ($i = 1; $i <= 254; $i++): ?>
+ <?php for ($i = 1; $i <= 255; $i++): ?>
<option value="<?=$i;?>" <?php if ($i == $pconfig['vhid']) echo "selected"; ?>>
<?=$i;?>
</option>
@@ -458,14 +486,23 @@ function typesel_change() {
</tr>
<tr valign="top">
<td width="22%" class="vncellreq"><?=gettext("Advertising Frequency");?></td>
- <td class="vtable"><select id='advskew' name='advskew'>
+ <td class="vtable">
+ Base: <select id='advbase' name='advbase'>
+ <?php for ($i = 1; $i <= 254; $i++): ?>
+ <option value="<?=$i;?>" <?php if ($i == $pconfig['advbase']) echo "selected"; ?>>
+ <?=$i;?>
+ </option>
+ <?php endfor; ?>
+ </select>
+ Skew: <select id='advskew' name='advskew'>
<?php for ($i = 0; $i <= 254; $i++): ?>
- <option value="<?=$i;?>" <?php if ($i == $pconfig['advskew']) echo "selected"; ?>>
+ <option value="<?=$i;?>" <?php if ($i == $pconfig['advskew']) echo "selected"; ?>>
<?=$i;?>
- </option>
+ </option>
<?php endfor; ?>
- </select>
- <br><?=gettext("The frequency that this machine will advertise. 0 = master. Anything above 0 designates a backup.");?>
+ </select>
+ <br/><br/>
+ <?=gettext("The frequency that this machine will advertise. 0 means usually master. Otherwise the lowest combination of both values in the cluster detrmines the master.");?>
</td>
</tr>
<tr>
diff --git a/usr/local/www/getserviceproviders.php b/usr/local/www/getserviceproviders.php
index 5767950..a2122c0 100644
--- a/usr/local/www/getserviceproviders.php
+++ b/usr/local/www/getserviceproviders.php
@@ -35,6 +35,7 @@
##|*DESCR=Allow access to the 'AJAX: Service Providers' page.
##|*MATCH=getserviceproviders.php*
##|-PRIV
+require_once("guiconfig.inc");
require_once("pfsense-utils.inc");
$serviceproviders_xml = "/usr/local/share/mobile-broadband-provider-info/serviceproviders.xml";
diff --git a/usr/local/www/guiconfig.inc b/usr/local/www/guiconfig.inc
index bafb8fa..70f9459 100755
--- a/usr/local/www/guiconfig.inc
+++ b/usr/local/www/guiconfig.inc
@@ -1059,7 +1059,8 @@ function rule_popup($src,$srcport,$dst,$dstport){
$alias_caption = substr($alias_caption, 0, $maxlength) . "...";
$alias_caption_escaped = str_replace("'", "\'", $alias_caption);
- $span_begin = "<span style=\"cursor: help;\" onmouseover=\"domTT_activate(this, event, 'content', '<h1>$alias_caption_escaped</h1><p>$alias_content_text</p>', 'trail', true, 'delay', 0, 'fade', 'both', 'fadeMax', 93, 'styleClass', 'niceTitle');\" onmouseout=\"this.style.color = ''; domTT_mouseout(this, event);\"><U>";
+ $alias_content_escaped = str_replace("'", "\'", $alias_content_text);
+ $span_begin = "<span style=\"cursor: help;\" onmouseover=\"domTT_activate(this, event, 'content', '<h1>$alias_caption_escaped</h1><p>$alias_content_escaped</p>', 'trail', true, 'delay', 0, 'fade', 'both', 'fadeMax', 93, 'styleClass', 'niceTitle');\" onmouseout=\"this.style.color = ''; domTT_mouseout(this, event);\"><U>";
if ($alias_name['name'] == $src)
$alias_src_span_begin = $span_begin;
diff --git a/usr/local/www/help.php b/usr/local/www/help.php
index 89a5feb..f7df5c9 100644
--- a/usr/local/www/help.php
+++ b/usr/local/www/help.php
@@ -121,7 +121,7 @@ $helppages = array(
'services_snmp.php' => 'http://doc.pfsense.org/index.php/SNMP_Daemon',
'services_wol.php' => 'http://doc.pfsense.org/index.php/Wake_on_LAN',
'services_wol_edit.php' => 'http://doc.pfsense.org/index.php/Wake_on_LAN',
- 'routed/routed.xml' => 'http://doc.pfsense.org/index.php/Routing_Information_Protocol_(RIP)', # RIP
+ 'routed.xml' => 'http://doc.pfsense.org/index.php/Routing_Information_Protocol_(RIP)', # RIP
'system.php' => 'http://doc.pfsense.org/index.php/General_Setup_(2.0)',
'system_advanced_admin.php' => 'http://doc.pfsense.org/index.php/Advanced_Setup_(2.0)',
'system_advanced_firewall.php' => 'http://doc.pfsense.org/index.php/Advanced_Setup_(2.0)#Firewall.2FNAT',
@@ -208,6 +208,14 @@ $helppages = array(
'vpn_openvpn_crl_edit.php' => 'http://doc.pfsense.org/index.php/Category:OpenVPN',
'vpn_openvpn_srv.php' => 'http://doc.pfsense.org/index.php/Category:OpenVPN',
'vpn_openvpn_srv_edit.php' => 'http://doc.pfsense.org/index.php/Category:OpenVPN',
+ 'diag_authentication.php' => 'http://doc.pfsense.org/index.php/User_Authentication_Servers',
+ 'diag_limiter_info.php' => 'http://doc.pfsense.org/index.php/Traffic_Shaping_Guide#Display_Pipes',
+ 'diag_pf_info.php' => 'http://doc.pfsense.org/index.php/Packet_Filter_Information',
+ 'diag_smart.php' => 'http://doc.pfsense.org/index.php/SMART_Status',
+ 'diag_states_summary.php' => 'http://doc.pfsense.org/index.php/States_Summary',
+ 'interfaces_wireless.php' => 'http://doc.pfsense.org/index.php/Wireless_Interfaces',
+ 'interfaces_wireless_edit.php' => 'http://doc.pfsense.org/index.php/Wireless_Interfaces',
+ 'system_crlmanager.php' => 'http://doc.pfsense.org/index.php/Certificate_Management',
/* Below here are pages that may need some cleanup or have not been fully looked at yet */
diff --git a/usr/local/www/index.php b/usr/local/www/index.php
index ffc3369..3bb68cf 100755
--- a/usr/local/www/index.php
+++ b/usr/local/www/index.php
@@ -423,7 +423,7 @@ EOD;
$closehead = false;
## Set Page Title and Include Header
-$pgtitle = array(sprintf(gettext("%s Dashboard"), $g['product_name']));
+$pgtitle = array(gettext("Status: Dashboard"));
include("head.inc");
echo "\t<script type=\"text/javascript\" src=\"javascript/domTT/domLib.js\"></script>\n";
diff --git a/usr/local/www/installer/index.php b/usr/local/www/installer/index.php
new file mode 100644
index 0000000..2c7dd90
--- /dev/null
+++ b/usr/local/www/installer/index.php
@@ -0,0 +1,5 @@
+<?php
+
+Header("Location: installer.php");
+
+?> \ No newline at end of file
diff --git a/usr/local/www/installer.php b/usr/local/www/installer/installer.php
index aa3b9c0..508a1dc 100644
--- a/usr/local/www/installer.php
+++ b/usr/local/www/installer/installer.php
@@ -1,6 +1,6 @@
<?php
/*
- installer.php
+ installer.php (pfSense installer)
part of pfSense (http://www.pfsense.com/)
Copyright (C) 2010 Scott Ullrich <sullrich@gmail.com>
All rights reserved.
@@ -35,7 +35,7 @@ require("guiconfig.inc");
define('PC_SYSINSTALL', '/usr/sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh');
if($g['platform'] == "pfSense" or $g['platform'] == "nanobsd") {
- Header("Location: /index.php");
+ Header("Location: /");
exit;
}
@@ -58,35 +58,61 @@ switch ($_REQUEST['state']) {
installer_main();
}
-function write_out_pc_sysinstaller_config($disk, $fstype = "UFS+S", $swapsize = false) {
+function write_out_pc_sysinstaller_config($disks, $bootmanager = "bsd") {
+ $diskareas = "";
$fd = fopen("/usr/sbin/pc-sysinstall/examples/pfSense-install.cfg", "w");
if(!$fd) {
return true;
}
- if($swapsize <> "") {
- $diskareas = "disk0-part=SWAP {$swapsize} none \n";
- $diskareas .= "disk0-part={$fstype} 0 /\n";
- } else {
- $diskareas = "disk0-part={$fstype} 0 /\n";
+ if($bootmanager == "")
+ $bootmanager = "none";
+ $numdisks = -1;
+ $lastdisk = "";
+ $diskdefs = "";
+ // Run through the disks and create the conf areas for pc-sysinstaller
+ foreach($disks as $disksa) {
+ $fstype = $disksa['fstype'];
+ $size = $disksa['size'];
+ $mountpoint = $disksa['mountpoint'];
+ $disk = $disksa['disk'];
+ if($disk <> $lastdisk) {
+ $lastdisk = $disk;
+ $numdisks++;
+ $diskdefs .= "disk{$numdisks}={$disk}\n";
+ }
+ $diskareas .= "disk{$numdisks}-part={$fstype} {$size} {$mountpoint} \n";
+ if($encpass)
+ $diskareas .= "encpass={$encpass}\n";
}
+
$config = <<<EOF
# Sample configuration file for an installation using pc-sysinstall
-
+# This file was automatically generated by installer.php
+
installMode=fresh
installInteractive=yes
installType=FreeBSD
installMedium=LiveCD
# Set the disk parameters
-disk0={$disk}
+{$diskdefs}
partition=all
-bootManager=bsd
+bootManager={$bootmanager}
commitDiskPart
# Setup the disk label
# All sizes are expressed in MB
# Avail FS Types, UFS, UFS+S, UFS+J, ZFS, SWAP
# Size 0 means use the rest of the slice size
+# Alternatively, you can append .eli to any of
+# the above filesystem types to encrypt that disk.
+# If you with to use a passphrase with this
+# encrypted partition, on the next line
+# the flag "encpass=" should be entered:
+# encpass=mypass
+# disk0-part=UFS 500 /boot
+# disk0-part=UFS.eli 500 /
+# disk0-part=UFS.eli 500 /usr
{$diskareas}
# Do it now!
@@ -98,7 +124,7 @@ installType=FreeBSD
packageType=cpdup
# Optional Components
-cpdupPaths=boot,COPYRIGHT,bin,conf,conf.default,dev,etc,home,kernels,libexec,lib,root,sbin,sys,usr,var
+cpdupPaths=boot,COPYRIGHT,bin,conf,conf.default,dev,etc,home,kernels,libexec,lib,root,sbin,usr,var
# runExtCommand=chmod a+rx /usr/local/bin/after_installation_routines.sh ; cd / ; /usr/local/bin/after_installation_routines.sh
EOF;
@@ -108,10 +134,10 @@ EOF;
}
function start_installation() {
- global $g, $fstype;
+ global $g, $fstype, $savemsg;
if(file_exists("/tmp/install_complete"))
return;
- $ps_running = exec("ps awwwux | grep -v grep | grep 'sh /tmp/installer.sh'");
+ $ps_running = exec("/bin/ps awwwux | /usr/bin/grep -v grep | /usr/bin/grep 'sh /tmp/installer.sh'");
if($ps_running)
return;
$fd = fopen("/tmp/installer.sh", "w");
@@ -119,35 +145,33 @@ function start_installation() {
die(gettext("Could not open /tmp/installer.sh for writing"));
exit;
}
- fwrite($fd, "rm /tmp/.pc-sysinstall/pc-sysinstall.log 2>/dev/null\n");
+ fwrite($fd, "/bin/rm /tmp/.pc-sysinstall/pc-sysinstall.log 2>/dev/null\n");
fwrite($fd, "/usr/sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh -c /usr/sbin/pc-sysinstall/examples/pfSense-install.cfg \n");
- fwrite($fd, "chmod a+rx /usr/local/bin/after_installation_routines.sh\n");
+ fwrite($fd, "/bin/chmod a+rx /usr/local/bin/after_installation_routines.sh\n");
fwrite($fd, "cd / && /usr/local/bin/after_installation_routines.sh\n");
- fwrite($fd, "mkdir /mnt/tmp\n");
-// fwrite($fd, "umount /mnt\n");
- fwrite($fd, "touch /tmp/install_complete\n");
+ fwrite($fd, "/bin/mkdir /mnt/tmp\n");
+ fwrite($fd, "/usr/bin/touch /tmp/install_complete\n");
fclose($fd);
- exec("chmod a+rx /tmp/installer.sh");
- mwexec_bg("sh /tmp/installer.sh");
+ exec("/bin/chmod a+rx /tmp/installer.sh");
+ mwexec_bg("/bin/sh /tmp/installer.sh");
}
function installer_find_first_disk() {
- global $g, $fstype;
+ global $g, $fstype, $savemsg;
$disk = `/usr/sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh disk-list | head -n1 | cut -d':' -f1`;
- return $disk;
+ return trim($disk);
}
function pcsysinstall_get_disk_info($diskname) {
- global $g, $fstype;
+ global $g, $fstype, $savemsg;
$disk = split("\n", `/usr/sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh disk-list`);
$disks_array = array();
foreach($disk as $d) {
- if(!$d)
- continue;
$disks_info = split(":", $d);
$tmp_array = array();
if($disks_info[0] == $diskname) {
$disk_info = split("\n", `/usr/sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh disk-info {$disks_info[0]}`);
+ $disk_info_split = split("=", $disk_info);
foreach($disk_info as $di) {
$di_s = split("=", $di);
if($di_s[0])
@@ -162,7 +186,7 @@ function pcsysinstall_get_disk_info($diskname) {
// Return an array with all disks information.
function installer_find_all_disks() {
- global $g, $fstype;
+ global $g, $fstype, $savemsg;
$disk = split("\n", `/usr/sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh disk-list`);
$disks_array = array();
foreach($disk as $d) {
@@ -184,7 +208,7 @@ function installer_find_all_disks() {
}
function update_installer_status() {
- global $g, $fstype;
+ global $g, $fstype, $savemsg;
// Ensure status files exist
if(!file_exists("/tmp/installer_installer_running"))
touch("/tmp/installer_installer_running");
@@ -252,14 +276,14 @@ function update_installer_status() {
// Check for error and bail if we see one.
if(stristr($status, "error")) {
$error = true;
- echo "\$('installerrunning').innerHTML='<img class=\"infoboxnpimg\" src=\"/themes/{$g['theme']}/images/icons/icon_exclam.gif\"> <font size=\"2\"><b>An error occurred. Aborting installation. <a href=\"installer.php\">Back</a> to webInstaller'; ";
+ echo "\$('installerrunning').innerHTML='<img class=\"infoboxnpimg\" src=\"/themes/{$g['theme']}/images/icons/icon_exclam.gif\"> <font size=\"2\"><b>An error occurred. Aborting installation. <a href=\"/installer\">Back</a> to webInstaller'; ";
echo "\$('progressbar').style.width='100%';\n";
unlink_if_exists("/tmp/install_complete");
return;
}
$running_old = trim(file_get_contents("/tmp/installer_installer_running"));
if($installer_running <> "running") {
- $ps_running = exec("ps awwwux | grep -v grep | grep 'sh /tmp/installer.sh'");
+ $ps_running = exec("/bin/ps awwwux | /usr/bin/grep -v grep | /usr/bin/grep 'sh /tmp/installer.sh'");
if($ps_running) {
$running = "\$('installerrunning').innerHTML='<table><tr><td valign=\"middle\"><img src=\"/themes/{$g['theme']}/images/misc/loader.gif\"></td><td valign=\"middle\">&nbsp;<font size=\"2\"><b>Installer running ({$progress}% completed)...</td></tr></table>'; ";
if($running_old <> $running) {
@@ -271,7 +295,7 @@ function update_installer_status() {
if($progress)
echo "\$('progressbar').style.width='{$progress}%';\n";
if(file_exists("/tmp/install_complete")) {
- echo "\$('installerrunning').innerHTML='<img class=\"infoboxnpimg\" src=\"/themes/{$g['theme']}/images/icons/icon_exclam.gif\"> <font size=\"+1\">Installation completed. Please <a href=\"reboot.php\">reboot</a> to continue';\n";
+ echo "\$('installerrunning').innerHTML='<img class=\"infoboxnpimg\" src=\"/themes/{$g['theme']}/images/icons/icon_exclam.gif\"> <font size=\"+1\">Installation completed. Please <a href=\"/reboot.php\">reboot</a> to continue';\n";
echo "\$('pbdiv').Fade();\n";
unlink_if_exists("/tmp/installer.sh");
file_put_contents("/tmp/installer_installer_running", "finished");
@@ -279,45 +303,35 @@ function update_installer_status() {
}
function update_installer_status_win($status) {
- global $g, $fstype;
+ global $g, $fstype, $savemsg;
echo "<script type=\"text/javascript\">\n";
echo " \$('installeroutput').value = '" . str_replace(htmlentities($status), "\n", "") . "';\n";
echo "</script>";
}
function begin_install() {
- global $g;
+ global $g, $savemsg;
if(file_exists("/tmp/install_complete"))
return;
unlink_if_exists("/tmp/install_complete");
- if($_REQUEST['disk'])
- $disk = htmlspecialchars($_REQUEST['disk']);
- else
- $disk = installer_find_first_disk();
- if(!$disk) {
- echo "<script type=\"text/javascript\">";
- echo "\$('pbdiv').Fade();\n";
- echo "</script>";
- $savemsg = gettext("Could not find a suitable disk for installation");
- update_installer_status_win(gettext("Could not find a suitable disk for installation."));
- return;
- }
- // Handle other type of file systems
- if($_REQUEST['fstype'])
- $fstype = htmlspecialchars(strtoupper($_REQUEST['fstype']));
- else
- $fstype = "UFS+S";
- write_out_pc_sysinstaller_config($disk, $fstype);
update_installer_status_win(sprintf(gettext("Beginning installation on disk %s."),$disk));
start_installation();
}
function head_html() {
- global $g, $fstype;
+ global $g, $fstype, $savemsg;
echo <<<EOF
<html>
<head>
<style type='text/css'>
+ hr {
+ border: 0;
+ color: #000000;
+ background-color: #000000;
+ height: 1px;
+ width: 100%;
+ text-align: left;
+ }
a:link {
color: #000000;
text-decoration:underline;
@@ -345,18 +359,19 @@ EOF;
}
function body_html() {
- global $g, $fstype;
+ global $g, $fstype, $savemsg;
$pfSversion = str_replace("\n", "", file_get_contents("/etc/version"));
- if(strstr($pfSversion, "1.2"))
+ if(strstr($pfSversion, "1.2"))
$one_two = true;
- $pgtitle = "{$g['product_name']}: " . gettext("Installer");
+ $pgtitle = array("{$g['product_name']}", gettext("Installer"));
include("head.inc");
echo <<<EOF
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
<script src="/javascript/scriptaculous/prototype.js" type="text/javascript"></script>
+ <script src="/javascript/scriptaculous/scriptaculous.js" type="text/javascript"></script>
<script type="text/javascript">
function getinstallerprogress() {
- url = 'installer.php';
+ url = '/installer/installer.php';
pars = 'state=update_installer_status';
callajax(url, pars, installcallback);
}
@@ -383,14 +398,14 @@ EOF;
}
function end_html() {
- global $g, $fstype;
+ global $g, $fstype, $savemsg;
echo "</form>";
echo "</body>";
echo "</html>";
}
function template() {
- global $g, $fstype;
+ global $g, $fstype, $savemsg;
head_html();
body_html();
echo <<<EOF
@@ -420,24 +435,74 @@ EOF;
}
function verify_before_install() {
- global $g, $fstype;
+ global $g, $fstype, $savemsg;
+ $encrypted_root = false;
+ $non_encrypted_boot = false;
+ $non_encrypted_notice = false;
head_html();
body_html();
- page_table_start();
+ page_table_start($g['product_name'] . " installer - Verify final installation settings");
+ // If we are visiting this step from anything but the row editor / custom install
+ // then load the on disk layout contents if they are available.
+ if(!$_REQUEST['fstype0'] && file_exists("/tmp/webInstaller_disk_layout.txt")) {
+ $disks = unserialize(file_get_contents("/tmp/webInstaller_disk_layout.txt"));
+ $bootmanager = unserialize(file_get_contents("/tmp/webInstaller_disk_bootmanager.txt"));
+ $restored_layout_from_file = true;
+ $restored_layout_txt = "The previous disk layout was restored from disk";
+ }
+ if(!$bootmanager)
+ $bootmanager = $_REQUEST['bootmanager'];
+ echo "\n<!--" . print_r($_REQUEST, true) . " -->\n";
$disk = pcsysinstall_get_disk_info(htmlspecialchars($_REQUEST['disk']));
$disksize = format_bytes($disk['size'] * 1048576);
- $swapsize = htmlspecialchars($_REQUEST['swapsize']);
- $fstype_echo = htmlspecialchars($_REQUEST['fstype']);
- $disk_echo = htmlspecialchars($_REQUEST['disk']);
- $swapsize_echo = htmlspecialchars($_REQUEST['swapsize']);
- echo <<<EOF
+ $disks = array();
+ // Loop through posted items and create an array
+ for($x=0; $x<99; $x++) { // XXX: Make this more optimal
+ if(!$_REQUEST['fstype' . $x])
+ continue;
+ $tmparray = array();
+ if($_REQUEST['fstype' . $x] <> "SWAP") {
+ $tmparray['mountpoint'] = $_REQUEST['mountpoint' . $x];
+ // Check for encrypted slice /
+ if(stristr($_REQUEST['fstype' . $x], ".eli")) {
+ if($tmparray['mountpoint'] == "/")
+ $encrypted_root = true;
+ }
+ // Check if we have a non-encrypted /boot
+ if($tmparray['mountpoint'] == "/boot") {
+ if(!stristr($_REQUEST['fstype' . $x], ".eli"))
+ $non_encrypted_boot = true;
+ }
+ if($tmparray['mountpoint'] == "/conf") {
+ $tmparray['mountpoint'] = "/conf{$x}";
+ $error_txt[] = "/conf is not an allowed mount point and has been renamed to /conf{$x}.";
+ }
+ } else {
+ $tmparray['mountpoint'] = "none";
+ }
+ // If we have an encrypted /root and lack a non encrypted /boot, throw an error/warning
+ if($encrypted_root && !$non_encrypted_boot && !$non_encrypted_notice) {
+ $error_txt[] = "A non-encrypted /boot slice is required when encrypting the / slice";
+ $non_encrypted_notice = true;
+ }
+ $tmparray['disk'] = $_REQUEST['disk' . $x];
+ $tmparray['fstype'] = $_REQUEST['fstype' . $x];
+ $tmparray['size'] = $_REQUEST['size' . $x];
+ $tmparray['encpass'] = $_REQUEST['encpass' . $x];
+ $disks[] = $tmparray;
+ }
+ echo "\n<!-- " . print_r($disks, true) . " --> \n";
+ $bootmanagerupper = strtoupper($bootmanager);
+ echo <<<EOFAMBAC
<form method="post" action="installer.php">
<input type="hidden" name="fstype" value="{$fstype_echo}">
<input type="hidden" name="disk" value="{$disk_echo}">
<input type="hidden" name="state" value="begin_install">
- <input type="hidden" name="swapsize" value="{$swapsize_echo}">
+ <input type="hidden" name="swapsize" value="{$swapsize}">
+ <input type="hidden" name="encpass" value="{$encpass}">
+ <input type="hidden" name="bootmanager" value="{$bootmanager}">
<div id="mainlevel">
- <table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <table width="800" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<div id="mainarea">
@@ -447,20 +512,55 @@ function verify_before_install() {
<div>
<center>
<div id="pfsensetemplate">
- <table bgcolor="FFFF00" width="400" height="30" cellpadding="2" style="border:1px dashed;">
- <tr valign="middle">
- <td>
- <center><b>Please verify that the following is correct:</b></center>
- </td>
- </tr>
- </table>
- <p/>
- <table>
- <tr><td align="right"><b>Disk:</td><td>{$disk_echo}</td></tr>
- <tr><td align="right"><b>Description:</td><td>{$disk['desc']}</td></tr>
- <tr><td align="right"><b>Size:</td><td>{$disksize}</td></tr>
- <tr><td align="right"><b>SWAP Size:</td><td>{$swapsize}</td></tr>
- <tr><td align="right"><b>Filesystem:</td><td>{$fstype_echo}</td></tr>
+ <table width='100%'>
+EOFAMBAC;
+ // If errors are found, throw the big red box.
+ if ($error_txt) {
+ echo "<tr><td colspan=\"5\">&nbsp;</td>";
+ echo "<tr><td colspan=\"5\">";
+ print_input_errors($error_txt);
+ echo "</td></tr>";
+ } else
+ echo "<tr><td>&nbsp;</td></tr>";
+
+ echo <<<EOFAMBACBAF
+
+ <tr><td colspan='5' align="center"><b>Boot manager: {$bootmanagerupper}</td></tr>
+ <tr><td>&nbsp;</td></tr>
+ <tr>
+ <td align='left'>
+ <b>Mount point</b>
+ </td>
+ <td align='left'>
+ <b>Filesysytem type</b>
+ </td>
+ <td align='left'>
+ <b>Disk</b>
+ </td>
+ <td align='left'>
+ <b>Size</b>
+ </td>
+ <td align='left'>
+ <b>Encryption password</b>
+ </td>
+ </tr>
+ <tr><td colspan='5'><hr></td></tr>
+
+EOFAMBACBAF;
+
+ foreach($disks as $disk) {
+ $desc = pcsysinstall_get_disk_info($disk['disk']);
+ echo "<tr>";
+ echo "<td>&nbsp;&nbsp;&nbsp;{$disk['mountpoint']}</td>";
+ echo "<td>{$disk['fstype']}</td>";
+ echo "<td>{$disk['disk']} {$desc['desc']}</td>";
+ echo "<td>{$disk['size']}</td>";
+ echo "<td>{$disk['encpass']}</td>";
+ echo "</tr>";
+ }
+
+echo <<<EOFAMB
+ <tr><td colspan="5"><hr></td></tr>
</table>
</div>
</center>
@@ -471,20 +571,29 @@ function verify_before_install() {
</div>
<center>
<p/>
- <input type="button" value="Cancel" onClick="javascript:document.location='/installer.php';"> &nbsp;&nbsp;
- <input type="submit" value="Begin installation">
+ <input type="button" value="Cancel" onClick="javascript:document.location='installer.php?state=custominstall';"> &nbsp;&nbsp;
+EOFAMB;
+ if(!$error_txt)
+ echo "<input type=\"submit\" value=\"Begin installation\"> <br/>&nbsp;";
+echo <<<EOFAMBASDF
+
</center>
</td>
</tr>
</table>
</div>
-EOF;
+EOFAMBASDF;
+
+
page_table_end();
end_html();
+ write_out_pc_sysinstaller_config($disks, $bootmanager);
+ file_put_contents("/tmp/webInstaller_disk_layout.txt", serialize($disks));
+ file_put_contents("/tmp/webInstaller_disk_bootmanager.txt", serialize($bootmanager));
}
function installing_gui() {
- global $g, $fstype;
+ global $g, $fstype, $savemsg;
head_html();
body_html();
echo "<form action=\"installer.php\" method=\"post\" state=\"step1_post\">";
@@ -519,16 +628,16 @@ function installing_gui() {
<center>
<table id='pbtable' height='15' width='640' border='0' colspacing='0' cellpadding='0' cellspacing='0'>
<tr>
- <td background="./themes/the_wall/images/misc/bar_left.gif" height='15' width='5'>
+ <td background="/themes/the_wall/images/misc/bar_left.gif" height='15' width='5'>
</td>
<td>
<table id="progholder" name="progholder" height='15' width='630' border='0' colspacing='0' cellpadding='0' cellspacing='0'>
- <td background="./themes/the_wall/images/misc/bar_gray.gif" valign="top" align="left">
- <img src='./themes/the_wall/images/misc/bar_blue.gif' width='0' height='15' name='progressbar' id='progressbar'>
+ <td background="/themes/the_wall/images/misc/bar_gray.gif" valign="top" align="left">
+ <img src='/themes/the_wall/images/misc/bar_blue.gif' width='0' height='15' name='progressbar' id='progressbar'>
</td>
</table>
</td>
- <td background="./themes/the_wall/images/misc/bar_right.gif" height='15' width='5'>
+ <td background="/themes/the_wall/images/misc/bar_right.gif" height='15' width='5'>
</td>
</tr>
</table>
@@ -555,17 +664,19 @@ EOF;
end_html();
}
-function page_table_start() {
- global $g, $fstype;
+function page_table_start($pgtitle = "") {
+ global $g, $fstype, $savemsg;
+ if($pgtitle == "")
+ $pgtitle = "{$g['product_name']} installer";
echo <<<EOF
<center>
- <img border="0" src="./themes/{$g['theme']}/images/logo.gif"></a><br/>
- <table cellpadding="6" cellspacing="0" width="550" height="380" style="border:1px solid #000000">
+ <img border="0" src="/themes/{$g['theme']}/images/logo.gif"></a><br/>
+ <table cellpadding="6" cellspacing="0" width="550" style="border:1px solid #000000">
<tr height="10" bgcolor="#990000">
<td style="border-bottom:1px solid #000000">
<font color='white'>
<b>
- {$g['product_name']} installer
+ {$pgtitle}
</b>
</font>
</td>
@@ -578,7 +689,7 @@ EOF;
}
function page_table_end() {
- global $g, $fstype;
+ global $g, $fstype, $savemsg;
echo <<<EOF
</td>
</tr>
@@ -590,13 +701,73 @@ EOF;
}
function installer_custom() {
- global $g, $fstype;
+ global $g, $fstype, $savemsg;
+ global $select_txt, $custom_disks;
if(file_exists("/tmp/.pc-sysinstall/pc-sysinstall.log"))
unlink("/tmp/.pc-sysinstall/pc-sysinstall.log");
head_html();
body_html();
- page_table_start();
+ page_table_start($g['product_name'] . " installer - Customize disk(s) layout");
echo <<<EOF
+ <script type="text/javascript">
+ function row_helper_dynamic_custom() {
+ var totalsize = 0;
+ // Run through all rows and process data
+ for(var x = 0; x<99; x++) { //optimize me better
+ if(\$('fstype' + x)) {
+ var fstype = \$F('fstype' + x);
+ if(fstype.substring(fstype.length - 4) == ".eli") {
+ \$('encpass' + x).disabled = 0;
+ if(!encryption_warning_shown) {
+ alert('NOTE: If you define a disk encryption password you will need to enter it on *EVERY* bootup!');
+ encryption_warning_shown = true;
+ }
+ } else {
+ \$('encpass' + x).disabled = 1;
+ }
+ }
+ // Calculate size allocations
+ if(\$('size' + x)) {
+ if(parseInt($('size' + x).value) > 0)
+ totalsize += parseInt($('size' + x).value);
+ }
+ }
+ // If the totalsize element exists, set it and disable
+ if(\$('totalsize')) {
+ if(\$('totalsize').value != totalsize) {
+ // When size allocation changes, draw attention.
+ new Effect.Highlight('totalsize');
+ \$('totalsize').value = totalsize;
+ }
+ \$('totalsize').disabled = 1;
+ }
+ }
+ </script>
+ <script type="text/javascript" src="/javascript/row_helper_dynamic.js"></script>
+ <script type="text/javascript">
+ // Setup rowhelper data types
+ rowname[0] = "mountpoint";
+ rowtype[0] = "textbox";
+ rowsize[0] = "8";
+ rowname[1] = "fstype";
+ rowtype[1] = "select";
+ rowsize[1] = "1";
+ rowname[2] = "disk";
+ rowtype[2] = "select";
+ rowsize[2] = "1";
+ rowname[3] = "size";
+ rowtype[3] = "textbox";
+ rowsize[3] = "8";
+ rowname[4] = "encpass";
+ rowtype[4] = "textbox";
+ rowsize[4] = "8";
+ field_counter_js = 5;
+ rows = 1;
+ totalrows = 1;
+ loaded = 1;
+ rowhelper_onChange = " onChange='javascript:row_helper_dynamic_custom()' ";
+ rowhelper_onAdd = 'row_helper_dynamic_custom();';
+ </script>
<form action="installer.php" method="post">
<input type="hidden" name="state" value="verify_before_install">
<div id="mainlevel">
@@ -606,7 +777,6 @@ function installer_custom() {
<td>
<center>
<div id="mainarea">
- <br/>
<center>
<table width="100%" border="0" cellpadding="5" cellspacing="5">
<tr>
@@ -614,55 +784,134 @@ function installer_custom() {
<div id="pfsenseinstaller">
<center>
<div id='loadingdiv'>
- <img src="/themes/{$g['theme']}/images/misc/loader.gif"> Probing disks, please wait...
+ <table>
+ <tr>
+ <td valign="center">
+ <img src="/themes/{$g['theme']}/images/misc/loader.gif">
+ </td>
+ <td valign="center">
+ &nbsp;Probing disks, please wait...
+ </td>
+ </tr>
+ </table>
</div>
EOF;
ob_flush();
$disks = installer_find_all_disks();
+ if(file_exists("/tmp/webInstaller_disk_bootmanager.txt"))
+ $bootmanager = unserialize(file_get_contents("/tmp/webInstaller_disk_bootmanager.txt"));
+ if($bootmanager == "none")
+ $noneselected = " SELECTED";
+ if($bootmanager == "bsd")
+ $bsdeselected = " SELECTED";
+
if(!$disks) {
$custom_txt = gettext("ERROR: Could not find any suitable disks for installation.");
} else {
// Prepare disk selection dropdown
$custom_txt = <<<EOF
- <table bgcolor="FFFF00" width="400" height="30" cellpadding="2" style="border:1px dashed;">
- <tr valign="middle">
- <td>
- <center><b>Select the installation parameters for {$g['product_name']}:</b></center>
- </td>
- </tr>
- </table><p/>
+ <center>
<table>
+ <tr>
+ <td align='right'>
+ Boot manager:
+ </td>
+ <td>
+ <select name='bootmanager'>
+ <option value='none' $noneselected>
+ None
+ </option>
+ <option value='bsd' $bsdeselected>
+ BSD
+ </option>
+ </select>
+ </td>
+ </tr>
+ </table>
+ <hr>
+ <table id='maintable'><tbody>
+ <tr>
+ <td align="middle">
+ <b>Mount</b>
+ </td>
+ <td align='middle'>
+ <b>Filesysytem</b>
+ </td>
+ <td align="middle">
+ <b>Disk</b>
+ </td>
+ <td align="middle">
+ <b>Size</b>
+ </td>
+ <td align="middle">
+ <b>Encryption password</b>
+ </td>
+ <td>
+ &nbsp;
+ </td>
+ </tr>
+ <tr>
+
EOF;
- $custom_txt .= "<tr><td align='right'><b>Swap size</td><td><input name='swapsize' type='text' value='200M'></td></tr>\n";
- $custom_txt .= "<tr><td align='right'><b>Disk:</td><td><select name='disk'>\n";
- foreach($disks as $disk) {
- $disksize = format_bytes($disk['size'] * 1048576);
- $custom_txt .= "<option value='{$disk['disk']}'>{$disk['disk']} - {$disksize} - {$disk['desc']}</option>\n";
+
+ // Calculate swap disk sizes
+ $memory = get_memory();
+ $swap_size = $memory[0] * 2;
+ $first_disk = trim(installer_find_first_disk());
+ $disk_info = pcsysinstall_get_disk_info($first_disk);
+ $size = $disk_info['size'];
+ $first_disk_size = $size - $swap_size;
+ // Decreate by 1 megabyte as some disks will fail
+ $first_disk_size--;
+
+ // Debugging
+ echo "\n\n<!-- $first_disk - " . print_r($disk_info, true) . " - $size - $first_disk_size -->\n\n";
+
+ // Check to see if a on disk layout exists
+ if(file_exists("/tmp/webInstaller_disk_layout.txt")) {
+ $disks_restored = unserialize(file_get_contents("/tmp/webInstaller_disk_layout.txt"));
+ $restored_layout_from_file = true;
+ $restored_layout_txt = "<br/>* The previous disk layout was restored from a previous session";
+ }
+
+ // If we restored disk layout(s) from a file then build the rows
+ if($restored_layout_from_file == true) {
+ $diskcounter = 0;
+ foreach($disks_restored as $dr) {
+ $custom_txt .= return_rowhelper_row("$diskcounter", $dr['mountpoint'], $dr['fstype'], $dr['disk'], $dr['size'], $dr['encpass']);
+ $diskcounter++;
+ }
+ } else {
+ // Construct the default rows that outline the disks configuration.
+ $custom_txt .= return_rowhelper_row("0", "/", "UFS", $first_disk, "{$first_disk_size}", "");
+ $custom_txt .= return_rowhelper_row("1", "none", "SWAP", $first_disk, "$swap_size", "");
}
- $custom_txt .= "</select></td></tr>\n";
- // XXX: Convert to rowhelper. Add Ajax callbacks to verify sizes, etc.
- // Prepare disk types
- $custom_txt .= "<tr><td align='right'><b>Filesystem type:</td><td><select name='fstype'>\n";
- $custom_txt .= "<option value='UFS'>UFS</option>\n";
- $custom_txt .= "<option value='UFS+S'>UFS + Softupdates</option>\n";
- $release = trim(`uname -r | cut -d'.' -f1`);
- if($release == "9")
- $custom_txt .= "<option value='UFS+J'>UFS + Journaling</option>\n";
- if(file_exists("/boot/gptzfsboot"))
- $custom_txt .= "<option value='ZFS'>ZFS</option>\n";
- $custom_txt .= "</select>\n</td></tr></table><p/>";
+
+ // tfoot and tbody are used by rowhelper
+ $custom_txt .= "</tr>";
+ $custom_txt .= "<tfoot></tfoot></tbody>";
+ $custom_txt .= "<tr><td></td><td></td><td align='right'>Total allocated:</td><td><input size=\"8\" id='totalsize' name='totalsize'></td></tr>";
+ $custom_txt .= "</table>";
+ $custom_txt .= "<script type=\"text/javascript\">row_helper_dynamic_custom();</script>";
}
echo <<<EOF
+
+ <tr>
+ <td colspan='4'>
<script type="text/javascript">
\$('loadingdiv').style.visibility='hidden';
</script>
<div id='contentdiv' style="display:none;">
+ <p/>
{$custom_txt}<p/>
- <input type="button" value="Cancel" onClick="javascript:document.location='/installer.php';"> &nbsp;&nbsp
+ <hr><p/>
+ <input type="button" value="Cancel" onClick="javascript:document.location='/installer/installer.php';"> &nbsp;&nbsp
<input type="submit" value="Next">
</div>
<script type="text/javascript">
+ var encryption_warning_shown = false;
\$('contentdiv').appear();
+ row_helper_dynamic_custom();
</script>
</center>
</td></tr>
@@ -671,11 +920,33 @@ EOF;
</td>
</tr>
</table>
+ </center>
+ <span class="vexpl">
+ <span class="red">
+ <strong>
+ NOTES:
+ </strong>
+ </span>
+ <br/>* Sizes are in megabytes.
+ <br/>* Encryption password field should only be used if a encrypted filesystem (.eli) was chosen
+ <br/>* Mount points named /conf are not allowed. Use /cf if you want to make a configuration slice/mount.
+ <br/>* Leave at least one megabyte unallocated to avoid errors
+ {$restored_layout_txt}
+ </span>
+ </strong>
</div>
</td>
</tr>
</table>
</div>
+ </center>
+ <script type="text/javascript">
+ <!--
+ newrow[1] = "{$select_txt}";
+ newrow[2] = "{$custom_disks}";
+ -->
+ </script>
+
EOF;
page_table_end();
@@ -683,15 +954,15 @@ EOF;
}
function installer_main() {
- global $g, $fstype;
+ global $g, $fstype, $savemsg;
if(file_exists("/tmp/.pc-sysinstall/pc-sysinstall.log"))
unlink("/tmp/.pc-sysinstall/pc-sysinstall.log");
head_html();
body_html();
$disk = installer_find_first_disk();
// Only enable ZFS if this exists. The install will fail otherwise.
- if(file_exists("/boot/gptzfsboot"))
- $zfs_enabled = "<tr bgcolor=\"#9A9A9A\"><td align=\"center\"><a href=\"installer.php?state=verify_before_install&fstype=ZFS&swapsize=200M\">Easy installation of {$g['product_name']} using the ZFS filesystem on disk {$disk}</a></td></tr>";
+ // if(file_exists("/boot/gptzfsboot"))
+ // $zfs_enabled = "<tr bgcolor=\"#9A9A9A\"><td align=\"center\"><a href=\"installer.php?state=verify_before_install&fstype0=ZFS&size=200M\">Easy installation of {$g['product_name']} using the ZFS filesystem on disk {$disk}</a></td></tr>";
page_table_start();
echo <<<EOF
<form action="installer.php" method="post" state="step1_post">
@@ -724,7 +995,9 @@ EOF;
<table cellspacing="5" cellpadding="5" style="border: 1px dashed;">
<tr bgcolor="#CECECE"><td align="center">
+<!--
<a href="installer.php?state=verify_before_install&disk={$disk}&fstype=UFS&swapsize=200M">Easy installation of {$g['product_name']} using the UFS filesystem on disk {$disk}</a>
+-->
</td></tr>
{$zfs_enabled}
<tr bgcolor="#AAAAAA"><td align="center">
@@ -749,4 +1022,84 @@ EOF;
end_html();
}
+function return_rowhelper_row($rownum, $mountpoint, $fstype, $disk, $size, $encpass) {
+ global $g, $select_txt, $custom_disks, $savemsg;
+ $release = php_uname("r");
+ $release = trim($release[0]);
+
+ // Mount point
+ $disks = installer_find_all_disks();
+ $custom_txt .= "<tr>";
+ $custom_txt .= "<td><input size='8' id='mountpoint{$rownum}' name='mountpoint{$rownum}' value='{$mountpoint}'></td>";
+
+ // Filesystem type array
+ $types = array(
+ 'UFS' => 'UFS',
+ 'UFS+S' => 'UFS + Softupdates',
+ 'UFS.eli' => 'Encrypted UFS',
+ 'UFS+S.eli' => 'Encrypted UFS + Softupdates',
+ 'SWAP' => 'SWAP'
+ );
+
+ // UFS + Journaling was introduced in 9.0
+ if($release == "9") {
+ $types['UFS+J'] = "UFS + Journaling";
+ $types['UFS+J.eli'] = "Encrypted UFS + Journaling";
+ }
+
+ // Add ZFS Boot loader if it exists
+ if(file_exists("/boot/gptzfsboot")) {
+ $types['ZFS'] = "Zetabyte Filesystem";
+ $types['ZFS.eli'] = "Encrypted Zetabyte Filesystem";
+ }
+
+ // fstype form field
+ $custom_txt .= "<td><select onChange='javascript:row_helper_dynamic_custom()' id='fstype{$rownum}' name='fstype{$rownum}'>";
+ $select_txt = "";
+ foreach($types as $type => $desc) {
+ if($type == $fstype)
+ $SELECTED="SELECTED";
+ else
+ $SELECTED="";
+ $select_txt .= "<option value='$type' $SELECTED>$desc</option>";
+ }
+ $custom_txt .= "{$select_txt}</select>\n";
+ $custom_txt .= "</td>";
+
+ // Disk selection form field
+ $custom_txt .= "<td><select id='disk{$rownum}' name='disk{$rownum}'>\n";
+ $custom_disks = "";
+ foreach($disks as $dsk) {
+ $disksize_bytes = format_bytes($dsk['size'] * 1048576);
+ $disksize = $dsk['size'];
+ if($disk == $dsk['disk'])
+ $SELECTED="SELECTED";
+ else
+ $SELECTED="";
+ $custom_disks .= "<option value='{$dsk['disk']}' $SELECTED>{$dsk['disk']} - {$dsk['desc']} - {$disksize}MB ({$disksize_bytes})</option>";
+ }
+ $custom_txt .= "{$custom_disks}</select></td>\n";
+
+ // Slice size
+ $custom_txt .= "<td><input onChange='javascript:row_helper_dynamic_custom();' name='size{$rownum}' id='size{$rownum}' size='8' type='text' value='{$size}'></td>";
+
+ // Encryption password
+ $custom_txt .= "<td>";
+ $custom_txt .= "<input id='encpass{$rownum}' name='encpass{$rownum}' size='8' value='{$encpass}'>";
+ $custom_txt .= "</td>";
+
+ // Add Rowhelper + button
+ if($rownum == 1) {
+ $custom_txt .= "<td>";
+ $custom_txt .= "<div id=\"addrowbutton\">";
+ $custom_txt .= "<a onclick=\"javascript:addRowTo('maintable', 'formfldalias'); return false;\" href=\"#\">";
+ $custom_txt .= "<img border=\"0\" src=\"/themes/{$g['theme']}/images/icons/icon_plus.gif\" alt=\"\" title=\"add another entry\" /></a>";
+ $custom_txt .= "</div>";
+ $custom_txt .= "</td>";
+ }
+
+ $custom_txt .= "</tr>";
+ return $custom_txt;
+}
+
?> \ No newline at end of file
diff --git a/usr/local/www/interfaces.php b/usr/local/www/interfaces.php
index 2a03124..b09690a 100755
--- a/usr/local/www/interfaces.php
+++ b/usr/local/www/interfaces.php
@@ -159,7 +159,7 @@ if ($wancfg['if'] == $a_ppps[$pppid]['if']) {
}
}// End force pppoe reset at specific time
}// End if type == pppoe
- if ($a_ppps[$pppid]['type'] == "pptp"){
+ else if ($a_ppps[$pppid]['type'] == "pptp"){
$pconfig['pptp_username'] = $a_ppps[$pppid]['username'];
$pconfig['pptp_password'] = base64_decode($a_ppps[$pppid]['password']);
$pconfig['pptp_local'] = explode(",",$a_ppps[$pppid]['localip']);
@@ -398,7 +398,7 @@ if ($_POST['apply']) {
if (isset($config['dhcpd']) && isset($config['dhcpd'][$if]['enable']) && (! preg_match("/^static/", $_POST['type'])))
$input_errors[] = gettext("The DHCP Server is active on this interface and it can be used only with a static IP configuration. Please disable the DHCP Server service on this interface first, then change the interface configuration.");
- switch($_POST['type']) {
+ switch(strtolower($_POST['type'])) {
case "staticv4":
$reqdfields = explode(" ", "ipaddr subnet gateway");
$reqdfieldsn = array(gettext("IPv4 address"),gettext("Subnet bit count"),gettext("Gateway"));
@@ -422,8 +422,6 @@ if ($_POST['apply']) {
}
}
case "dhcp":
- if (in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp")))
- $input_errors[] = gettext("You have to reassign the interface to be able to configure as {$_POST['type']}.");
break;
case "dhcpv6":
if (in_array($wancfg['ipaddrv6'], array("ppp", "pppoe", "pptp", "l2tp")))
@@ -434,7 +432,7 @@ if ($_POST['apply']) {
$reqdfieldsn = array(gettext("Modem Port"),gettext("Phone Number"));
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
break;
- case "PPPoE":
+ case "pppoe":
if ($_POST['pppoe_dialondemand']) {
$reqdfields = explode(" ", "pppoe_username pppoe_password pppoe_dialondemand pppoe_idletimeout");
$reqdfieldsn = array(gettext("PPPoE username"),gettext("PPPoE password"),gettext("Dial on demand"),gettext("Idle timeout value"));
@@ -444,7 +442,7 @@ if ($_POST['apply']) {
}
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
break;
- case "PPTP":
+ case "pptp":
if ($_POST['pptp_dialondemand']) {
$reqdfields = explode(" ", "pptp_username pptp_password pptp_local pptp_subnet pptp_remote pptp_dialondemand pptp_idletimeout");
$reqdfieldsn = array(gettext("PPTP username"),gettext("PPTP password"),gettext("PPTP local IP address"),gettext("PPTP subnet"),gettext("PPTP remote IP address"),gettext("Dial on demand"),gettext("Idle timeout value"));
@@ -561,6 +559,12 @@ if ($_POST['apply']) {
}
}
if (!$input_errors) {
+ if ($wancfg['type'] != $_POST['type']) {
+ if (in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp"))) {
+ $wancfg['if'] = $a_ppps[$pppid]['ports'];
+ unset($a_ppps[$pppid]);
+ }
+ }
$ppp = array();
if ($wancfg['ipaddr'] != "ppp")
unset($wancfg['ipaddr']);
@@ -951,7 +955,7 @@ function check_wireless_mode() {
}
}
-$pgtitle = array(gettext("Interfaces"), strtoupper($pconfig['descr']));
+$pgtitle = array(gettext("Interfaces"), $pconfig['descr']);
$statusurl = "status_interfaces.php";
$closehead = false;
diff --git a/usr/local/www/interfaces_assign.php b/usr/local/www/interfaces_assign.php
index fbd6e7f..340ee78 100755
--- a/usr/local/www/interfaces_assign.php
+++ b/usr/local/www/interfaces_assign.php
@@ -302,7 +302,7 @@ if ($_GET['act'] == "del") {
}
}
-if ($_GET['act'] == "add") {
+if ($_GET['act'] == "add" && (count($config['interfaces']) < count($portlist))) {
/* find next free optional interface number */
if(!$config['interfaces']['lan']) {
$newifname = gettext("lan");
@@ -348,7 +348,8 @@ if ($_GET['act'] == "add") {
$savemsg = gettext("Interface has been added.");
-}
+} else if ($_GET['act'] == "add")
+ $input_errors[] = "No more interfaces available to be assigned.";
include("head.inc");
@@ -401,7 +402,7 @@ if(file_exists("/var/run/interface_mismatch_reboot_needed"))
</tr>
<?php foreach ($config['interfaces'] as $ifname => $iface):
if ($iface['descr'])
- $ifdescr = strtoupper($iface['descr']);
+ $ifdescr = $iface['descr'];
else
$ifdescr = strtoupper($ifname);
?>
@@ -414,7 +415,7 @@ if(file_exists("/var/run/interface_mismatch_reboot_needed"))
<?php if ($portinfo['isvlan']) {
$descr = sprintf(gettext('VLAN %1$s on %2$s'),$portinfo['tag'],$portinfo['if']);
if ($portinfo['descr'])
- $descr .= " (" . strtoupper($portinfo['descr']) . ")";
+ $descr .= " (" . $portinfo['descr'] . ")";
echo htmlspecialchars($descr);
} elseif ($portinfo['iswlclone']) {
$descr = $portinfo['cloneif'];
@@ -453,7 +454,7 @@ if(file_exists("/var/run/interface_mismatch_reboot_needed"))
</td>
<td valign="middle" class="list">
<?php if ($ifname != 'wan'): ?>
- <a href="interfaces_assign.php?act=del&id=<?=$ifname;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" title=<?=gettext("delete interface"); ?> width="17" height="17" border="0"></a>
+ <a href="interfaces_assign.php?act=del&id=<?=$ifname;?>" onclick="return confirm('<?=gettext("Do you really want to delete this interface?");?>')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" title=<?=gettext("delete interface"); ?> width="17" height="17" border="0"></a>
<?php endif; ?>
</td>
</tr>
diff --git a/usr/local/www/interfaces_gif_edit.php b/usr/local/www/interfaces_gif_edit.php
index fc21620..ee9157a 100644
--- a/usr/local/www/interfaces_gif_edit.php
+++ b/usr/local/www/interfaces_gif_edit.php
@@ -136,6 +136,9 @@ include("head.inc");
<select name="if" class="formselect">
<?php
$portlist = get_configured_interface_with_descr();
+ $carplist = get_configured_carp_interface_list();
+ foreach ($carplist as $cif => $carpip)
+ $portlist[$cif] = $carpip." (".get_vip_descr($carpip).")";
foreach ($portlist as $ifn => $ifinfo) {
echo "<option value=\"{$ifn}\"";
if ($ifn == $pconfig['if'])
diff --git a/usr/local/www/interfaces_gre_edit.php b/usr/local/www/interfaces_gre_edit.php
index f0f0a84..ce9f324 100644
--- a/usr/local/www/interfaces_gre_edit.php
+++ b/usr/local/www/interfaces_gre_edit.php
@@ -139,6 +139,9 @@ include("head.inc");
<select name="if" class="formselect">
<?php
$portlist = get_configured_interface_with_descr();
+ $carplist = get_configured_carp_interface_list();
+ foreach ($carplist as $cif => $carpip)
+ $portlist[$cif] = $carpip." (".get_vip_descr($carpip).")";
foreach ($portlist as $ifn => $ifinfo) {
echo "<option value=\"{$ifn}\"";
if ($ifn == $pconfig['if'])
diff --git a/usr/local/www/interfaces_groups_edit.php b/usr/local/www/interfaces_groups_edit.php
index adfb102..253be67 100755
--- a/usr/local/www/interfaces_groups_edit.php
+++ b/usr/local/www/interfaces_groups_edit.php
@@ -96,7 +96,6 @@ if ($_POST) {
$ifgroupentry['descr'] = mb_convert_encoding($_POST['descr'],"HTML-ENTITIES","auto");
if (isset($id) && $a_ifgroups[$id] && $_POST['ifname'] != $a_ifgroups[$id]['ifname']) {
-
if (!empty($config['filter']) && is_array($config['filter']['rule'])) {
foreach ($config['filter']['rule'] as $ridx => $rule) {
if (isset($rule['floating'])) {
diff --git a/usr/local/www/interfaces_lagg_edit.php b/usr/local/www/interfaces_lagg_edit.php
index b65597c..b30853b 100644
--- a/usr/local/www/interfaces_lagg_edit.php
+++ b/usr/local/www/interfaces_lagg_edit.php
@@ -47,14 +47,18 @@ $a_laggs = &$config['laggs']['lagg'];
$portlist = get_interface_list();
+$realifchecklist = array();
/* add LAGG interfaces */
if (is_array($config['laggs']['lagg']) && count($config['laggs']['lagg'])) {
- foreach ($config['laggs']['lagg'] as $lagg)
+ foreach ($config['laggs']['lagg'] as $lagg) {
unset($portlist[$lagg['laggif']]);
+ $laggiflist = explode(",", $lagg['members']);
+ foreach ($laggiflist as $tmpif)
+ $realifchecklist[get_real_interface($tmpif)] = $tmpif;
+ }
}
$checklist = get_configured_interface_list(false, true);
-$realifchecklist = array();
foreach ($checklist as $tmpif)
$realifchecklist[get_real_interface($tmpif)] = $tmpif;
@@ -76,7 +80,7 @@ if ($_POST) {
/* input validation */
$reqdfields = explode(" ", "members proto");
- $reqdfieldsn = array(",", gettext("Member interfaces"), gettext("Lagg protocol"));
+ $reqdfieldsn = array(gettext("Member interfaces"), gettext("Lagg protocol"));
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
diff --git a/usr/local/www/javascript/filter_log.js b/usr/local/www/javascript/filter_log.js
index 88be819..d8cffd4 100644
--- a/usr/local/www/javascript/filter_log.js
+++ b/usr/local/www/javascript/filter_log.js
@@ -74,10 +74,6 @@ function update_div_rows(data) {
var isIE = navigator.appName.indexOf('Microsoft') != -1;
var isSafari = navigator.userAgent.indexOf('Safari') != -1;
var isOpera = navigator.userAgent.indexOf('Opera') != -1;
- var rows = $$('.log-entry-mini');
- if (rows.length == 0) {
- rows = $$('.log-entry');
- }
var showanim = 1;
if (isIE) {
showanim = 0;
@@ -89,6 +85,11 @@ function update_div_rows(data) {
}
data = data.slice(startat, data.length);
+ var rows = $$('.log-entry-mini');
+ if (rows.length == 0) {
+ rows = $$('.log-entry');
+ }
+
for(var x=0; x<data.length; x++) {
/* if reverse logging is enabled we need to show the
* records in a reverse order with new items appearing
@@ -96,18 +97,17 @@ function update_div_rows(data) {
*/
if(isReverse == false) {
for (var i = 1; i < rows.length; i++) {
- nextrecord = i - 1;
- rows[nextrecord].innerHTML = rows[i].innerHTML;
+ rows[i-1].innerHTML = rows[i].innerHTML;
}
} else {
- for (var i = rows.length - 2; i > 0; i--) {
- nextrecord = i + 1;
- rows[nextrecord].innerHTML = rows[i].innerHTML;
+ for (var i = rows.length - 1; i > 0; i--) {
+ rows[i].innerHTML = rows[i-1].innerHTML;
}
}
$('firstrow').update(data[x]);
}
}
+
function toggle_pause() {
if(isPaused) {
isPaused = false;
diff --git a/usr/local/www/javascript/row_helper_dynamic.js b/usr/local/www/javascript/row_helper_dynamic.js
index bef6120..30312ba 100755
--- a/usr/local/www/javascript/row_helper_dynamic.js
+++ b/usr/local/www/javascript/row_helper_dynamic.js
@@ -1,14 +1,20 @@
// Global Variables
-var rowname = new Array(99);
-var rowtype = new Array(99);
-var newrow = new Array(99);
-var rowsize = new Array(99);
+var rowname = new Array(99);
+var rowtype = new Array(99);
+var newrow = new Array(99);
+var rowsize = new Array(99);
+
+// Global variables. Set to javascript code
+// that will be eval() after change, add & delete.
+var rowhelper_onChange = '';
+var rowhelper_onAdd = '';
+var rowhelper_onDelete = '';
for (i = 0; i < 99; i++) {
rowname[i] = '';
rowtype[i] = '';
- newrow[i] = '';
- rowsize[i] = '25';
+ newrow[i] = '';
+ rowsize[i] = '25';
}
var field_counter_js = 0;
@@ -30,17 +36,17 @@ var addRowTo = (function() {
if(typeof(rowtype[i]) == 'function') {
td.innerHTML="<INPUT type='hidden' value='" + totalrows +"' name='" + rowname[i] + "_row-" + totalrows + "'></input>" + rowtype[i](rowname[i], objectSize, totalrows) + " ";
} else if(rowtype[i] == 'textbox') {
- td.innerHTML="<INPUT type='hidden' value='" + totalrows +"' name='" + rowname[i] + "_row-" + totalrows + "'></input><input size='" + objectSize + "' name='" + rowname[i] + totalrows + "' id='" + rowname[i] + totalrows + "'></input> ";
+ td.innerHTML="<INPUT type='hidden' value='" + totalrows +"' name='" + rowname[i] + "_row-" + totalrows + "'></input><input " + rowhelper_onChange + " size='" + rowsize[i] + "' name='" + rowname[i] + totalrows + "' id='" + rowname[i] + totalrows + "'></input> ";
} else if(rowtype[i] == 'select') {
- td.innerHTML="<INPUT type='hidden' value='" + totalrows +"' name='" + rowname[i] + "_row-" + totalrows + "'></input><select name='" + rowname[i] + totalrows + "' id='" + rowname[i] + totalrows + "'>" + newrow[i] + "</select> ";
+ td.innerHTML="<INPUT type='hidden' value='" + totalrows +"' name='" + rowname[i] + "_row-" + totalrows + "'></input><select " + rowhelper_onChange + " name='" + rowname[i] + totalrows + "' id='" + rowname[i] + totalrows + "'>" + newrow[i] + "</select> ";
} else if(rowtype[i] == 'select_source') {
- td.innerHTML="<INPUT type='hidden' value='" + totalrows +"' name='" + rowname[i] + "_row-" + totalrows + "'></input><select name='" + rowname[i] + totalrows + "' id='" + rowname[i] + totalrows + "'>" + newrow[i] + "</select> ";
+ td.innerHTML="<INPUT type='hidden' value='" + totalrows +"' name='" + rowname[i] + "_row-" + totalrows + "'></input><select " + rowhelper_onChange + " name='" + rowname[i] + totalrows + "' id='" + rowname[i] + totalrows + "'>" + newrow[i] + "</select> ";
} else if(rowtype[i] == 'checkbox') {
- td.innerHTML="<INPUT type='hidden' value='" + totalrows +"' name='" + rowname[i] + "_row-" + totalrows + "'></input><input type='checkbox'name='" + rowname[i] + totalrows + "' id='" + rowname[i] + totalrows + "'></input> ";
+ td.innerHTML="<INPUT type='hidden' value='" + totalrows +"' name='" + rowname[i] + "_row-" + totalrows + "'></input><input " + rowhelper_onChange + " type='checkbox'name='" + rowname[i] + totalrows + "' id='" + rowname[i] + totalrows + "'></input> ";
} else if(rowtype[i] == 'input') {
- td.innerHTML="<INPUT type='hidden' value='" + totalrows +"' name='" + rowname[i] + "_row-" + totalrows + "'></input><input class='formfld unknown' size='" + objectSize + "' name='" + rowname[i] + totalrows + "' id='" + rowname[i] + totalrows + "'></input> ";
+ td.innerHTML="<INPUT type='hidden' value='" + totalrows +"' name='" + rowname[i] + "_row-" + totalrows + "'></input><input " + rowhelper_onChange + " class='formfld unknown' size='" + objectSize + "' name='" + rowname[i] + totalrows + "' id='" + rowname[i] + totalrows + "'></input> ";
} else if(rowtype[i] == 'password') {
- td.innerHTML="<INPUT type='hidden' value='" + totalrows +"' name='" + rowname[i] + "_row-" + totalrows + "'></input><input class='formfld pwd' type='password' name='" + rowname[i] + totalrows + "' id='" + rowname[i] + totalrows + "'></input> ";
+ td.innerHTML="<INPUT type='hidden' value='" + totalrows +"' name='" + rowname[i] + "_row-" + totalrows + "'></input><input " + rowhelper_onChange + " class='formfld pwd' type='password' name='" + rowname[i] + totalrows + "' id='" + rowname[i] + totalrows + "'></input> ";
}
tr.appendChild(td);
}
@@ -49,6 +55,8 @@ var addRowTo = (function() {
td.innerHTML = '<a onclick="removeRow(this); return false;" href="#"><img border="0" src="/themes/' + theme + '/images/icons/icon_x.gif" /></a>';
tr.appendChild(td);
tbody.appendChild(tr);
+ if(rowhelper_onAdd != '')
+ eval(rowhelper_onAdd);
});
})();
@@ -61,6 +69,8 @@ function removeRow(el) {
cel = el.getElementsByTagName("td").item(0);
el.parentNode.removeChild(el);
}
+ if(rowhelper_onDelete != '')
+ eval(rowhelper_onDelete);
}
function find_unique_field_name(field_name) {
diff --git a/usr/local/www/load_balancer_pool_edit.php b/usr/local/www/load_balancer_pool_edit.php
index 51b3bec..08e7fdc 100755
--- a/usr/local/www/load_balancer_pool_edit.php
+++ b/usr/local/www/load_balancer_pool_edit.php
@@ -56,6 +56,7 @@ if (isset($id) && $a_pool[$id]) {
$pconfig['mode'] = $a_pool[$id]['mode'];
$pconfig['descr'] = $a_pool[$id]['descr'];
$pconfig['port'] = $a_pool[$id]['port'];
+ $pconfig['retry'] = $a_pool[$id]['retry'];
$pconfig['servers'] = &$a_pool[$id]['servers'];
$pconfig['serversdisabled'] = &$a_pool[$id]['serversdisabled'];
$pconfig['monitor'] = $a_pool[$id]['monitor'];
@@ -86,6 +87,11 @@ if ($_POST) {
if (!is_port($_POST['port']))
$input_errors[] = gettext("The port must be an integer between 1 and 65535.");
+
+ // May as well use is_port as we want a positive integer and such.
+ if (!empty($_POST['retry']) && !is_port($_POST['retry']))
+ $input_errors[] = gettext("The retry value must be an integer between 1 and 65535.");
+
if (is_array($_POST['servers'])) {
foreach($pconfig['servers'] as $svrent) {
if (!is_ipaddr($svrent)) {
@@ -118,6 +124,7 @@ if ($_POST) {
update_if_changed("mode", $poolent['mode'], $_POST['mode']);
update_if_changed("description", $poolent['descr'], $_POST['descr']);
update_if_changed("port", $poolent['port'], $_POST['port']);
+ update_if_changed("retry", $poolent['retry'], $_POST['retry']);
update_if_changed("servers", $poolent['servers'], $_POST['servers']);
update_if_changed("serversdisabled", $poolent['serversdisabled'], $_POST['serversdisabled']);
update_if_changed("monitor", $poolent['monitor'], $_POST['monitor']);
@@ -199,6 +206,13 @@ function clearcombo(){
<div id="monitorport_desc"><?=gettext("This is the port your servers are listening on."); ?></div>
</td>
</tr>
+ <tr align="left">
+ <td width="22%" valign="top" id="retry_text" class="vncell"><?=gettext("Retry"); ?></td>
+ <td width="78%" class="vtable" colspan="2">
+ <input name="retry" type="text" <?if(isset($pconfig['retry'])) echo "value=\"{$pconfig['retry']}\"";?> size="16" maxlength="16"><br>
+ <div id="retry_desc"><?=gettext("Optionally specify how many times to retry checking a server before declaring it down."); ?></div>
+ </td>
+ </tr>
<tr>
<td>&nbsp;</td>
</tr>
diff --git a/usr/local/www/pkg_edit.php b/usr/local/www/pkg_edit.php
index 52bc31a..8b71837 100755
--- a/usr/local/www/pkg_edit.php
+++ b/usr/local/www/pkg_edit.php
@@ -84,17 +84,16 @@ $id = $_GET['id'];
if (isset($_POST['id']))
$id = htmlspecialchars($_POST['id']);
-if(!is_numeric($id)) {
- Header("Location: /");
- exit;
-}
-
-
// Not posting? Then user is editing a record. There must be a valid id
// when editing a record.
if(!$id && !$_POST)
$id = "0";
-
+
+if(!is_numeric($id)) {
+ Header("Location: /");
+ exit;
+}
+
if($pkg['custom_php_global_functions'] <> "")
eval($pkg['custom_php_global_functions']);
diff --git a/usr/local/www/pkg_mgr_install.php b/usr/local/www/pkg_mgr_install.php
index 5c6ae56..3424621 100755
--- a/usr/local/www/pkg_mgr_install.php
+++ b/usr/local/www/pkg_mgr_install.php
@@ -145,14 +145,16 @@ switch($_GET['mode']) {
delete_package_xml(htmlspecialchars($_GET['pkg']));
if (install_package(htmlspecialchars($_GET['pkg'])) < 0) {
update_status(gettext("Package reinstallation failed."));
- $static_output .= "\n\n" . gettext("Package reinstallation failed.");
+ $static_output .= "\n" . gettext("Package reinstallation failed.");
update_output_window($static_output);
} else {
update_status(gettext("Package reinstalled."));
- $static_output .= "\n\n" . gettext("Package reinstalled.");
+ $static_output .= "\n" . gettext("Package reinstalled.");
update_output_window($static_output);
filter_configure();
}
+ file_put_contents("/tmp{$_GET['pkg']}.info", $static_output);
+ echo "<script type='text/javascript'>document.location=\"pkg_mgr_install.php?mode=installedinfo&pkg={$_GET['pkg']}\";</script>";
break;
case "installedinfo":
if(file_exists("/tmp/{$_GET['pkg']}.info")) {
@@ -180,7 +182,7 @@ switch($_GET['mode']) {
}
}
update_status(gettext("All packages reinstalled."));
- $static_output .= "\n\n" . gettext("All packages reinstalled.");
+ $static_output .= "\n" . gettext("All packages reinstalled.");
update_output_window($static_output);
filter_configure();
break;
@@ -188,21 +190,18 @@ switch($_GET['mode']) {
$status = install_package(htmlspecialchars($_GET['id']));
if($status == -1) {
update_status(gettext("Installation of") . " " . htmlspecialchars($_GET['id']) . " " . gettext("FAILED!"));
- $static_output .= "\n\n" . gettext("Installation halted.");
+ $static_output .= "\n" . gettext("Installation halted.");
update_output_window($static_output);
} else {
- $filename = escapeshellcmd("/tmp/" . $_GET['id'] . ".info");
- $fd = fopen($filename, "w");
$status_a = gettext("Installation of") . " " . htmlspecialchars($_GET['id']) . " " . gettext("completed.");
update_status($status_a);
$status = get_after_install_info($_GET['id']);
if($status)
- $static_output .= "\n" . gettext("Installation completed.") . "\n\n{$_GET['id']} " . gettext("setup instructions") . ":\n\n{$status}";
+ $static_output .= "\n" . gettext("Installation completed.") . "\n{$_GET['id']} " . gettext("setup instructions") . ":\n{$status}";
else
$static_output .= "\n" . gettext("Installation completed. Please check to make sure that the package is configured from the respective menu then start the package.");
- fwrite($fd, $status_a . "\n\n". $static_output);
- fclose($fd);
- echo "<script type='text/javascript'>document.location=\"pkg_mgr_install.php?mode=installedinfo&pkg={$_GET['id']}\";</script>";
+ file_put_contents("/tmp/{$_GET['id']}.info", $static_output);
+ echo "<script type='text/javascript'>document.location=\"pkg_mgr_install.php?mode=installedinfo&pkg={$_GET['id']}\";</script>";
}
filter_configure();
break;
@@ -214,7 +213,7 @@ rmdir_recursive("/var/tmp/instmp*");
// close log
if($fd_log)
- fclose($fd_log);
+ fclose($fd_log);
/* read only fs */
conf_mount_ro();
diff --git a/usr/local/www/services_captiveportal_vouchers.php b/usr/local/www/services_captiveportal_vouchers.php
index c79b84d..680a9e1 100644
--- a/usr/local/www/services_captiveportal_vouchers.php
+++ b/usr/local/www/services_captiveportal_vouchers.php
@@ -77,7 +77,7 @@ if (!isset($config['voucher']['rollbits']))
if (!isset($config['voucher']['ticketbits']))
$config['voucher']['ticketbits'] = 10;
if (!isset($config['voucher']['saveinterval']))
- $config['voucher']['saveinterval'] = 300;
+ $config['voucher']['saveinterval'] = 5;
if (!isset($config['voucher']['checksumbits']))
$config['voucher']['checksumbits'] = 5;
if (!isset($config['voucher']['magic']))
diff --git a/usr/local/www/services_dhcp.php b/usr/local/www/services_dhcp.php
index e6c3f68..3f922d4 100755
--- a/usr/local/www/services_dhcp.php
+++ b/usr/local/www/services_dhcp.php
@@ -265,21 +265,21 @@ if ($_POST) {
foreach ($pconfig['numberoptions']['item'] as $numberoption) {
if ( $numberoption['type'] == 'text' && strstr($numberoption['value'], '"') )
$input_errors[] = gettext("Text type cannot include quotation marks.");
- else if ( $numberoption['type'] == 'string' && !preg_match('/^"[^"]*"$/', $numberoption['value']) && !preg_match('/^[0-9a-z]{2}(?:\:[0-9a-z]{2})*$/i', $numberoption['value']) )
+ else if ( $numberoption['type'] == 'string' && !preg_match('/^"[^"]*"$/', $numberoption['value']) && !preg_match('/^[0-9a-f]{2}(?:\:[0-9a-f]{2})*$/i', $numberoption['value']) )
$input_errors[] = gettext("String type must be enclosed in quotes like \"this\" or must be a series of octets specified in hexadecimal, separated by colons, like 01:23:45:67:89:ab:cd:ef");
- else if ( $numberoption['type'] == 'flag' && $numberoption['value'] != 'true' && $numberoption['value'] != 'false' && $numberoption['value'] != 'on' && $numberoption['value'] != 'off' )
+ else if ( $numberoption['type'] == 'boolean' && $numberoption['value'] != 'true' && $numberoption['value'] != 'false' && $numberoption['value'] != 'on' && $numberoption['value'] != 'off' )
$input_errors[] = gettext("Boolean type must be true, false, on, or off.");
- else if ( $numberoption['type'] == 'uint8' && (!is_numeric($numberoption['value']) || $numberoption['value'] < 0 || $numberoption['value'] > 255) )
+ else if ( $numberoption['type'] == 'unsigned integer 8' && (!is_numeric($numberoption['value']) || $numberoption['value'] < 0 || $numberoption['value'] > 255) )
$input_errors[] = gettext("Unsigned 8-bit integer type must be a number in the range 0 to 255.");
- else if ( $numberoption['type'] == 'uint16' && (!is_numeric($numberoption['value']) || $numberoption['value'] < 0 || $numberoption['value'] > 65535) )
+ else if ( $numberoption['type'] == 'unsigned integer 16' && (!is_numeric($numberoption['value']) || $numberoption['value'] < 0 || $numberoption['value'] > 65535) )
$input_errors[] = gettext("Unsigned 16-bit integer type must be a number in the range 0 to 65535.");
- else if ( $numberoption['type'] == 'uint32' && (!is_numeric($numberoption['value']) || $numberoption['value'] < 0 || $numberoption['value'] > 4294967295) )
+ else if ( $numberoption['type'] == 'unsigned integer 32' && (!is_numeric($numberoption['value']) || $numberoption['value'] < 0 || $numberoption['value'] > 4294967295) )
$input_errors[] = gettext("Unsigned 32-bit integer type must be a number in the range 0 to 4294967295.");
- else if ( $numberoption['type'] == 'int8' && (!is_numeric($numberoption['value']) || $numberoption['value'] < -128 || $numberoption['value'] > 127) )
+ else if ( $numberoption['type'] == 'signed integer 8' && (!is_numeric($numberoption['value']) || $numberoption['value'] < -128 || $numberoption['value'] > 127) )
$input_errors[] = gettext("Signed 8-bit integer type must be a number in the range -128 to 127.");
- else if ( $numberoption['type'] == 'int16' && (!is_numeric($numberoption['value']) || $numberoption['value'] < -32768 || $numberoption['value'] > 32767) )
+ else if ( $numberoption['type'] == 'signed integer 16' && (!is_numeric($numberoption['value']) || $numberoption['value'] < -32768 || $numberoption['value'] > 32767) )
$input_errors[] = gettext("Signed 16-bit integer type must be a number in the range -32768 to 32767.");
- else if ( $numberoption['type'] == 'int32' && (!is_numeric($numberoption['value']) || $numberoption['value'] < -2147483648 || $numberoption['value'] > 2147483647) )
+ else if ( $numberoption['type'] == 'signed integer 32' && (!is_numeric($numberoption['value']) || $numberoption['value'] < -2147483648 || $numberoption['value'] > 2147483647) )
$input_errors[] = gettext("Signed 32-bit integer type must be a number in the range -2147483648 to 2147483647.");
else if ( $numberoption['type'] == 'ip-address' && !is_ipaddr($numberoption['value']) && !is_hostname($numberoption['value']) )
$input_errors[] = gettext("IP address or host type must be an IP address or host name.");
@@ -305,13 +305,15 @@ if ($_POST) {
$dynsubnet_start = ip2ulong($_POST['range_from']);
$dynsubnet_end = ip2ulong($_POST['range_to']);
- foreach ($a_maps as $map) {
- if (empty($map['ipaddr']))
- continue;
- if ((ip2ulong($map['ipaddr']) > $dynsubnet_start) &&
- (ip2ulong($map['ipaddr']) < $dynsubnet_end)) {
- $input_errors[] = sprintf(gettext("The DHCP range cannot overlap any static DHCP mappings."));
- break;
+ if (is_array($a_maps)) {
+ foreach ($a_maps as $map) {
+ if (empty($map['ipaddr']))
+ continue;
+ if ((ip2ulong($map['ipaddr']) > $dynsubnet_start) &&
+ (ip2ulong($map['ipaddr']) < $dynsubnet_end)) {
+ $input_errors[] = sprintf(gettext("The DHCP range cannot overlap any static DHCP mappings."));
+ break;
+ }
}
}
}
@@ -429,9 +431,9 @@ include("head.inc");
<script type="text/javascript">
function itemtype_field(fieldname, fieldsize, n) {
return '<select name="' + fieldname + n + '" class="formselect" id="' + fieldname + n + '"><?php
- $customitemtypes = array('text' => gettext('Text'), 'string' => gettext('String'), 'flag' => gettext('Boolean'),
- 'uint8' => gettext('Unsigned 8-bit integer'), 'uint16' => gettext('Unsigned 16-bit integer'), 'uint32' => gettext('Unsigned 32-bit integer'),
- 'int8' => gettext('Signed 8-bit integer'), 'int16' => gettext('Signed 16-bit integer'), 'int32' => gettext('Signed 32-bit integer'), 'ip-address' => gettext('IP address or host'));
+ $customitemtypes = array('text' => gettext('Text'), 'string' => gettext('String'), 'boolean' => gettext('Boolean'),
+ 'unsigned integer 8' => gettext('Unsigned 8-bit integer'), 'unsigned integer 16' => gettext('Unsigned 16-bit integer'), 'unsigned integer 32' => gettext('Unsigned 32-bit integer'),
+ 'signed integer 8' => gettext('Signed 8-bit integer'), 'signed integer 16' => gettext('Signed 16-bit integer'), 'signed integer 32' => gettext('Signed 32-bit integer'), 'ip-address' => gettext('IP address or host'));
foreach ($customitemtypes as $typename => $typedescr) {
echo "<option value=\"{$typename}\">{$typedescr}</option>";
}
diff --git a/usr/local/www/services_dhcp_relay.php b/usr/local/www/services_dhcp_relay.php
index c8e918c..37a9837 100755
--- a/usr/local/www/services_dhcp_relay.php
+++ b/usr/local/www/services_dhcp_relay.php
@@ -130,12 +130,17 @@ function enable_change(enable_over) {
<td>
<div id="mainarea">
<table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
<?php
- if ($dhcpd_enabled):
- echo gettext("DHCP Server is currently enabled. Cannot enable the DHCP Relay service while the DHCP Server is enabled on any interface.");
- else:
+ if ($dhcpd_enabled) {
+ echo "<td>DHCP Server is currently enabled. Cannot enable the DHCP Relay service while the DHCP Server is enabled on any interface.";
+ echo "</td></tr></table></div></td></tr></table></body>";
+ echo "</html>";
+ include("fend.inc");
+ exit;
+ }
?>
- <tr>
+
<td colspan="2" valign="top" class="listtopic"><?=gettext("DHCP Relay configuration"); ?></td>
</tr>
<tr>
@@ -184,7 +189,6 @@ function enable_change(enable_over) {
<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" onclick="enable_change(true)">
</td>
</tr>
-<?php endif; ?>
</table>
</div>
</td>
diff --git a/usr/local/www/services_dyndns.php b/usr/local/www/services_dyndns.php
index c1a25d4..c6939d7 100755
--- a/usr/local/www/services_dyndns.php
+++ b/usr/local/www/services_dyndns.php
@@ -114,21 +114,21 @@ include("head.inc");
</td>
<td class="listlr">
<?php
- $types = explode(",", "DNS-O-Matic, DynDNS (dynamic),DynDNS (static),DynDNS (custom),DHS,DyNS,easyDNS,No-IP,ODS.org,ZoneEdit,Loopia,freeDNS, DNSexit, OpenDNS, Namecheap");
- $vals = explode(" ", "dnsomatic dyndns dyndns-static dyndns-custom dhs dyns easydns noip ods zoneedit loopia freedns dnsexit opendns namecheap");
- $j = 0; for ($j = 0; $j < count($vals); $j++)
- if ($vals[$j] == $dyndns['type']) {
- echo htmlspecialchars($types[$j]);
- break;
- }
- ?>
+ $types = explode(",", "DNS-O-Matic, DynDNS (dynamic),DynDNS (static),DynDNS (custom),DHS,DyNS,easyDNS,No-IP,ODS.org,ZoneEdit,Loopia,freeDNS, DNSexit, OpenDNS, Namecheap");
+ $vals = explode(" ", "dnsomatic dyndns dyndns-static dyndns-custom dhs dyns easydns noip ods zoneedit loopia freedns dnsexit opendns namecheap");
+ $j = 0; for ($j = 0; $j < count($vals); $j++)
+ if ($vals[$j] == $dyndns['type']) {
+ echo htmlspecialchars($types[$j]);
+ break;
+ }
+ ?>
</td>
<td class="listr">
<?=htmlspecialchars($dyndns['host']);?>
</td>
<td class="listlr">
<?php
- $filename = "{$g['conf_path']}/dyndns_{$if}{$dyndns['type']}.cache";
+ $filename = "{$g['conf_path']}/dyndns_{$if}{$dyndns['type']}" . escapeshellarg($dyndns['host']) . ".cache";
$ipaddr = dyndnsCheckIP($if);
if(file_exists($filename)) {
$cached_ip_s = split(":", file_get_contents($filename));
diff --git a/usr/local/www/services_dyndns_edit.php b/usr/local/www/services_dyndns_edit.php
index 7d3072c..9ff0f22 100644
--- a/usr/local/www/services_dyndns_edit.php
+++ b/usr/local/www/services_dyndns_edit.php
@@ -117,7 +117,7 @@ if ($_POST) {
conf_mount_rw();
- mwexec("/bin/rm {$g['conf_path']}/dyndns_{$dyndns['interface']}{$dyndns['type']}.cache");
+ unlink("{$g['conf_path']}/dyndns_{$dyndns['interface']}{$dyndns['type']}{$dyndns['host']}.cache");
$retval = services_dyndns_configure_client($dyndns);
diff --git a/usr/local/www/services_snmp.php b/usr/local/www/services_snmp.php
index 0b61bbf..432db3d 100755
--- a/usr/local/www/services_snmp.php
+++ b/usr/local/www/services_snmp.php
@@ -162,6 +162,12 @@ include("head.inc");
?>
<script language="JavaScript">
<!--
+function check_deps() {
+ if ($('hostres').checked == true) {
+ $('mibii').checked = true;
+ }
+}
+
function enable_change(whichone) {
if( whichone.name == "trapenable" )
@@ -369,13 +375,13 @@ function enable_change(whichone) {
<tr>
<td width="22%" valign="top" class="vncellreq"><?=gettext("SNMP Modules");?></td>
<td width="78%" class="vtable">
- <input name="mibii" type="checkbox" id="mibii" value="yes" <?php if ($pconfig['mibii']) echo "checked"; ?> ><?=gettext("MibII"); ?>
+ <input name="mibii" type="checkbox" id="mibii" value="yes" onClick="check_deps()" <?php if ($pconfig['mibii']) echo "checked"; ?> ><?=gettext("MibII"); ?>
<br />
<input name="netgraph" type="checkbox" id="netgraph" value="yes" <?php if ($pconfig['netgraph']) echo "checked"; ?> ><?=gettext("Netgraph"); ?>
<br />
<input name="pf" type="checkbox" id="pf" value="yes" <?php if ($pconfig['pf']) echo "checked"; ?> ><?=gettext("PF"); ?>
<br />
- <input name="hostres" type="checkbox" id="hostres" value="yes" <?php if ($pconfig['hostres']) echo "checked"; ?> ><?=gettext("Host Resources");?>
+ <input name="hostres" type="checkbox" id="hostres" value="yes" onClick="check_deps()" <?php if ($pconfig['hostres']) echo "checked"; ?> ><?=gettext("Host Resources (Requires MibII)");?>
</td>
</tr>
<?php if(!$config['interfaces']['lan']): ?>
diff --git a/usr/local/www/status_graph.php b/usr/local/www/status_graph.php
index a68b6bd..4527a71 100755
--- a/usr/local/www/status_graph.php
+++ b/usr/local/www/status_graph.php
@@ -174,7 +174,7 @@ if (isset($config['ipsec']['enable']) || isset($config['ipsec']['mobileclients']
foreach ($ifdescrs as $ifn => $ifd) {
echo "<option value=\"$ifn\"";
if ($ifn == $curif) echo " selected";
- echo ">" . strtoupper(htmlspecialchars($ifd)) . " (" . strtoupper($ifn) . ")</option>\n";
+ echo ">" . htmlspecialchars($ifd) . "</option>\n";
}
?>
</select>
@@ -184,8 +184,8 @@ foreach ($ifdescrs as $ifn => $ifd) {
<p>
<div id="niftyOutter">
<div id="col1" style="float: left; width: 46%; padding: 5px; position: relative;">
- <object data="graph.php?ifnum=<?=htmlspecialchars($curif);?>&ifname=<?=strtoupper(rawurlencode($ifdescrs[htmlspecialchars($curif)]));?>" type="image/svg+xml" width="<?=$width;?>" height="<?=$height;?>">
- <param name="src" value="graph.php?ifnum=<?=htmlspecialchars($curif);?>&ifname=<?=strtoupper(rawurlencode($ifdescrs[htmlspecialchars($curif)]));?>" />
+ <object data="graph.php?ifnum=<?=htmlspecialchars($curif);?>&ifname=<?=rawurlencode($ifdescrs[htmlspecialchars($curif)]);?>" type="image/svg+xml" width="<?=$width;?>" height="<?=$height;?>">
+ <param name="src" value="graph.php?ifnum=<?=htmlspecialchars($curif);?>&ifname=<?=rawurlencode($ifdescrs[htmlspecialchars($curif)]);?>" />
<?=gettext("Your browser does not support the type SVG! You need to either use Firefox or download the Adobe SVG plugin"); ?>.
</object>
</div>
diff --git a/usr/local/www/status_lb_pool.php b/usr/local/www/status_lb_pool.php
index 16f474b..b7d79ce 100755
--- a/usr/local/www/status_lb_pool.php
+++ b/usr/local/www/status_lb_pool.php
@@ -43,6 +43,7 @@ require_once("guiconfig.inc");
require_once("functions.inc");
require_once("filter.inc");
require_once("shaper.inc");
+require_once("vslb.inc");
if (!is_array($config['load_balancer']['lbpool'])) {
$config['load_balancer']['lbpool'] = array();
@@ -61,21 +62,7 @@ $year = date("Y");
$pgtitle = array(gettext("Status"),gettext("Load Balancer"),gettext("Pool"));
include("head.inc");
-$relayctl=split("\n", shell_exec("/usr/local/sbin/relayctl show summary"));
-$relay_hosts=Array();
-foreach( (array) $relayctl as $line) {
- $t=split("\t", $line);
- switch (trim($t[1])) {
- case "table":
- $curpool=trim($t[2]);
- break;
- case "host":
- $curhost=trim($t[2]);
- $relay_hosts[$curpool][$curhost]['avail']=trim($t[3]);
- $relay_hosts[$curpool][$curhost]['state']=trim($t[4]);
- break;
- }
-}
+$relay_hosts = get_lb_summary();
if ($_POST) {
if ($_POST['apply']) {
diff --git a/usr/local/www/status_lb_vs.php b/usr/local/www/status_lb_vs.php
index bab9976..33ad6e3 100755
--- a/usr/local/www/status_lb_vs.php
+++ b/usr/local/www/status_lb_vs.php
@@ -40,7 +40,8 @@
##|*MATCH=status_lb_vs.php*
##|-PRIV
-require("guiconfig.inc");
+require_once("guiconfig.inc");
+require_once("vslb.inc");
if (!is_array($config['load_balancer']['lbpool'])) {
$config['load_balancer']['lbpool'] = array();
@@ -50,63 +51,7 @@ if (!is_array($config['load_balancer']['virtual_server'])) {
}
$a_vs = &$config['load_balancer']['virtual_server'];
$a_pool = &$config['load_balancer']['lbpool'];
-
-
-
-// # relayctl show summary
-// Id Type Name Avlblty Status
-// 1 redirect testvs2 active
-// 5 table test2:80 active (3 hosts up)
-// 11 host 192.168.1.2 91.55% up
-// 10 host 192.168.1.3 100.00% up
-// 9 host 192.168.1.4 88.73% up
-// 3 table test:80 active (1 hosts up)
-// 7 host 192.168.1.2 66.20% down
-// 6 host 192.168.1.3 97.18% up
-// 0 redirect testvs active
-// 3 table test:80 active (1 hosts up)
-// 7 host 192.168.1.2 66.20% down
-// 6 host 192.168.1.3 97.18% up
-// 4 table testvs-sitedown:80 active (1 hosts up)
-// 8 host 192.168.1.4 84.51% up
-// # relayctl show redirects
-// Id Type Name Avlblty Status
-// 1 redirect testvs2 active
-// 0 redirect testvs active
-// # relayctl show redirects
-// Id Type Name Avlblty Status
-// 1 redirect testvs2 active
-// total: 2 sessions
-// last: 2/60s 2/h 2/d sessions
-// average: 1/60s 0/h 0/d sessions
-// 0 redirect testvs active
-
-$redirects_a = array();
-exec('/usr/local/sbin/relayctl show redirects 2>&1', $redirects_a);
-$summary_a = array();
-exec('/usr/local/sbin/relayctl show summary 2>&1', $summary_a);
-$rdr_a = parse_redirects($redirects_a);
-//$server_a = parse_summary($summary_a, parse_redirects($redirects_a));
-
-function parse_redirects($rdr_a) {
- $vs = array();
- for ($i = 0; isset($rdr_a[$i]); $i++) {
- $line = $rdr_a[$i];
- if (preg_match("/^[0-9]+/", $line)) {
- $regs = array();
- if($x = preg_match("/^[0-9]+\s+redirect\s+([0-9a-zA-Z\s]+)\s+([a-z]+)/", $line, $regs)) {
- $vs[trim($regs[1])] = array();
- $vs[trim($regs[1])]['status'] = trim($regs[2]);
- }
- }
- }
- return $vs;
-}
-
-function parse_summary($summary, $rdrs_a) {
- $server_a = array();
- return $server_a;
-}
+$rdr_a = get_lb_redirects();
$pgtitle = array(gettext("Status"),gettext("Load Balancer"),gettext("Virtual Server"));
include("head.inc");
diff --git a/usr/local/www/system_advanced_firewall.php b/usr/local/www/system_advanced_firewall.php
index 0a944a9..38d12c1 100644
--- a/usr/local/www/system_advanced_firewall.php
+++ b/usr/local/www/system_advanced_firewall.php
@@ -124,6 +124,11 @@ if ($_POST) {
else
$config['system']['enablebinatreflection'] = "yes";
+ if($_POST['enablenatreflectionhelper'] == "yes")
+ $config['system']['enablenatreflectionhelper'] = "yes";
+ else
+ unset($config['system']['enablenatreflectionhelper']);
+
$config['system']['reflectiontimeout'] = $_POST['reflectiontimeout'];
if($_POST['bypassstaticroutes'] == "yes")
@@ -348,6 +353,15 @@ function update_description(itemnum) {
</td>
</tr>
<tr>
+ <td width="22%" valign="top" class="vncell">&nbsp;</td>
+ <td width="78%" class="vtable">
+ <input name="enablenatreflectionhelper" type="checkbox" id="enablenatreflectionhelper" value="yes" <?php if (isset($config['system']['enablenatreflectionhelper'])) echo "checked"; ?> />
+ <strong><?=gettext("Automatically create outbound NAT rules which assist inbound NAT rules that direct traffic back out to the same subnet it originated from.");?></strong>
+ <br/>
+ <?=gettext("Currently only applies to 1:1 NAT rules. Required for full functionality of NAT Reflection for 1:1 NAT.");?>
+ </td>
+ </tr>
+ <tr>
<td width="22%" valign="top" class="vncell"><?=gettext("TFTP Proxy");?></td>
<td width="78%" class="vtable">
<select name="tftpinterface[]" multiple="true" class="formselect" size="3">
diff --git a/usr/local/www/system_advanced_misc.php b/usr/local/www/system_advanced_misc.php
index 547ee46..b93301d 100644
--- a/usr/local/www/system_advanced_misc.php
+++ b/usr/local/www/system_advanced_misc.php
@@ -57,6 +57,7 @@ $pconfig['maxmss'] = $config['system']['maxmss'];
$pconfig['powerd_enable'] = isset($config['system']['powerd_enable']);
$pconfig['glxsb_enable'] = isset($config['system']['glxsb_enable']);
$pconfig['schedule_states'] = isset($config['system']['schedule_states']);
+$pconfig['kill_states'] = isset($config['system']['kill_states']);
if ($_POST) {
@@ -107,6 +108,11 @@ if ($_POST) {
else
unset($config['system']['schedule_states']);
+ if($_POST['kill_states'] == "yes")
+ $config['system']['kill_states'] = true;
+ else
+ unset($config['system']['kill_states']);
+
write_config();
$retval = 0;
@@ -279,6 +285,21 @@ function maxmss_checked(obj) {
"This option allows to override this setting by not clearing states for existing connections."); ?>
</td>
</tr>
+ <tr>
+ <td colspan="2" class="list" height="12">&nbsp;</td>
+ </tr>
+ <tr>
+ <td colspan="2" valign="top" class="listtopic"><?=gettext("Gateway Monitoring"); ?></td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell"><?=gettext("States"); ?></td>
+ <td width="78%" class="vtable">
+ <input name="kill_states" type="checkbox" id="kill_states" value="yes" <?php if ($pconfig['kill_states']) echo "checked"; ?> />
+ <br />
+ <?=gettext("By default the monitoring process will flush states for a gateway that goes down. ".
+ "This option allows to override this setting by not clearing states for existing connections."); ?>
+ </td>
+ </tr>
<tr>
<td colspan="2" class="list" height="12">&nbsp;</td>
</tr>
diff --git a/usr/local/www/system_crlmanager.php b/usr/local/www/system_crlmanager.php
index 9a78cb6..90b61d6 100644
--- a/usr/local/www/system_crlmanager.php
+++ b/usr/local/www/system_crlmanager.php
@@ -214,16 +214,18 @@ if ($_POST) {
if (!$input_errors) {
$result = false;
- $crl = array();
- $crl['refid'] = uniqid();
- if ($thiscrl)
+ if ($thiscrl) {
$crl =& $thiscrl;
+ } else {
+ $crl = array();
+ $crl['refid'] = uniqid();
+ }
$crl['descr'] = $pconfig['descr'];
$crl['caref'] = $pconfig['caref'];
if ($pconfig['method'] == "existing") {
- $crl['text'] == base64_encode($pconfig['crltext']);
+ $crl['text'] = base64_encode($pconfig['crltext']);
}
if ($pconfig['method'] == "internal") {
@@ -235,7 +237,7 @@ if ($_POST) {
if (!$thiscrl)
$a_crl[] = $crl;
- write_config("Saved CRL {$crl['caref']}");
+ write_config("Saved CRL {$crl['descr']}");
pfSenseHeader("system_crlmanager.php");
}
@@ -537,9 +539,11 @@ function method_change() {
<td class="listr"><?php echo ($internal) ? count($tmpcrl['cert']) : "Unknown (imported)"; ?></td>
<td class="listr"><?php echo ($inuse) ? "YES" : "NO"; ?></td>
<td valign="middle" nowrap class="list">
+ <?php if (!$internal || count($tmpcrl['cert'])): ?>
<a href="system_crlmanager.php?act=exp&id=<?=$tmpcrl['refid'];?>")">
<img src="/themes/<?= $g['theme'];?>/images/icons/icon_down.gif" title="<?=gettext("Export CRL") . " " . htmlspecialchars($tmpcrl['descr']);?>" alt="<?=gettext("Export CRL") . " " . htmlspecialchars($tmpcrl['descr']);?>" width="17" height="17" border="0" />
</a>
+ <?php endif; ?>
<?php if ($internal): ?>
<a href="system_crlmanager.php?act=edit&id=<?=$tmpcrl['refid'];?>")">
<img src="/themes/<?= $g['theme'];?>/images/icons/icon_e.gif" title="<?=gettext("Edit CRL") . " " . htmlspecialchars($tmpcrl['descr']);?>" alt="<?=gettext("Edit CRL") . " " . htmlspecialchars($tmpcrl['descr']);?>" width="17" height="17" border="0" />
diff --git a/usr/local/www/system_gateways_edit.php b/usr/local/www/system_gateways_edit.php
index 6de6a8b..a4975fe 100755
--- a/usr/local/www/system_gateways_edit.php
+++ b/usr/local/www/system_gateways_edit.php
@@ -120,7 +120,7 @@ if ($_POST) {
}
if (is_ipaddrv4($parent_ip)) {
$parent_sn = get_interface_subnet($_POST['interface']);
- if(!ip_in_subnet($_POST['gateway'], gen_subnet($parent_ip, $parent_sn) . "/" . $parent_sn)) {
+ if(!ip_in_subnet($_POST['gateway'], gen_subnet($parent_ip, $parent_sn) . "/" . $parent_sn) && !ip_in_interface_alias_subnet($_POST['interface'], $_POST['gateway'])) {
$input_errors[] = sprintf(gettext("The gateway address %s does not lie within the chosen interface's subnet."), $_POST['gateway']);
}
}
diff --git a/usr/local/www/system_routes_edit.php b/usr/local/www/system_routes_edit.php
index 89f2288..3fb4fba 100755
--- a/usr/local/www/system_routes_edit.php
+++ b/usr/local/www/system_routes_edit.php
@@ -211,7 +211,7 @@ include("head.inc");
</tr>
<tr><td>&nbsp;</td>
<tr>
- <td width="45%" align="right"><font color="white"><?=gettext("Default gateway:"); ?></td><td><input type="checkbox" id="defaultgw" name="defaultgw"<?=$checked?>></td>
+ <td width="45%" align="right"><font color="white"><?=gettext("Default gateway:"); ?></td><td><input type="checkbox" id="defaultgw" name="defaultgw"></td>
</tr>
<tr>
<td width="45%" align="right"><font color="white"><?=gettext("Interface:"); ?></td>
@@ -296,7 +296,9 @@ include("head.inc");
var descr = $('gatewaydescr').getValue();
gatewayip = $('gatewayip').getValue();
addrtype = $('addrtype').getValue();
- var defaultgw = $('defaultgw').getValue();
+ var defaultgw = '';
+ if ($('defaultgw').checked)
+ defaultgw = 'yes';
var url = "system_gateways_edit.php";
var pars = 'isAjax=true&defaultgw=' + escape(defaultgw) + '&interface=' + escape(iface) + '&name=' + escape(name) + '&descr=' + escape(descr) + '&gateway=' + escape(gatewayip) + '&type=' + escape(addrtype);
var myAjax = new Ajax.Request(
@@ -315,7 +317,7 @@ include("head.inc");
optn.value = value;
selectbox.options.add(optn);
selectbox.selectedIndex = (selectbox.options.length-1);
- $('notebox').innerHTML="<p/><strong><?=gettext("NOTE:");?></strong> <?php printf(gettext("You can manage Gateways %shere%s."), "<a target='_new' href='system_gateways.php'>", "</a>");?>
+ $('notebox').innerHTML="<p/><strong><?=gettext("NOTE:");?></strong> <?php printf(gettext("You can manage Gateways %shere%s."), "<a target='_new' href='system_gateways.php'>", "</a>");?> </strong>";
}
function report_failure() {
alert("<?=gettext("Sorry, we could not create your gateway at this time."); ?>");
diff --git a/usr/local/www/system_usermanager_settings.php b/usr/local/www/system_usermanager_settings.php
index d7e3e1a..d9017c4 100755
--- a/usr/local/www/system_usermanager_settings.php
+++ b/usr/local/www/system_usermanager_settings.php
@@ -62,10 +62,13 @@ if ($_POST) {
}
if (!$input_errors) {
- if ($_POST['savetest'] && $_POST['authmode'] == "ldap")
- $save_and_test = true;
- else
- $savemsg = gettext("The test was not performed becuase it is supported only for ldap based backends.");
+ if ($_POST['authmode'] != "local") {
+ $authsrv = auth_get_authserver($_POST['authmode']);
+ if ($_POST['savetest'] && $authsrv['type'] == "ldap")
+ $save_and_test = true;
+ else
+ $savemsg = gettext("The test was not performed becuase it is supported only for ldap based backends.");
+ }
if(isset($_POST['session_timeout']) && $_POST['session_timeout'] != "")
diff --git a/usr/local/www/vpn_ipsec.php b/usr/local/www/vpn_ipsec.php
index c0232ab..40879f6 100755
--- a/usr/local/www/vpn_ipsec.php
+++ b/usr/local/www/vpn_ipsec.php
@@ -191,7 +191,10 @@ include("head.inc");
$iflabels = get_configured_interface_with_descr();
$carplist = get_configured_carp_interface_list();
foreach ($carplist as $cif => $carpip)
- $iflabels[$cif] = strtoupper($cif) . " ({$carpip})";
+ $iflabels[$cif] = $carpip." (".get_vip_descr($carpip).")";
+ $aliaslist = get_configured_ip_aliases_list();
+ foreach ($aliaslist as $aliasip => $aliasif)
+ $iflabels[$aliasip] = $aliasip." (".get_vip_descr($aliasip).")";
$if = htmlspecialchars($iflabels[$ph1ent['interface']]);
}
else
@@ -443,7 +446,7 @@ function show_ipsec_header($ph1ent) {
global $g;
if (isset($ph1ent['mobile']))
$mobile = "&mobile=true";
- echo <<<EOF
+ ?>
<tr>
<td class="listhdrr"><?=gettext("Remote Gateway"); ?></td>
<td class="listhdrr"><?=gettext("Mode"); ?></td>
@@ -454,7 +457,7 @@ function show_ipsec_header($ph1ent) {
</td>
</tr>
-EOF;
+<?php
}
diff --git a/usr/local/www/vpn_ipsec_phase1.php b/usr/local/www/vpn_ipsec_phase1.php
index c498858..6240a63 100644
--- a/usr/local/www/vpn_ipsec_phase1.php
+++ b/usr/local/www/vpn_ipsec_phase1.php
@@ -509,7 +509,10 @@ function dpdchkbox_change() {
$interfaces = get_configured_interface_with_descr();
$carplist = get_configured_carp_interface_list();
foreach ($carplist as $cif => $carpip)
- $interfaces[$cif] = strtoupper($cif) . " ({$carpip})";
+ $interfaces[$cif] = $carpip." (".get_vip_descr($carpip).")";
+ $aliaslist = get_configured_ip_aliases_list();
+ foreach ($aliaslist as $aliasip => $aliasif)
+ $interfaces[$aliasip] = $aliasip." (".get_vip_descr($aliasip).")";
foreach ($interfaces as $iface => $ifacename):
?>
<option value="<?=$iface;?>" <?php if ($iface == $pconfig['interface']) echo "selected"; ?>>
diff --git a/usr/local/www/vpn_ipsec_phase2.php b/usr/local/www/vpn_ipsec_phase2.php
index f8d601d..b20fe0c 100644
--- a/usr/local/www/vpn_ipsec_phase2.php
+++ b/usr/local/www/vpn_ipsec_phase2.php
@@ -358,7 +358,12 @@ function change_protocol() {
<select name="localid_type" class="formselect" onChange="typesel_change_local()">
<option value="address" <?php if ($pconfig['localid_type'] == "address") echo "selected";?>><?=gettext("Address"); ?></option>
<option value="network" <?php if ($pconfig['localid_type'] == "network") echo "selected";?>><?=gettext("Network"); ?></option>
- <option value="lan" <?php if ($pconfig['localid_type'] == "lan" ) echo "selected";?>><?=gettext("LAN subnet"); ?></option>
+ <?php
+ $iflist = get_configured_interface_with_descr();
+ foreach ($iflist as $ifname => $ifdescr):
+ ?>
+ <option value="<?=$ifname; ?>" <?php if ($pconfig['localid_type'] == $ifname ) echo "selected";?>><?=sprintf(gettext("%s subnet"), $ifdescr); ?></option>
+ <?php endforeach; ?>
<option value="none" <?php if ($pconfig['localid_type'] == "none" ) echo "selected";?>><?=gettext("None"); ?></option>
</select>
</td>
diff --git a/usr/local/www/vpn_openvpn_client.php b/usr/local/www/vpn_openvpn_client.php
index 04bbeb9..96f67bf 100644
--- a/usr/local/www/vpn_openvpn_client.php
+++ b/usr/local/www/vpn_openvpn_client.php
@@ -457,10 +457,10 @@ if ($savemsg)
$interfaces = get_configured_interface_with_descr();
$carplist = get_configured_carp_interface_list();
foreach ($carplist as $cif => $carpip)
- $interfaces[$cif.'|'.$carpip] = strtoupper($cif) . " ({$carpip})";
+ $interfaces[$cif.'|'.$carpip] = $carpip." (".get_vip_descr($carpip).")";
$aliaslist = get_configured_ip_aliases_list();
foreach ($aliaslist as $aliasip => $aliasif)
- $interfaces[$aliasif.'|'.$aliasip] = strtoupper($aliasif) . " ({$aliasip})";
+ $interfaces[$aliasif.'|'.$aliasip] = $aliasip." (".get_vip_descr($aliasip).")";
$interfaces['any'] = "any";
foreach ($interfaces as $iface => $ifacename):
$selected = "";
@@ -479,7 +479,7 @@ if ($savemsg)
<td width="78%" class="vtable">
<input name="local_port" type="text" class="formfld unknown" size="5" value="<?=htmlspecialchars($pconfig['local_port']);?>"/>
<br/>
- <?=gettext("Set this option if you would like to bind to a specific port"); ?>.
+ <?=gettext("Set this option if you would like to bind to a specific port. Leave this blank or enter 0 for a random dynamic port."); ?>
</td>
</tr>
<tr>
diff --git a/usr/local/www/vpn_openvpn_server.php b/usr/local/www/vpn_openvpn_server.php
index 7cb4332..9d7c00d 100644
--- a/usr/local/www/vpn_openvpn_server.php
+++ b/usr/local/www/vpn_openvpn_server.php
@@ -427,6 +427,7 @@ function mode_change() {
case "p2p_shared_key":
document.getElementById("client_opts").style.display="none";
document.getElementById("remote_opts").style.display="";
+ document.getElementById("gwredir_opts").style.display="none";
document.getElementById("local_opts").style.display="none";
document.getElementById("authmodetr").style.display="none";
document.getElementById("inter_client_communication").style.display="none";
@@ -434,6 +435,7 @@ function mode_change() {
case "p2p_tls":
document.getElementById("client_opts").style.display="none";
document.getElementById("remote_opts").style.display="";
+ document.getElementById("gwredir_opts").style.display="";
document.getElementById("local_opts").style.display="";
document.getElementById("authmodetr").style.display="none";
document.getElementById("inter_client_communication").style.display="none";
@@ -443,6 +445,7 @@ function mode_change() {
document.getElementById("authmodetr").style.display="";
document.getElementById("client_opts").style.display="";
document.getElementById("remote_opts").style.display="none";
+ document.getElementById("gwredir_opts").style.display="";
document.getElementById("local_opts").style.display="";
document.getElementById("inter_client_communication").style.display="";
break;
@@ -451,10 +454,12 @@ function mode_change() {
default:
document.getElementById("client_opts").style.display="";
document.getElementById("remote_opts").style.display="none";
+ document.getElementById("gwredir_opts").style.display="";
document.getElementById("local_opts").style.display="";
document.getElementById("inter_client_communication").style.display="";
break;
}
+ gwredir_change();
}
function autokey_change() {
@@ -658,10 +663,10 @@ if ($savemsg)
$interfaces = get_configured_interface_with_descr();
$carplist = get_configured_carp_interface_list();
foreach ($carplist as $cif => $carpip)
- $interfaces[$cif.'|'.$carpip] = strtoupper($cif) . " ({$carpip})";
+ $interfaces[$cif.'|'.$carpip] = $carpip." (".get_vip_descr($carpip).")";
$aliaslist = get_configured_ip_aliases_list();
foreach ($aliaslist as $aliasip => $aliasif)
- $interfaces[$aliasif.'|'.$aliasip] = strtoupper($aliasif) . " ({$aliasip})";
+ $interfaces[$aliasif.'|'.$aliasip] = $aliasip." (".get_vip_descr($aliasip).")";
$interfaces['any'] = "any";
foreach ($interfaces as $iface => $ifacename):
$selected = "";
@@ -900,7 +905,7 @@ if ($savemsg)
"to connecting clients. (see Address Pool)"); ?>
</td>
</tr>
- <tr>
+ <tr id="gwredir_opts">
<td width="22%" valign="top" class="vncell"><?=gettext("Redirect Gateway"); ?></td>
<td width="78%" class="vtable">
<table border="0" cellpadding="2" cellspacing="0">
diff --git a/usr/local/www/widgets/include/carp_status.inc b/usr/local/www/widgets/include/carp_status.inc
index d2851d2..79d3c03 100644
--- a/usr/local/www/widgets/include/carp_status.inc
+++ b/usr/local/www/widgets/include/carp_status.inc
@@ -4,4 +4,4 @@
$carp_status_title = "Carp Status";
$carp_status_title_link = "carp_status.php";
-?> \ No newline at end of file
+?>
diff --git a/usr/local/www/widgets/include/wake_on_lan.inc b/usr/local/www/widgets/include/wake_on_lan.inc
new file mode 100644
index 0000000..af3229c
--- /dev/null
+++ b/usr/local/www/widgets/include/wake_on_lan.inc
@@ -0,0 +1,7 @@
+<?php
+
+//set variable for custom title
+$wake_on_lan_title = "Wake On Lan";
+$wake_on_lan_title_link = "services_wol.php";
+
+?> \ No newline at end of file
diff --git a/usr/local/www/widgets/widgets/carp_status.widget.php b/usr/local/www/widgets/widgets/carp_status.widget.php
index 7c98946..6399579 100644
--- a/usr/local/www/widgets/widgets/carp_status.widget.php
+++ b/usr/local/www/widgets/widgets/carp_status.widget.php
@@ -37,13 +37,14 @@ require_once("/usr/local/www/widgets/include/carp_status.inc");
if(is_array($config['virtualip']['vip'])) {
$carpint=0;
foreach($config['virtualip']['vip'] as $carp) {
- if ($carp['mode'] != "carp") continue;
+ if ($carp['mode'] != "carp")
+ continue;
$ipaddress = $carp['subnet'];
$password = $carp['password'];
- $netmask = $carp['subnet_bits'];
+ $netmask = $carp['subnet_bits'];
$vhid = $carp['vhid'];
$advskew = $carp['advskew'];
- $carp_int = find_carp_interface($ipaddress);
+ $carp_int = "vip{$vhid}";
$status = get_carp_interface_status($carp_int);
?>
<tr>
@@ -54,7 +55,7 @@ require_once("/usr/local/www/widgets/include/carp_status.inc");
</td>
<td width="70%" class="listr">
<?php
- if($status == "MASTER") {
+ if($status == "MASTER") {
echo "<img src='/themes/".$g['theme']."/images/icons/icon_pass.gif' title=\"$status\">";
} else if($status == "BACKUP") {
echo "<img src='/themes/".$g['theme']."/images/icons/icon_pass_d.gif' title=\"$status\">";
@@ -73,4 +74,4 @@ require_once("/usr/local/www/widgets/include/carp_status.inc");
<?php
}
?>
-</table> \ No newline at end of file
+</table>
diff --git a/usr/local/www/widgets/widgets/cpu_graphs.widget.php b/usr/local/www/widgets/widgets/deactivated/cpu_graphs.widget.php
index 42c5faa..fa48610 100644
--- a/usr/local/www/widgets/widgets/cpu_graphs.widget.php
+++ b/usr/local/www/widgets/widgets/deactivated/cpu_graphs.widget.php
@@ -70,4 +70,3 @@ require_once("functions.inc");
//GraphDynamicScale(graph[0]);
</script>
-
diff --git a/usr/local/www/widgets/widgets/load_balancer_status.widget.php b/usr/local/www/widgets/widgets/load_balancer_status.widget.php
index c1cf979..5993b67 100644
--- a/usr/local/www/widgets/widgets/load_balancer_status.widget.php
+++ b/usr/local/www/widgets/widgets/load_balancer_status.widget.php
@@ -1,137 +1,142 @@
<?php
/*
- $Id$
- Copyright 2007 Scott Dale
- Part of pfSense widgets (www.pfsense.com)
- originally based on m0n0wall (http://m0n0.ch/wall)
+ Copyright 2010 Jim Pingle
+ Portions copied from status_lb_pool.php, status_lb_vs.php, and vslb.inc:
+ Copyright (C) 2010 Seth Mos <seth.mos@dds.nl>.
+ Copyright (C) 2005-2008 Bill Marquette
- Copyright (C) 2004-2005 T. Lechat <dev@lechat.org>, Manuel Kasper <mk@neon1.net>
- and Jonathan Watt <jwatt@jwatt.org>.
- All rights reserved.
+ Part of pfSense widgets (www.pfsense.com)
+ originally based on m0n0wall (http://m0n0.ch/wall)
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
+ Copyright (C) 2004-2005 T. Lechat <dev@lechat.org>, Manuel Kasper <mk@neon1.net>
+ and Jonathan Watt <jwatt@jwatt.org>.
+ All rights reserved.
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
*/
require_once("guiconfig.inc");
require_once("pfsense-utils.inc");
require_once("functions.inc");
+require_once("vslb.inc");
+
+$now = time();
+$year = date("Y");
- if (!is_array($config['load_balancer']['lbpool'])) {
+if (!is_array($config['load_balancer']['lbpool'])) {
$config['load_balancer']['lbpool'] = array();
- }
- if (!is_array($config['load_balancer']['virtual_server'])) {
- $config['load_balancer']['virtual_server'] = array();
- }
- $a_vs = &$config['load_balancer']['virtual_server'];
- $a_pool = &$config['load_balancer']['lbpool'];
-
- $slbd_logfile = "{$g['varlog_path']}/slbd.log";
-
- $nentries = $config['syslog']['nentries'];
- if (!$nentries)
- $nentries = 50;
-
- $now = time();
- $year = date("Y");
-
-
+}
+if (!is_array($config['load_balancer']['virtual_server'])) {
+ $config['load_balancer']['virtual_server'] = array();
+}
+$a_vs = &$config['load_balancer']['virtual_server'];
+$a_pool = &$config['load_balancer']['lbpool'];
+$rdr_a = get_lb_redirects();
+$relay_hosts = get_lb_summary();
+
+$lb_logfile = "{$g['varlog_path']}/relayd.log";
+$nentries = $config['syslog']['nentries'];
+if (!$nentries)
+ $nentries = 50;
+
?>
- <table bgcolor="#990000" width="100%" border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td width="10%" class="listhdrr">Name</td>
- <td width="10%" class="listhdrr">Port</td>
- <td width="10%" class="listhdrr">Servers</td>
- <td width="30%" class="listhdrr">Status</td>
- <td width="30%" class="listhdr">Description</td>
- </tr>
- <?php $i = 0; foreach ($a_vs as $vsent): ?>
- <tr>
- <td class="listlr">
- <?=$vsent['name'];?>
- </td>
- <td class="listr" align="center" >
- <?=$vsent['port'];?>
- <br />
- </td>
- <td class="listr" align="center" >
- <table border="0" cellpadding="0" cellspacing="2">
- <?php
- foreach ($a_pool as $vipent) {
- if ($vipent['name'] == $vsent['pool']) {
- foreach ((array) $vipent['servers'] as $server) {
- PRINT "<tr><td> {$server} </td></tr>";
- }
+<table bgcolor="#990000" width="100%" border="0" cellspacing="0" cellpadding="0">
+ <tr>
+ <td width="10%" class="listhdrr">Server</td>
+ <td width="10%" class="listhdrr">Pool</td>
+ <td width="30%" class="listhdr">Description</td>
+ </tr>
+ <?php $i = 0; foreach ($a_vs as $vsent): ?>
+ <tr>
+ <?php
+ switch (trim($rdr_a[$vsent['name']]['status'])) {
+ case 'active':
+ $bgcolor = "lightgreen";
+ $rdr_a[$vsent['name']]['status'] = "Active";
+ break;
+ case 'down':
+ $bgcolor = "lightcoral";
+ $rdr_a[$vsent['name']]['status'] = "Down";
+ break;
+ default:
+ $bgcolor = "lightgray";
+ $rdr_a[$vsent['name']]['status'] = 'Unknown - relayd not running?';
+ }
+ ?>
+ <td class="listlr">
+ <?=$vsent['name'];?><br/>
+ <span style="background-color: <?=$bgcolor?>; display: block"><i><?=$rdr_a[$vsent['name']]['status']?></i></span>
+ <?=$vsent['ipaddr'].":".$vsent['port'];?><br/>
+ </td>
+ <td class="listr" align="center" >
+ <table border="0" cellpadding="0" cellspacing="2">
+ <?php
+ foreach ($a_pool as $pool) {
+ if ($pool['name'] == $vsent['pool']) {
+ $pool_hosts=array();
+ foreach ((array) $pool['servers'] as $server) {
+ $svr['ip']['addr']=$server;
+ $svr['ip']['state']=$relay_hosts[$pool['name'].":".$pool['port']][$server]['state'];
+ $svr['ip']['avail']=$relay_hosts[$pool['name'].":".$pool['port']][$server]['avail'];
+ $pool_hosts[]=$svr;
}
- }
- ?>
- </table>
- </td>
- <td class="listr" >
- <table border="0" cellpadding="0" cellspacing="2">
- <?php
- $poolfile = "{$g['tmp_path']}/{$vsent['name']}.pool";
- if(file_exists("$poolfile")) {
- $poolstatus = file_get_contents("$poolfile");
+ foreach ((array) $pool['serversdisabled'] as $server) {
+ $svr['ip']['addr']="$server";
+ $svr['ip']['state']='disabled';
+ $svr['ip']['avail']='disabled';
+ $pool_hosts[]=$svr;
}
- foreach ($a_pool as $vipent) {
- if ($vipent['name'] == $vsent['pool']) {
- foreach ((array) $vipent['servers'] as $server) {
- $lastchange = "";
- $monitorip = $server;
- $logstates = return_clog($slbd_logfile, $nentries, array("$monitorip", "marking"), true);
- $logstates = $logstates[0];
-
- if(stristr($logstates, $monitorip)) {
- $date = preg_split("/[ ]+/" , $logstates);
- $lastchange = "$date[0] $date[1] $year $date[2]";
- }
- if(stristr($poolstatus, $monitorip)) {
- $online = "Online";
- $bgcolor = "lightgreen";
- $change = $now - strtotime("$lastchange");
- if($change < 300) {
- $bgcolor = "khaki";
- }
- } else {
- $online = "Offline";
- $bgcolor = "lightcoral";
+ asort($pool_hosts);
+ foreach ((array) $pool_hosts as $server) {
+ if($server['ip']['addr']!="") {
+ switch ($server['ip']['state']) {
+ case 'up':
+ $bgcolor = "lightgreen";
+ $checked = "checked";
+ break;
+ case 'disabled':
+ $bgcolor = "white";
+ $checked = "";
+ break;
+ default:
+ $bgcolor = "lightcoral";
+ $checked = "checked";
}
- PRINT "<tr><td bgcolor=\"$bgcolor\" > $online </td><td>";
- if($lastchange <> "") {
- PRINT "Last change $lastchange";
- } else {
- PRINT "No changes found in logfile";
- }
- PRINT "</td></tr>";
- }
+ echo "<tr>";
+ echo "<td bgcolor={$bgcolor}> {$server['ip']['addr']}:{$pool['port']} </td><td bgcolor={$bgcolor}>";
+ if($server['ip']['avail'])
+ echo " ({$server['ip']['avail']}) ";
+ echo "</td></tr>";
+ }
}
}
- ?>
- </table>
- </td>
- <td class="listbg" >
- <font color="#FFFFFF"><?=$vipent['descr'];?></font>
- </td>
- </tr>
- <?php $i++; endforeach; ?>
- </table>
+ }
+ ?>
+ </table>
+ </td>
+ <td class="listbg" >
+ <font color="#FFFFFF"><?=$vsent['descr'];?></font>
+ </td>
+ </tr>
+ <?php $i++; endforeach; ?>
+</table>
diff --git a/usr/local/www/widgets/widgets/system_information.widget.php b/usr/local/www/widgets/widgets/system_information.widget.php
index b808fde..9604461 100644
--- a/usr/local/www/widgets/widgets/system_information.widget.php
+++ b/usr/local/www/widgets/widgets/system_information.widget.php
@@ -87,15 +87,11 @@ $curcfg = $config['system']['firmware'];
<td width="25%" valign="top" class="vncellt">Version</td>
<td width="75%" class="listr">
<strong><?php readfile("/etc/version"); ?></strong>
- (<?php
- $arch = "";
- exec('uname -m', $arch);
- echo $arch[0];
- ?>)
+ (<?php echo php_uname("m"); ?>)
<br />
built on <?php readfile("/etc/version.buildtime"); ?>
<br />
- <div name="uname" id="uname"><a href="#" onClick='swapuname(); return false;'><?=`uname -sr`?></a></div>
+ <div name="uname" id="uname"><a href="#" onClick='swapuname(); return false;'><php echo php_uname("s") . " " . php_uname("r"); ?></a></div>
<div id='updatestatus'><br/>Obtaining update status...</div>
</td>
</tr>
@@ -271,7 +267,7 @@ $curcfg = $config['system']['firmware'];
$('updatestatus').innerHTML = transport.responseText;
}
function swapuname() {
- $('uname').innerHTML="<?php echo exec("uname -a"); ?>";
+ $('uname').innerHTML="<?php echo php_uname("a"); ?>";
}
setTimeout('getstatus()', 4000);
</script>
diff --git a/usr/local/www/widgets/widgets/traffic_graphs.widget.php b/usr/local/www/widgets/widgets/traffic_graphs.widget.php
index bcc2298..9d1e76c 100644
--- a/usr/local/www/widgets/widgets/traffic_graphs.widget.php
+++ b/usr/local/www/widgets/widgets/traffic_graphs.widget.php
@@ -68,7 +68,7 @@ Refresh Interval:
<option value="8" <?php if ($refreshInterval == "8") echo "SELECTED";?>>8</option>
<option value="9" <?php if ($refreshInterval == "9") echo "SELECTED";?>>9</option>
<option value="10" <?php if ($refreshInterval == "10") echo "SELECTED";?>>10</option>
- </select>&nbsp; Seconds<br>&nbsp; &nbsp; &nbsp; <b>Note:</b> changing this settings can affect CPU Performance on the pfSense Box<br><br>
+ </select>&nbsp; Seconds<br>&nbsp; &nbsp; &nbsp; <b>Note:</b> changing this setting will increase CPU utilization<br><br>
<input id="submit" name="submit" type="submit" onclick="return updatePref();" class="formbtn" value="Save Settings" />
</div>
diff --git a/usr/local/www/widgets/widgets/wake_on_lan.widget.php b/usr/local/www/widgets/widgets/wake_on_lan.widget.php
new file mode 100644
index 0000000..bb253d0
--- /dev/null
+++ b/usr/local/www/widgets/widgets/wake_on_lan.widget.php
@@ -0,0 +1,78 @@
+<?php
+/*
+ wake_on_lan.widget.php
+ Copyright (C) 2010 Yehuda Katz
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INClUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+require_once("/usr/local/www/widgets/include/wake_on_lan.inc");
+
+if (is_array($config['wol']['wolentry']))
+ $wolcomputers = $config['wol']['wolentry'];
+else
+ $wolcomputers = array();
+
+?>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <?
+ echo '<td class="widgetsubheader"><b><center>' . gettext("Computer / Device") . '</center></b></td>';
+ echo '<td class="widgetsubheader"><b><center>' . gettext("Interface") . '</center></b></td>';
+ echo '<td class="widgetsubheader"><b><center>' . gettext("Status") . '</center></b></td>';
+ ?>
+ <td class="widgetsubheader">&nbsp;</td>
+ </tr>
+<?php
+
+if (count($wolcomputers) > 0) {
+ foreach($wolcomputers as $wolent) {
+ echo '<tr><td class="listlr">' . $wolent['descr'] . '<br />' . $wolent['mac'] . '</td>' . "\n";
+ $wolifname = $config['interfaces'][$wolent['interface']]['descr'];
+ if ( empty( $wolifname ) ){
+ $wolifname = ucase($wolent['interface']);
+ }
+ echo '<td class="listr">' . $wolifname . '</td>' . "\n";
+
+ $is_active = exec("/usr/sbin/arp -an |/usr/bin/grep {$wolent['mac']}| /usr/bin/wc -l|/usr/bin/awk '{print $1;}'");
+ if($is_active == 1) {
+ echo '<td class="listr"><center>' . "\n";
+ echo "<img src=\"/themes/" . $g["theme"] . "/images/icons/icon_pass.gif\"> " . gettext("Online") . "</td>\n";
+ } else {
+ echo '<td class="listbg"><center>' . "\n";
+ echo "<img src=\"/themes/" . $g["theme"] . "/images/icons/icon_block.gif\"> <font color=\"white\">" . gettext("Offline") . "</td>\n";
+ }
+ echo '<td valign="middle" class="list" nowrap>';
+ /*if($is_active) { */
+ /* Will always show wake-up button even if pfsense thinks it is awake */
+ /* } else { */
+ echo "<a href='services_wol.php?mac={$wolent['mac']}&if={$wolent['interface']}'> ";
+ echo "<img title='" . gettext("Wake Up") . "' border='0' src='./themes/".$g['theme']."/images/icons/icon_wol_all.gif'></a>\n";
+ /* } */
+ echo "</td></tr>\n";
+ }
+} else {
+ echo "<tr><td colspan=\"3\"><center>" . gettext("No saved WoL addresses") . ".</td></tr>\n";
+}
+?>
+</table>
+<center><a href="status_dhcp_leases.php" class="navlink">DHCP Leases Status</a></center>
diff --git a/usr/local/www/wizard.php b/usr/local/www/wizard.php
index 965a2aa..493fab1 100755
--- a/usr/local/www/wizard.php
+++ b/usr/local/www/wizard.php
@@ -894,7 +894,7 @@ if($pkg['step'][$stepid]['javascriptafterformdisplay'] <> "") {
*/
function fixup_string($string) {
- global $config, $myurl;
+ global $config, $g, $myurl, $title;
$newstring = $string;
// fixup #1: $myurl -> http[s]://ip_address:port/
switch($config['system']['webgui']['protocol']) {
@@ -918,7 +918,26 @@ function fixup_string($string) {
$urlport = "";
}
}
- $myurl = $proto . "://" . $_SERVER['HTTP_HOST'] . $urlport . "/";
+ $http_host = explode(":", $_SERVER['HTTP_HOST']);
+ $http_host = $http_host[0];
+ $urlhost = $http_host;
+ // If finishing the setup wizard, check if accessing on a LAN or WAN address that changed
+ if($title == "Reload in progress") {
+ if (is_ipaddr($urlhost)) {
+ $host_if = find_ip_interface($urlhost);
+ if ($host_if) {
+ $host_if = convert_real_interface_to_friendly_interface_name($host_if);
+ if ($host_if && is_ipaddr($config['interfaces'][$host_if]['ipaddr']))
+ $urlhost = $config['interfaces'][$host_if]['ipaddr'];
+ }
+ } else if ($urlhost == $config['system']['hostname'])
+ $urlhost = $config['wizardtemp']['system']['hostname'];
+ else if ($urlhost == $config['system']['hostname'] . '.' . $config['system']['domain'])
+ $urlhost = $config['wizardtemp']['system']['hostname'] . '.' . $config['wizardtemp']['system']['domain'];
+ }
+ if($urlhost != $http_host)
+ file_put_contents("{$g['tmp_path']}/setupwizard_lastreferrer", $proto . "://" . $http_host . $urlport . $_SERVER['REQUEST_URI']);
+ $myurl = $proto . "://" . $urlhost . $urlport . "/";
if (strstr($newstring, "\$myurl"))
$newstring = str_replace("\$myurl", $myurl, $newstring);
diff --git a/usr/local/www/wizards/setup_wizard.xml b/usr/local/www/wizards/setup_wizard.xml
index aad3a59..5a33d39 100644
--- a/usr/local/www/wizards/setup_wizard.xml
+++ b/usr/local/www/wizards/setup_wizard.xml
@@ -57,7 +57,7 @@
<field>
<name>Hostname</name>
<type>input</type>
- <bindstofield>system->hostname</bindstofield>
+ <bindstofield>wizardtemp->system->hostname</bindstofield>
<description>EXAMPLE: myserver</description>
<validate>^[a-z0-9.|-]+$</validate>
<message>Invalid Hostname</message>
@@ -65,7 +65,7 @@
<field>
<name>Domain</name>
<type>input</type>
- <bindstofield>system->domain</bindstofield>
+ <bindstofield>wizardtemp->system->domain</bindstofield>
<description>EXAMPLE: mydomain.com</description>
<validate>^[a-z0-9.|-]+$</validate>
<message>Domain name field is invalid</message>
@@ -99,6 +99,14 @@
<type>submit</type>
</field>
</fields>
+ <stepbeforeformdisplay>
+ <![CDATA[
+ $config['wizardtemp'] = array();
+ $config['wizardtemp']['system'] = array();
+ $config['wizardtemp']['system']['hostname'] = $config['system']['hostname'];
+ $config['wizardtemp']['system']['domain'] = $config['system']['domain'];
+ ]]>
+ </stepbeforeformdisplay>
<stepsubmitphpaction>
<![CDATA[
if(empty($_POST['hostname']) || !is_hostname($_POST['hostname'])) {
@@ -210,13 +218,6 @@
<type>listtopic</type>
</field>
<field>
- <name>interface</name>
- <type>interface_select</type>
- <donotdisable>true</donotdisable>
- <displayname>Interface</displayname>
- <bindstofield>interfaces->wan->if</bindstofield>
- </field>
- <field>
<donotdisable>true</donotdisable>
<name>MAC Address</name>
<bindstofield>interfaces->wan->spoofmac</bindstofield>
@@ -553,6 +554,10 @@
<description>A reload is now in progress. Please wait. &lt;p&gt; The system will automatically try to access $myurl in 120 seconds. &lt;p&gt; You can click on the icon above to access the site more quickly.
&lt;meta http-equiv="refresh" content="60; url=$myurl" &gt;</description>
<stepafterformdisplay>
+ $config['system']['hostname'] = $config['wizardtemp']['system']['hostname'];
+ $config['system']['domain'] = $config['wizardtemp']['system']['domain'];
+ unset($config['wizardtemp']);
+ write_config();
reload_all();
mwexec_bg("/etc/rc.update_bogons.sh now");
</stepafterformdisplay>
diff --git a/usr/local/www/wizards/traffic_shaper_wizard.inc b/usr/local/www/wizards/traffic_shaper_wizard.inc
index e42de1e..2fa3f1b 100644
--- a/usr/local/www/wizards/traffic_shaper_wizard.inc
+++ b/usr/local/www/wizards/traffic_shaper_wizard.inc
@@ -555,10 +555,8 @@ function step8_stepsubmitphpaction() {
clear_subsystem_dirty('shaper');
update_filter_reload_status("Initializing");
-}
-function step9_stepsubmitphpaction() {
- global $g, $config;
- header("status_filter_reload.php");
+ header("Location: status_filter_reload.php");
+ exit;
}
function apply_all_choosen_items() {
@@ -588,7 +586,7 @@ function apply_all_choosen_items() {
$lanbw = 0;
for ($i = 0; $i < $steps; $i++) {
$down = wizard_get_bandwidthtype_scale($config['ezshaper']['step2']["conn{$i}downloadspeed"]);
- $input_bw = $config['ezshaper']['step2']["conn{$i}download"] * $down;
+ $input_bw = floatval($config['ezshaper']['step2']["conn{$i}download"]) * $down;
$lanbw += $input_bw;
}
@@ -626,7 +624,7 @@ function apply_all_choosen_items() {
if ($config['ezshaper']['step3']['enable']) {
$voip = true;
- $voipbw = $config['ezshaper']['step3']["conn{$i}upload"];
+ $voipbw = floatval($config['ezshaper']['step3']["conn{$i}upload"]);
$voipbwunit = $config['ezshaper']['step3']["conn{$i}uploadspeed"];
if ($sched != "HFSC") {
if ($voipbwunit == "%")
@@ -685,7 +683,7 @@ function apply_all_choosen_items() {
if ($remainbw > 0 && $remainbw > 30) {
$savemsg=gettext("Custom Bandwidths are greater than 30%. Please lower them for the wizard to continue.");
- header("Location: wizard.php?xml=traffic_shaper_wizard.xml&stepid=2&message={$message}");
+ header("Location: wizard.php?xml=traffic_shaper_wizard.xml&stepid=2&message={$savemsg}");
exit;
} else {
$remainbw = 100 - $remainbw;
@@ -1037,7 +1035,7 @@ function apply_all_choosen_items() {
if ($remainbw > 0 && $remainbw > 30) {
$savemsg=gettext("Custom Bandwidths are greater than 30%. Please lower them for the wizard to continue.");
- header("Location: wizard.php?xml=traffic_shaper_wizard.xml&stepid=2&message={$message}");
+ header("Location: wizard.php?xml=traffic_shaper_wizard.xml&stepid=2&message={$savemsg}");
exit;
} else {
$remainbw = 100 - $remainbw;
@@ -1506,7 +1504,7 @@ function apply_all_choosen_items() {
write_config();
}
-function wizard_get_bandwidthtype_scale($type) {
+function wizard_get_bandwidthtype_scale($type = "b") {
switch ($type) {
case "Gb":
$factor = 1000 * 1000 * 1000;
@@ -1522,7 +1520,7 @@ function wizard_get_bandwidthtype_scale($type) {
$factor = 1;
break;
}
- return floatval($factor);
+ return intval($factor);
}
?>
diff --git a/usr/local/www/wizards/traffic_shaper_wizard.xml b/usr/local/www/wizards/traffic_shaper_wizard.xml
index ce2b04c..4c2f2a3 100644
--- a/usr/local/www/wizards/traffic_shaper_wizard.xml
+++ b/usr/local/www/wizards/traffic_shaper_wizard.xml
@@ -1215,16 +1215,4 @@
<stepsubmitphpaction>step8_stepsubmitphpaction();</stepsubmitphpaction>
<includefile>/usr/local/www/wizards/traffic_shaper_wizard.inc</includefile>
</step>
- <step>
- <id>9</id>
- <title>pfSense Traffic Shaper Wizard</title>
- <fields>
- <field>
- <name>Finish</name>
- <type>submit</type>
- </field>
- </fields>
- <includefile>/usr/local/www/wizards/traffic_shaper_wizard.inc</includefile>
- <stepsubmitphpaction>step9_stepsubmitphpaction();</stepsubmitphpaction>
- </step>
</pfsensewizard>
diff --git a/usr/local/www/wizards/traffic_shaper_wizard_dedicated.inc b/usr/local/www/wizards/traffic_shaper_wizard_dedicated.inc
index 78c8990..66b4716 100755
--- a/usr/local/www/wizards/traffic_shaper_wizard_dedicated.inc
+++ b/usr/local/www/wizards/traffic_shaper_wizard_dedicated.inc
@@ -525,7 +525,7 @@ function step4_stepsubmitphpaction() {
$stepid--;
return;
}
- $bw = wizard_get_bw($_POST['bandwidth']);
+ $bw = $_POST['bandwidth'];
if($bw > 15 && $bw < 2) {
$savemsg="Values should be between 2% and 15%!";
$stepid--;
@@ -554,7 +554,7 @@ function step5_stepsubmitphpaction() {
$stepid--;
return;
}
- $bw = wizard_get_bw($_POST['bandwidth']);
+ $bw = $_POST['bandwidth'];
if($bw > 15 && $bw < 2) {
$savemsg="Values should be between 2% and 15%!";
$stepid--;
@@ -582,11 +582,8 @@ function step8_stepsubmitphpaction() {
clear_subsystem_dirty('shaper');
update_filter_reload_status("Initializing");
-}
-
-function step9_stepsubmitphpaction() {
- global $g, $config;
- header("status_filter_reload.php");
+ header("Location: status_filter_reload.php");
+ exit;
}
function apply_all_choosen_items() {
@@ -712,7 +709,7 @@ function apply_all_choosen_items() {
if (intval($remainbw) > 0 && intval($remainbw) > 30) {
$savemsg=gettext("Custom Bandwidths are greater than 30%. Please lower them for the wizard to continue.");
- header("Location: wizard.php?xml=traffic_shaper_wizard_dedicated.xml&stepid=2&message={$message}");
+ header("Location: wizard.php?xml=traffic_shaper_wizard_dedicated.xml&stepid=2&message={$savemsg}");
exit;
} else {
$remainbw = 100 - $remainbw;
@@ -1097,7 +1094,7 @@ function apply_all_choosen_items() {
$remainbw = round($remainbw / $downbw * 100, 2);
if (intval($remainbw) > 0 && intval($remainbw) > 40) {
$savemsg=gettext("Custom Bandwidths are greater than 30%. Please lower them for the wizard to continue.");
- header("Location: wizard.php?xml=traffic_shaper_wizard_dedicated.xml&stepid=2&message={$message}");
+ header("Location: wizard.php?xml=traffic_shaper_wizard_dedicated.xml&stepid=2&message={$savemsg}");
exit;
} else {
$remainbw = 100 - $remainbw;
@@ -1567,7 +1564,7 @@ function apply_all_choosen_items() {
write_config();
}
-function wizard_get_bandwidthtype_scale($type) {
+function wizard_get_bandwidthtype_scale($type = "b") {
switch ($type) {
case "Gb":
$factor = 1000 * 1000 * 1000;
diff --git a/usr/local/www/wizards/traffic_shaper_wizard_dedicated.xml b/usr/local/www/wizards/traffic_shaper_wizard_dedicated.xml
index 5d83553..ecdb508 100755
--- a/usr/local/www/wizards/traffic_shaper_wizard_dedicated.xml
+++ b/usr/local/www/wizards/traffic_shaper_wizard_dedicated.xml
@@ -1220,16 +1220,4 @@
<stepsubmitphpaction>step8_stepsubmitphpaction();</stepsubmitphpaction>
<includefile>/usr/local/www/wizards/traffic_shaper_wizard_dedicated.inc</includefile>
</step>
- <step>
- <id>9</id>
- <title>pfSense Traffic Shaper Wizard</title>
- <fields>
- <field>
- <name>Finish</name>
- <type>submit</type>
- </field>
- </fields>
- <includefile>/usr/local/www/wizards/traffic_shaper_wizard_dedicated.inc</includefile>
- <stepsubmitphpaction>step9_stepsubmitphpaction();</stepsubmitphpaction>
- </step>
</pfsensewizard>
diff --git a/usr/local/www/wizards/traffic_shaper_wizard_multi_all.inc b/usr/local/www/wizards/traffic_shaper_wizard_multi_all.inc
index 63b3b11..6568dc1 100755
--- a/usr/local/www/wizards/traffic_shaper_wizard_multi_all.inc
+++ b/usr/local/www/wizards/traffic_shaper_wizard_multi_all.inc
@@ -615,11 +615,8 @@ function step8_stepsubmitphpaction() {
clear_subsystem_dirty('shaper');
update_filter_reload_status("Initializing");
-}
-
-function step9_stepsubmitphpaction() {
- global $g, $config;
- header("status_filter_reload.php");
+ header("Location: status_filter_reload.php");
+ exit;
}
function apply_all_choosen_items() {
@@ -745,7 +742,7 @@ function apply_all_choosen_items() {
if (intval($remainbw) > 0 && intval($remainbw) > 30) {
$savemsg=gettext("Custom Bandwidths are greater than 30%. Please lower them for the wizard to continue.");
- header("Location: wizard.php?xml=traffic_shaper_wizard_multi_all.xml&stepid=2&message={$message}");
+ header("Location: wizard.php?xml=traffic_shaper_wizard_multi_all.xml&stepid=2&message={$savemsg}");
exit;
} else {
$remainbw = 100 - $remainbw;
@@ -1143,7 +1140,7 @@ function apply_all_choosen_items() {
if (intval($remainbw) > 0 && intval($remainbw) > 40) {
$savemsg=gettext("Custom Bandwidths are greater than 30%. Please lower them for the wizard to continue.");
- header("Location: wizard.php?xml=traffic_shaper_wizard_multi_all.xml&stepid=2&message={$message}");
+ header("Location: wizard.php?xml=traffic_shaper_wizard_multi_all.xml&stepid=2&message={$savemsg}");
exit;
} else {
$remainbw = 100 - $remainbw;
@@ -1614,7 +1611,7 @@ function apply_all_choosen_items() {
write_config();
}
-function wizard_get_bandwidthtype_scale($type) {
+function wizard_get_bandwidthtype_scale($type = "b") {
switch ($type) {
case "Gb":
$factor = 1000 * 1000 * 1000;
diff --git a/usr/local/www/wizards/traffic_shaper_wizard_multi_all.xml b/usr/local/www/wizards/traffic_shaper_wizard_multi_all.xml
index 9fca078..050f493 100755
--- a/usr/local/www/wizards/traffic_shaper_wizard_multi_all.xml
+++ b/usr/local/www/wizards/traffic_shaper_wizard_multi_all.xml
@@ -1228,16 +1228,4 @@
<stepsubmitphpaction>step8_stepsubmitphpaction();</stepsubmitphpaction>
<includefile>/usr/local/www/wizards/traffic_shaper_wizard_multi_all.inc</includefile>
</step>
- <step>
- <id>9</id>
- <title>pfSense Traffic Shaper Wizard</title>
- <fields>
- <field>
- <name>Finish</name>
- <type>submit</type>
- </field>
- </fields>
- <includefile>/usr/local/www/wizards/traffic_shaper_wizard_multi_all.inc</includefile>
- <stepsubmitphpaction>step9_stepsubmitphpaction();</stepsubmitphpaction>
- </step>
</pfsensewizard>
diff --git a/usr/local/www/wizards/traffic_shaper_wizard_multi_lan.inc b/usr/local/www/wizards/traffic_shaper_wizard_multi_lan.inc
index e4f5816..99f5c35 100644
--- a/usr/local/www/wizards/traffic_shaper_wizard_multi_lan.inc
+++ b/usr/local/www/wizards/traffic_shaper_wizard_multi_lan.inc
@@ -397,11 +397,8 @@ function step8_stepsubmitphpaction() {
clear_subsystem_dirty('shaper');
update_filter_reload_status("Initializing");
-}
-
-function step9_stepsubmitphpaction() {
- global $g, $config;
- header("status_filter_reload.php");
+ header("Location: status_filter_reload.php");
+ exit;
}
function apply_all_choosen_items() {
@@ -520,8 +517,8 @@ function apply_all_choosen_items() {
$remainbw = round($remainbw / $upbw * 100, 2);
if ($remainbw > 0 && $remainbw > 30) {
- $message=gettext("Custom Bandwidths are greater than 30%. Please lower them for the wizard to continue.");
- header("Location: wizard.php?xml=traffic_shaper_wizard_multi_lan.xml&stepid=2&message={$message}");
+ $savemsg=gettext("Custom Bandwidths are greater than 30%. Please lower them for the wizard to continue.");
+ header("Location: wizard.php?xml=traffic_shaper_wizard_multi_lan.xml&stepid=2&message={$savemsg}");
exit;
} else {
$remainbw = 100 - $remainbw;
@@ -910,8 +907,8 @@ function apply_all_choosen_items() {
}
$remainbw = round($remainbw / $lanbw * 100, 2);
if ($remainbw > 0 && $remainbw > 30) {
- $message=gettext("Custom Bandwidths are greater than 30%. Please lower them for the wizard to continue.");
- header("Location: wizard.php?xml=traffic_shaper_wizard_multi_lan.xml&stepid=2&message={$message}");
+ $savemsg=gettext("Custom Bandwidths are greater than 30%. Please lower them for the wizard to continue.");
+ header("Location: wizard.php?xml=traffic_shaper_wizard_multi_lan.xml&stepid=2&message={$savemsg}");
exit;
} else {
$remainbw = 100 - $remainbw;
@@ -1351,7 +1348,7 @@ function apply_all_choosen_items() {
write_config();
}
-function wizard_get_bandwidthtype_scale($type) {
+function wizard_get_bandwidthtype_scale($type = "b") {
switch ($type) {
case "Gb":
$factor = 1000 * 1000 * 1000;
@@ -1367,7 +1364,7 @@ function wizard_get_bandwidthtype_scale($type) {
$factor = 1;
break;
}
- return floatval($factor);
+ return intval($factor);
}
?>
diff --git a/usr/local/www/wizards/traffic_shaper_wizard_multi_lan.xml b/usr/local/www/wizards/traffic_shaper_wizard_multi_lan.xml
index 9ed7c44..ae5a139 100644
--- a/usr/local/www/wizards/traffic_shaper_wizard_multi_lan.xml
+++ b/usr/local/www/wizards/traffic_shaper_wizard_multi_lan.xml
@@ -1277,16 +1277,4 @@
<stepsubmitphpaction>step8_stepsubmitphpaction();</stepsubmitphpaction>
<includefile>/usr/local/www/wizards/traffic_shaper_wizard_multi_lan.inc</includefile>
</step>
- <step>
- <id>9</id>
- <title>pfSense Traffic Shaper Wizard</title>
- <fields>
- <field>
- <name>Finish</name>
- <type>submit</type>
- </field>
- </fields>
- <includefile>/usr/local/www/wizards/traffic_shaper_wizard_multi_lan.inc</includefile>
- <stepsubmitphpaction>step9_stepsubmitphpaction();</stepsubmitphpaction>
- </step>
</pfsensewizard>
diff --git a/usr/local/www/xmlrpc.php b/usr/local/www/xmlrpc.php
index 375ad46..ea0166b 100755
--- a/usr/local/www/xmlrpc.php
+++ b/usr/local/www/xmlrpc.php
@@ -61,12 +61,12 @@ if($synchronizetoip) {
}
$xmlrpc_g = array(
- "return" => array(
- "true" => new XML_RPC_Response(new XML_RPC_Value(true, $XML_RPC_Boolean)),
- "false" => new XML_RPC_Response(new XML_RPC_Value(false, $XML_RPC_Boolean)),
- "authfail" => new XML_RPC_Response(new XML_RPC_Value(gettext("Authentication failed"), $XML_RPC_String))
- )
- );
+ "return" => array(
+ "true" => new XML_RPC_Response(new XML_RPC_Value(true, $XML_RPC_Boolean)),
+ "false" => new XML_RPC_Response(new XML_RPC_Value(false, $XML_RPC_Boolean)),
+ "authfail" => new XML_RPC_Response(new XML_RPC_Value(gettext("Authentication failed"), $XML_RPC_String))
+ )
+);
/*
* pfSense XMLRPC errors
@@ -75,20 +75,21 @@ $xmlrpc_g = array(
$XML_RPC_erruser = 200;
/* EXPOSED FUNCTIONS */
-
$exec_php_doc = gettext("XMLRPC wrapper for eval(). This method must be called with two parameters: a string containing the local system\'s password followed by the PHP code to evaluate.");
$exec_php_sig = array(
- array(
- $XML_RPC_Boolean, // First signature element is return value.
- $XML_RPC_String, // password
- $XML_RPC_String, // shell code to exec
- )
- );
+ array(
+ $XML_RPC_Boolean, // First signature element is return value.
+ $XML_RPC_String, // password
+ $XML_RPC_String, // shell code to exec
+ )
+);
function exec_php_xmlrpc($raw_params) {
global $config, $xmlrpc_g;
+
$params = xmlrpc_params_to_php($raw_params);
- if(!xmlrpc_auth($params)) return $xmlrpc_g['return']['authfail'];
+ if(!xmlrpc_auth($params))
+ return $xmlrpc_g['return']['authfail'];
$exec_php = $params[0];
eval($exec_php);
if($toreturn) {
@@ -99,61 +100,61 @@ function exec_php_xmlrpc($raw_params) {
}
/*****************************/
-
$exec_shell_doc = gettext("XMLRPC wrapper for mwexec(). This method must be called with two parameters: a string containing the local system\'s password followed by an shell command to execute.");
$exec_shell_sig = array(
- array(
- $XML_RPC_Boolean, // First signature element is return value.
- $XML_RPC_String, // password
- $XML_RPC_String, // shell code to exec
- )
- );
-
+ array(
+ $XML_RPC_Boolean, // First signature element is return value.
+ $XML_RPC_String, // password
+ $XML_RPC_String, // shell code to exec
+ )
+);
function exec_shell_xmlrpc($raw_params) {
global $config, $xmlrpc_g;
+
$params = xmlrpc_params_to_php($raw_params);
- if(!xmlrpc_auth($params)) return $xmlrpc_g['return']['authfail'];
+ if(!xmlrpc_auth($params))
+ return $xmlrpc_g['return']['authfail'];
$shell_cmd = $params[0];
mwexec($shell_cmd);
+
return $xmlrpc_g['return']['true'];
}
-
-
/*****************************/
-
-
$backup_config_section_doc = gettext("XMLRPC wrapper for backup_config_section. This method must be called with two parameters: a string containing the local system\'s password followed by an array containing the keys to be backed up.");
$backup_config_section_sig = array(
- array(
- $XML_RPC_Struct, // First signature element is return value.
- $XML_RPC_String,
- $XML_RPC_Array
- )
- );
+ array(
+ $XML_RPC_Struct, // First signature element is return value.
+ $XML_RPC_String,
+ $XML_RPC_Array
+ )
+);
function backup_config_section_xmlrpc($raw_params) {
global $config, $xmlrpc_g;
+
$params = xmlrpc_params_to_php($raw_params);
- if(!xmlrpc_auth($params)) return $xmlrpc_g['return']['authfail'];
+ if(!xmlrpc_auth($params))
+ return $xmlrpc_g['return']['authfail'];
$val = array_intersect_key($config, array_flip($params[0]));
+
return new XML_RPC_Response(XML_RPC_encode($val));
}
/*****************************/
-
$restore_config_section_doc = gettext("XMLRPC wrapper for restore_config_section. This method must be called with two parameters: a string containing the local system\'s password and an array to merge into the system\'s config. This function returns true upon completion.");
$restore_config_section_sig = array(
- array(
- $XML_RPC_Boolean,
- $XML_RPC_String,
- $XML_RPC_Struct
- )
- );
+ array(
+ $XML_RPC_Boolean,
+ $XML_RPC_String,
+ $XML_RPC_Struct
+ )
+);
function restore_config_section_xmlrpc($raw_params) {
global $config, $xmlrpc_g;
+
$params = xmlrpc_params_to_php($raw_params);
if(!xmlrpc_auth($params))
return $xmlrpc_g['return']['authfail'];
@@ -168,54 +169,55 @@ function restore_config_section_xmlrpc($raw_params) {
// For vip section, first keep items sent from the master
$config = array_merge($config, $params[0]);
// Then add ipalias and proxyarp types already defined on the backup
- foreach ($vipbackup as $vip) {
- if (($vip['mode'] == 'ipalias') || ($vip['mode'] == 'proxyarp'))
- $config['virtualip']['vip'][]=$vip ;
+ if (is_array($vipbackup)) {
+ foreach ($vipbackup as $vip) {
+ if (($vip['mode'] == 'ipalias') || ($vip['mode'] == 'proxyarp'))
+ array_unshift($config['virtualip']['vip'], $vip);
+ }
}
$mergedkeys = implode(",", array_keys($params[0]));
write_config(sprintf(gettext("Merged in config (%s sections) from XMLRPC client."),$mergedkeys));
interfaces_vips_configure();
+
return $xmlrpc_g['return']['true'];
}
-
/*****************************/
-
-
$merge_config_section_doc = gettext("XMLRPC wrapper for merging package sections. This method must be called with two parameters: a string containing the local system\'s password and an array to merge into the system\'s config. This function returns true upon completion.");
$merge_config_section_sig = array(
- array(
- $XML_RPC_Boolean,
- $XML_RPC_String,
- $XML_RPC_Struct
- )
- );
+ array(
+ $XML_RPC_Boolean,
+ $XML_RPC_String,
+ $XML_RPC_Struct
+ )
+);
function merge_installedpackages_section_xmlrpc($raw_params) {
global $config, $xmlrpc_g;
+
$params = xmlrpc_params_to_php($raw_params);
- if(!xmlrpc_auth($params)) return $xmlrpc_g['return']['authfail'];
+ if(!xmlrpc_auth($params))
+ return $xmlrpc_g['return']['authfail'];
$config['installedpackages'] = array_merge($config['installedpackages'], $params[0]);
$mergedkeys = implode(",", array_keys($params[0]));
write_config(sprintf(gettext("Merged in config (%s sections) from XMLRPC client."),$mergedkeys));
+
return $xmlrpc_g['return']['true'];
}
-
/*****************************/
-
-
$merge_config_section_doc = gettext("XMLRPC wrapper for merge_config_section. This method must be called with two parameters: a string containing the local system\'s password and an array to merge into the system\'s config. This function returns true upon completion.");
$merge_config_section_sig = array(
- array(
- $XML_RPC_Boolean,
- $XML_RPC_String,
- $XML_RPC_Struct
- )
- );
+ array(
+ $XML_RPC_Boolean,
+ $XML_RPC_String,
+ $XML_RPC_Struct
+ )
+);
function merge_config_section_xmlrpc($raw_params) {
global $config, $xmlrpc_g;
+
$params = xmlrpc_params_to_php($raw_params);
if(!xmlrpc_auth($params))
return $xmlrpc_g['return']['authfail'];
@@ -229,23 +231,25 @@ function merge_config_section_xmlrpc($raw_params) {
$mergedkeys = implode(",", array_keys($params[0]));
write_config("Merged in config ({$mergedkeys} sections) from XMLRPC client.");
interfaces_vips_configure();
+
return $xmlrpc_g['return']['true'];
}
/*****************************/
-
$filter_configure_doc = gettext("Basic XMLRPC wrapper for filter_configure. This method must be called with one paramater: a string containing the local system\'s password. This function returns true upon completion.");
$filter_configure_sig = array(
- array(
- $XML_RPC_Boolean,
- $XML_RPC_String
- )
- );
+ array(
+ $XML_RPC_Boolean,
+ $XML_RPC_String
+ )
+);
function filter_configure_xmlrpc($raw_params) {
global $xmlrpc_g;
+
$params = xmlrpc_params_to_php($raw_params);
- if(!xmlrpc_auth($params)) return $xmlrpc_g['return']['authfail'];
+ if(!xmlrpc_auth($params))
+ return $xmlrpc_g['return']['authfail'];
filter_configure();
system_routing_configure();
setup_gateways_monitor();
@@ -255,71 +259,98 @@ function filter_configure_xmlrpc($raw_params) {
services_dhcpd_configure();
services_dnsmasq_configure();
local_sync_accounts();
+
return $xmlrpc_g['return']['true'];
}
/*****************************/
-
$carp_configure_doc = gettext("Basic XMLRPC wrapper for configuring CARP interfaces.");
$carp_configure_sig = array(
- array(
- $XML_RPC_Boolean,
- $XML_RPC_String
- )
- );
+ array(
+ $XML_RPC_Boolean,
+ $XML_RPC_String
+ )
+);
function interfaces_carp_configure_xmlrpc($raw_params) {
global $xmlrpc_g;
+
$params = xmlrpc_params_to_php($raw_params);
- if(!xmlrpc_auth($params)) return $xmlrpc_g['return']['authfail'];
+ if(!xmlrpc_auth($params))
+ return $xmlrpc_g['return']['authfail'];
interfaces_vips_configure();
+
return $xmlrpc_g['return']['true'];
}
/*****************************/
-
$check_firmware_version_doc = gettext("Basic XMLRPC wrapper for check_firmware_version. This function will return the output of check_firmware_version upon completion.");
+
$check_firmware_version_sig = array(
- array(
- $XML_RPC_String,
- $XML_RPC_String
- )
- );
+ array(
+ $XML_RPC_String,
+ $XML_RPC_String
+ )
+);
function check_firmware_version_xmlrpc($raw_params) {
global $xmlrpc_g, $XML_RPC_String;
+
$params = xmlrpc_params_to_php($raw_params);
- if(!xmlrpc_auth($params)) return $xmlrpc_g['return']['authfail'];
+ if(!xmlrpc_auth($params))
+ return $xmlrpc_g['return']['authfail'];
+
return new XML_RPC_Response(new XML_RPC_Value(check_firmware_version(false), $XML_RPC_String));
}
/*****************************/
+$pfsense_firmware_version_doc = gettext("Basic XMLRPC wrapper for check_firmware_version. This function will return the output of check_firmware_version upon completion.");
+
+$pfsense_firmware_version_sig = array (
+ array (
+ $XML_RPC_Struct,
+ $XML_RPC_String
+ )
+);
+
+function pfsense_firmware_version_xmlrpc($raw_params) {
+ global $xmlrpc_g;
+ $params = xmlrpc_params_to_php($raw_params);
+ if(!xmlrpc_auth($params))
+ return $xmlrpc_g['return']['authfail'];
+
+ return new XML_RPC_Response(XML_RPC_encode(host_firmware_version()));
+}
+
+/*****************************/
$reboot_doc = gettext("Basic XMLRPC wrapper for rc.reboot.");
$reboot_sig = array(array($XML_RPC_Boolean, $XML_RPC_String));
-
function reboot_xmlrpc($raw_params) {
global $xmlrpc_g;
+
$params = xmlrpc_params_to_php($raw_params);
- if(!xmlrpc_auth($params)) return $xmlrpc_g['return']['authfail'];
+ if(!xmlrpc_auth($params))
+ return $xmlrpc_g['return']['authfail'];
mwexec_bg("/etc/rc.reboot");
+
return $xmlrpc_g['return']['true'];
}
/*****************************/
-
$get_notices_sig = array(
- array(
- $XML_RPC_Array,
- $XML_RPC_String
- ),
- array(
- $XML_RPC_Array
- )
- );
+ array(
+ $XML_RPC_Array,
+ $XML_RPC_String
+ ),
+ array(
+ $XML_RPC_Array
+ )
+);
function get_notices_xmlrpc($raw_params) {
global $g, $xmlrpc_g;
+
$params = xmlrpc_params_to_php($raw_params);
if(!xmlrpc_auth($params)) return $xmlrpc_g['return']['authfail'];
require("notices.inc");
@@ -329,44 +360,47 @@ function get_notices_xmlrpc($raw_params) {
$toreturn = get_notices($params);
}
$response = new XML_RPC_Response(XML_RPC_encode($toreturn));
+
return $response;
}
/*****************************/
-
$server = new XML_RPC_Server(
array(
- 'pfsense.exec_shell' => array('function' => 'exec_shell_xmlrpc',
- 'signature' => $exec_shell_sig,
- 'docstring' => $exec_shell_doc),
- 'pfsense.exec_php' => array('function' => 'exec_php_xmlrpc',
- 'signature' => $exec_php_sig,
- 'docstring' => $exec_php_doc),
- 'pfsense.filter_configure' => array('function' => 'filter_configure_xmlrpc',
- 'signature' => $filter_configure_sig,
- 'docstring' => $filter_configure_doc),
- 'pfsense.interfaces_carp_configure' => array('function' => 'interfaces_carp_configure_xmlrpc',
- 'docstring' => $carp_configure_sig),
- 'pfsense.backup_config_section' => array('function' => 'backup_config_section_xmlrpc',
- 'signature' => $backup_config_section_sig,
- 'docstring' => $backup_config_section_doc),
- 'pfsense.restore_config_section' => array('function' => 'restore_config_section_xmlrpc',
- 'signature' => $restore_config_section_sig,
- 'docstring' => $restore_config_section_doc),
- 'pfsense.merge_config_section' => array('function' => 'merge_config_section_xmlrpc',
- 'signature' => $merge_config_section_sig,
- 'docstring' => $merge_config_section_doc),
- 'pfsense.merge_installedpackages_section_xmlrpc' => array('function' => 'merge_installedpackages_section_xmlrpc',
- 'signature' => $merge_config_section_sig,
- 'docstring' => $merge_config_section_doc),
- 'pfsense.check_firmware_version' => array('function' => 'check_firmware_version_xmlrpc',
- 'signature' => $check_firmware_version_sig,
- 'docstring' => $check_firmware_version_doc),
- 'pfsense.reboot' => array('function' => 'reboot_xmlrpc',
- 'signature' => $reboot_sig,
- 'docstring' => $reboot_doc),
- 'pfsense.get_notices' => array('function' => 'get_notices_xmlrpc',
- 'signature' => $get_notices_sig)
+ 'pfsense.exec_shell' => array('function' => 'exec_shell_xmlrpc',
+ 'signature' => $exec_shell_sig,
+ 'docstring' => $exec_shell_doc),
+ 'pfsense.exec_php' => array('function' => 'exec_php_xmlrpc',
+ 'signature' => $exec_php_sig,
+ 'docstring' => $exec_php_doc),
+ 'pfsense.filter_configure' => array('function' => 'filter_configure_xmlrpc',
+ 'signature' => $filter_configure_sig,
+ 'docstring' => $filter_configure_doc),
+ 'pfsense.interfaces_carp_configure' => array('function' => 'interfaces_carp_configure_xmlrpc',
+ 'docstring' => $carp_configure_sig),
+ 'pfsense.backup_config_section' => array('function' => 'backup_config_section_xmlrpc',
+ 'signature' => $backup_config_section_sig,
+ 'docstring' => $backup_config_section_doc),
+ 'pfsense.restore_config_section' => array('function' => 'restore_config_section_xmlrpc',
+ 'signature' => $restore_config_section_sig,
+ 'docstring' => $restore_config_section_doc),
+ 'pfsense.merge_config_section' => array('function' => 'merge_config_section_xmlrpc',
+ 'signature' => $merge_config_section_sig,
+ 'docstring' => $merge_config_section_doc),
+ 'pfsense.merge_installedpackages_section_xmlrpc' => array('function' => 'merge_installedpackages_section_xmlrpc',
+ 'signature' => $merge_config_section_sig,
+ 'docstring' => $merge_config_section_doc),
+ 'pfsense.check_firmware_version' => array('function' => 'check_firmware_version_xmlrpc',
+ 'signature' => $check_firmware_version_sig,
+ 'docstring' => $check_firmware_version_doc),
+ 'pfsense.host_firmware_version' => array('function' => 'pfsense_firmware_version_xmlrpc',
+ 'signature' => $pfsense_firmware_version_sig,
+ 'docstring' => $host_firmware_version_doc),
+ 'pfsense.reboot' => array('function' => 'reboot_xmlrpc',
+ 'signature' => $reboot_sig,
+ 'docstring' => $reboot_doc),
+ 'pfsense.get_notices' => array('function' => 'get_notices_xmlrpc',
+ 'signature' => $get_notices_sig)
)
);
diff --git a/usr/sbin/pc-sysinstall/backend-query/Makefile b/usr/sbin/pc-sysinstall/backend-query/Makefile
index 0f14446..3b65d4e 100644
--- a/usr/sbin/pc-sysinstall/backend-query/Makefile
+++ b/usr/sbin/pc-sysinstall/backend-query/Makefile
@@ -1,10 +1,10 @@
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend-query/Makefile,v 1.5 2010/07/13 23:47:12 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend-query/Makefile,v 1.6 2010/08/19 05:59:27 imp Exp $
FILES= detect-laptop.sh detect-nics.sh detect-emulation.sh disk-info.sh \
disk-list.sh disk-part.sh enable-net.sh get-packages.sh list-config.sh \
list-components.sh list-mirrors.sh list-packages.sh list-rsync-backups.sh \
- list-tzones.sh query-langs.sh send-logs.sh setup-ssh-keys.sh sys-mem.sh \
- test-live.sh test-netup.sh update-part-list.sh xkeyboard-layouts.sh \
+ list-tzones.sh query-langs.sh send-logs.sh set-mirror.sh setup-ssh-keys.sh \
+ sys-mem.sh test-live.sh test-netup.sh update-part-list.sh xkeyboard-layouts.sh \
xkeyboard-models.sh xkeyboard-variants.sh
FILESMODE= ${BINMODE}
FILESDIR=${SHAREDIR}/pc-sysinstall/backend-query
diff --git a/usr/sbin/pc-sysinstall/backend-query/disk-info.sh b/usr/sbin/pc-sysinstall/backend-query/disk-info.sh
index 75c0386..f64bdb8 100755
--- a/usr/sbin/pc-sysinstall/backend-query/disk-info.sh
+++ b/usr/sbin/pc-sysinstall/backend-query/disk-info.sh
@@ -23,28 +23,20 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend-query/disk-info.sh,v 1.2 2010/06/27 16:46:11 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend-query/disk-info.sh,v 1.6 2010/10/28 06:45:20 imp Exp $
# Query a disk for partitions and display them
-#############################
+#############################################################################
. ${PROGDIR}/backend/functions.sh
. ${PROGDIR}/backend/functions-disk.sh
-if [ -z "${1}" ]
-then
- echo "Error: No disk specified!"
- exit 1
-fi
-
-if [ ! -e "/dev/${1}" ]
-then
- echo "Error: Disk /dev/${1} does not exist!"
- exit 1
-fi
-
DISK="${1}"
+[ -z "${DISK}" ] && { echo 'Error: No disk specified!'; exit 1; }
+[ ! -e "/dev/${DISK}" ] && \
+ { echo "Error: Disk /dev/${DISK} does not exist!"; exit 1; }
+
get_disk_cyl "${DISK}"
CYLS="${VAL}"
@@ -54,15 +46,15 @@ HEADS="${VAL}"
get_disk_sectors "${DISK}"
SECS="${VAL}"
-echo "cylinders=${CYLS}"
-echo "heads=${HEADS}"
-echo "sectors=${SECS}"
-
# Now get the disks size in MB
KB="`diskinfo -v ${1} | grep 'bytes' | cut -d '#' -f 1 | tr -s '\t' ' ' | tr -d ' '`"
MB=$(convert_byte_to_megabyte ${KB})
-echo "size=$MB"
# Now get the Controller Type
CTYPE="`dmesg | grep "^${1}:" | grep "B <" | cut -d '>' -f 2 | cut -d ' ' -f 3-10`"
-echo "type=$CTYPE"
+
+echo "cylinders=${CYLS}"
+echo "heads=${HEADS}"
+echo "sectors=${SECS}"
+echo "size=${MB}"
+echo "type=${CTYPE}"
diff --git a/usr/sbin/pc-sysinstall/backend-query/disk-list.sh b/usr/sbin/pc-sysinstall/backend-query/disk-list.sh
index 06bf04b..d836a82 100755
--- a/usr/sbin/pc-sysinstall/backend-query/disk-list.sh
+++ b/usr/sbin/pc-sysinstall/backend-query/disk-list.sh
@@ -23,10 +23,40 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend-query/disk-list.sh,v 1.2 2010/06/27 16:46:11 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend-query/disk-list.sh,v 1.5 2010/09/08 20:10:24 imp Exp $
+
+ARGS=$1
+FLAGS_MD=""
+FLAGS_CD=""
+FLAGS_VERBOSE=""
+
+shift
+while [ -n "$1" ]
+do
+ case "$1" in
+ -m)
+ FLAGS_MD=1
+ ;;
+ -v)
+ FLAGS_VERBOSE=1
+ ;;
+ -c)
+ FLAGS_CD=1
+ ;;
+ esac
+ shift
+done
# Create our device listing
SYSDISK=$(sysctl -n kern.disks)
+if [ -n "${FLAGS_MD}" ]
+then
+ MDS=`mdconfig -l`
+ if [ -n "${MDS}" ]
+ then
+ SYSDISK="${SYSDISK} ${MDS}"
+ fi
+fi
# Now loop through these devices, and list the disk drives
for i in ${SYSDISK}
@@ -36,9 +66,12 @@ do
DEV="${i}"
# Make sure we don't find any cd devices
- case "${DEV}" in
- acd[0-9]*|cd[0-9]*|scd[0-9]*) continue ;;
- esac
+ if [ -z "${FLAGS_CD}" ]
+ then
+ case "${DEV}" in
+ acd[0-9]*|cd[0-9]*|scd[0-9]*) continue ;;
+ esac
+ fi
# Check the dmesg output for some more info about this device
NEWLINE=$(dmesg | sed -n "s/^$DEV: .*<\(.*\)>.*$/ <\1>/p" | head -n 1)
@@ -46,6 +79,16 @@ do
NEWLINE=" <Unknown Device>"
fi
+ if [ -n "${FLAGS_MD}" ] && echo "${DEV}" | grep -E '^md[0-9]+' >/dev/null 2>/dev/null
+ then
+ NEWLINE=" <Memory Disk>"
+ fi
+
+ if [ -n "${FLAGS_VERBOSE}" ]
+ then
+ :
+ fi
+
# Save the disk list
if [ ! -z "$DLIST" ]
then
diff --git a/usr/sbin/pc-sysinstall/backend-query/disk-part.sh b/usr/sbin/pc-sysinstall/backend-query/disk-part.sh
index 9ddd47d..6e921ee 100755
--- a/usr/sbin/pc-sysinstall/backend-query/disk-part.sh
+++ b/usr/sbin/pc-sysinstall/backend-query/disk-part.sh
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend-query/disk-part.sh,v 1.2 2010/06/27 16:46:11 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend-query/disk-part.sh,v 1.3 2010/08/24 06:11:46 imp Exp $
# Query a disk for partitions and display them
#############################
@@ -51,8 +51,6 @@ MB=$(convert_byte_to_megabyte ${KB})
TOTALSIZE="$MB"
TOTALB="`diskinfo -v ${1} | grep 'in sectors' | tr -s '\t' ' ' | cut -d ' ' -f 2`"
-
-
gpart show ${1} >/dev/null 2>/dev/null
if [ "$?" != "0" ] ; then
# No partitions on this disk, display entire disk size and exit
@@ -85,14 +83,14 @@ do
# First get the sysid / label for this partition
if [ "$TYPE" = "MBR" ] ; then
- get_partition_sysid_mbr "${DISK}" "${curpart}"
- echo "${curpart}-sysid: ${VAL}"
- get_partition_label_mbr "${DISK}" "${curpart}"
- echo "${curpart}-label: ${VAL}"
+ get_partition_sysid_mbr "${DISK}" "${curpart}"
+ echo "${curpart}-sysid: ${VAL}"
+ get_partition_label_mbr "${DISK}" "${curpart}"
+ echo "${curpart}-label: ${VAL}"
else
- get_partition_label_gpt "${DISK}" "${curpart}"
- echo "${curpart}-sysid: ${VAL}"
- echo "${curpart}-label: ${VAL}"
+ get_partition_label_gpt "${DISK}" "${curpart}"
+ echo "${curpart}-sysid: ${VAL}"
+ echo "${curpart}-label: ${VAL}"
fi
# Now get the startblock, blocksize and MB size of this partition
diff --git a/usr/sbin/pc-sysinstall/backend-query/enable-net.sh b/usr/sbin/pc-sysinstall/backend-query/enable-net.sh
index 9d40142..339a562 100755
--- a/usr/sbin/pc-sysinstall/backend-query/enable-net.sh
+++ b/usr/sbin/pc-sysinstall/backend-query/enable-net.sh
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend-query/enable-net.sh,v 1.2 2010/06/27 16:46:11 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend-query/enable-net.sh,v 1.3 2010/08/24 06:11:46 imp Exp $
# Script which enables networking with specified options
###########################################################################
@@ -60,6 +60,6 @@ else
fi
case ${MIRRORFETCH} in
- ON|on|yes|YES) fetch -o /tmp/mirrors-list.txt ${MIRRORLIST} >/dev/null 2>/dev/null;;
- *) ;;
+ ON|on|yes|YES) fetch -o /tmp/mirrors-list.txt ${MIRRORLIST} >/dev/null 2>/dev/null;;
+ *) ;;
esac
diff --git a/usr/sbin/pc-sysinstall/backend-query/get-packages.sh b/usr/sbin/pc-sysinstall/backend-query/get-packages.sh
index 4ff17f6..7427326 100755
--- a/usr/sbin/pc-sysinstall/backend-query/get-packages.sh
+++ b/usr/sbin/pc-sysinstall/backend-query/get-packages.sh
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend-query/get-packages.sh,v 1.1 2010/07/13 23:47:12 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend-query/get-packages.sh,v 1.3 2010/08/24 06:11:46 imp Exp $
# Script which lists the available packages for this release
###########################################################################
@@ -31,30 +31,22 @@
. ${PROGDIR}/backend/functions.sh
. ${PROGDIR}/backend/functions-packages.sh
-DEFAULT_FTP_SERVER="ftp.freebsd.org"
-FTP_SERVER="${1}"
ID=`id -u`
-
if [ "${ID}" -ne "0" ]
then
- echo "Error: must be root!"
- exit 1
-fi
-
-if [ -z "${FTP_SERVER}" ]
-then
- FTP_SERVER="${DEFAULT_FTP_SERVER}"
+ echo "Error: must be root!"
+ exit 1
fi
if [ ! -f "${PKGDIR}/INDEX" ]
then
- get_package_index "${FTP_SERVER}"
+ get_package_index
fi
if [ -f "${PKGDIR}/INDEX" ]
then
- echo "${PKGDIR}/INDEX"
- exit 0
+ echo "${PKGDIR}/INDEX"
+ exit 0
fi
exit 1
diff --git a/usr/sbin/pc-sysinstall/backend-query/list-components.sh b/usr/sbin/pc-sysinstall/backend-query/list-components.sh
index 299ce28..e55233e 100755
--- a/usr/sbin/pc-sysinstall/backend-query/list-components.sh
+++ b/usr/sbin/pc-sysinstall/backend-query/list-components.sh
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend-query/list-components.sh,v 1.2 2010/06/27 16:46:11 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend-query/list-components.sh,v 1.3 2010/10/21 17:23:48 imp Exp $
# Script which lists the available components for this release
###########################################################################
@@ -32,23 +32,24 @@
echo "Available Components:"
-cd ${COMPDIR}
-for i in `ls -d *`
-do
- if [ -e "${i}/component.cfg" -a -e "${i}/install.sh" -a -e "${i}/distfiles" ]
- then
- NAME="`grep 'name:' ${i}/component.cfg | cut -d ':' -f 2`"
- DESC="`grep 'description:' ${i}/component.cfg | cut -d ':' -f 2`"
- TYPE="`grep 'type:' ${i}/component.cfg | cut -d ':' -f 2`"
- echo " "
- echo "name: ${i}"
- echo "desc:${DESC}"
- echo "type:${TYPE}"
- if [ -e "${i}/component.png" ]
+if [ -d "${COMPDIR}" ]
+then
+ cd ${COMPDIR}
+ for i in `ls -d *`
+ do
+ if [ -e "${i}/component.cfg" -a -e "${i}/install.sh" -a -e "${i}/distfiles" ]
then
- echo "icon: ${COMPDIR}/${i}/component.png"
+ NAME="`grep 'name:' ${i}/component.cfg | cut -d ':' -f 2`"
+ DESC="`grep 'description:' ${i}/component.cfg | cut -d ':' -f 2`"
+ TYPE="`grep 'type:' ${i}/component.cfg | cut -d ':' -f 2`"
+ echo " "
+ echo "name: ${i}"
+ echo "desc:${DESC}"
+ echo "type:${TYPE}"
+ if [ -e "${i}/component.png" ]
+ then
+ echo "icon: ${COMPDIR}/${i}/component.png"
+ fi
fi
- fi
-
-done
-
+ done
+fi
diff --git a/usr/sbin/pc-sysinstall/backend-query/list-packages.sh b/usr/sbin/pc-sysinstall/backend-query/list-packages.sh
index dcf7c00..97bec8c 100755
--- a/usr/sbin/pc-sysinstall/backend-query/list-packages.sh
+++ b/usr/sbin/pc-sysinstall/backend-query/list-packages.sh
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend-query/list-packages.sh,v 1.1 2010/07/13 23:47:12 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend-query/list-packages.sh,v 1.3 2010/08/24 06:11:46 imp Exp $
# Script which lists the available packages for this release
###########################################################################
@@ -37,38 +37,50 @@ NARGS=0
if [ ! -f "${PKGDIR}/INDEX" ]
then
- echo "Error: please fetch package index with get-packages!"
- exit 1
+ echo "Error: please fetch package index with get-packages!"
+ exit 1
fi
if [ ! -f "${PKGDIR}/INDEX.parsed" ]
then
- parse_package_index
+ parse_package_index
fi
if [ -n "${PACKAGE_CATEGORY}" ]
then
- NARGS=$((NARGS+1))
+ NARGS=$((NARGS+1))
fi
if [ -n "${PACKAGE_NAME}" ]
then
- NARGS=$((NARGS+1))
+ NARGS=$((NARGS+1))
fi
-echo "Available Packages:"
if [ "${NARGS}" -eq "0" ]
then
- show_packages
+ show_packages
elif [ "${NARGS}" -eq "1" ]
then
- show_packages_by_category "${PACKAGE_CATEGORY}"
+
+ if [ "${PACKAGE_CATEGORY}" = "@INDEX@" ]
+ then
+ if [ -f "${PKGDIR}/INDEX" ]
+ then
+ echo "${PKGDIR}/INDEX"
+ exit 0
+ else
+ exit 1
+ fi
+
+ else
+ show_packages_by_category "${PACKAGE_CATEGORY}"
+ fi
elif [ "${NARGS}" -eq "2" ]
then
- show_package_by_name "${PACKAGE_CATEGORY}" "${PACKAGE_NAME}"
+ show_package_by_name "${PACKAGE_CATEGORY}" "${PACKAGE_NAME}"
else
- show_packages
+ show_packages
fi
diff --git a/usr/sbin/pc-sysinstall/backend-query/list-tzones.sh b/usr/sbin/pc-sysinstall/backend-query/list-tzones.sh
index 973f892..7e4bac4 100755
--- a/usr/sbin/pc-sysinstall/backend-query/list-tzones.sh
+++ b/usr/sbin/pc-sysinstall/backend-query/list-tzones.sh
@@ -23,21 +23,12 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend-query/list-tzones.sh,v 1.2 2010/06/27 16:46:11 imp Exp $
-
-rm ${TMPDIR}/.tzonetmp >/dev/null 2>/dev/null
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend-query/list-tzones.sh,v 1.3 2010/10/19 15:18:40 emaste Exp $
# Backend script which lists all the available timezones for front-ends to display
-while read line
-do
- echo "$line" | grep "^#" >/dev/null 2>/dev/null
- if [ "$?" != "0" ]
- then
- echo "$line" | tr -s "\t" ":" | cut -d ":" -f 3-4 >>${TMPDIR}/.tzonetmp
- fi
-done < /usr/share/zoneinfo/zone.tab
-
-sort ${TMPDIR}/.tzonetmp
-rm -f ${TMPDIR}/.tzonetmp >/dev/null 2>/dev/null
+egrep -v '^#' /usr/share/zoneinfo/zone.tab |\
+ tr -s "\t" ":" |\
+ cut -d ":" -f 3-4 |\
+ sort
exit 0
diff --git a/usr/sbin/pc-sysinstall/backend-query/query-langs.sh b/usr/sbin/pc-sysinstall/backend-query/query-langs.sh
index 044f41b..336e8dd 100755
--- a/usr/sbin/pc-sysinstall/backend-query/query-langs.sh
+++ b/usr/sbin/pc-sysinstall/backend-query/query-langs.sh
@@ -23,9 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend-query/query-langs.sh,v 1.2 2010/06/27 16:46:11 imp Exp $
-
-FOUND="0"
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend-query/query-langs.sh,v 1.3 2010/10/22 00:10:48 imp Exp $
cat ${PROGDIR}/conf/avail-langs
diff --git a/usr/sbin/pc-sysinstall/backend-query/set-mirror.sh b/usr/sbin/pc-sysinstall/backend-query/set-mirror.sh
new file mode 100644
index 0000000..fe4daf8
--- /dev/null
+++ b/usr/sbin/pc-sysinstall/backend-query/set-mirror.sh
@@ -0,0 +1,40 @@
+#!/bin/sh
+#-
+# Copyright (c) 2010 iXSystems, Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend-query/set-mirror.sh,v 1.2 2010/08/24 06:11:46 imp Exp $
+
+. ${PROGDIR}/backend/functions.sh
+. ${PROGDIR}/backend/functions-ftp.sh
+
+MIRROR="${1}"
+
+if [ -z "${MIRROR}" ]
+then
+ echo "Error: No mirror specified!"
+ exit 1
+fi
+
+set_ftp_mirror "${MIRROR}"
+exit 0
diff --git a/usr/sbin/pc-sysinstall/backend-query/sys-mem.sh b/usr/sbin/pc-sysinstall/backend-query/sys-mem.sh
index 6fcf9b2..8577c29 100755
--- a/usr/sbin/pc-sysinstall/backend-query/sys-mem.sh
+++ b/usr/sbin/pc-sysinstall/backend-query/sys-mem.sh
@@ -23,9 +23,6 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend-query/sys-mem.sh,v 1.2 2010/06/27 16:46:11 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend-query/sys-mem.sh,v 1.3 2010/10/19 15:12:16 emaste Exp $
-MEM=`sysctl hw.realmem | sed "s|hw.realmem: ||g"`
-MEM=`expr $MEM / 1024`
-MEM=`expr $MEM / 1024`
-echo $MEM
+expr $(sysctl -n hw.realmem) / 1048576
diff --git a/usr/sbin/pc-sysinstall/backend-query/test-live.sh b/usr/sbin/pc-sysinstall/backend-query/test-live.sh
index 7c61cae..43f4298 100755
--- a/usr/sbin/pc-sysinstall/backend-query/test-live.sh
+++ b/usr/sbin/pc-sysinstall/backend-query/test-live.sh
@@ -23,18 +23,11 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend-query/test-live.sh,v 1.2 2010/06/27 16:46:11 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend-query/test-live.sh,v 1.3 2010/10/22 00:11:55 imp Exp $
# Script which checks if we are running from install media, or real system
#############################################################################
-dmesg | grep "md0: Preloaded image" >/dev/null 2>/dev/null
-if [ "$?" = "0" ]
-then
- echo "INSTALL-MEDIA"
- exit 0
-else
- echo "REAL-DISK"
- exit 1
-fi
+dmesg | grep -q 'md0: Preloaded image' || { echo 'REAL-DISK'; exit 1; }
+echo 'INSTALL-MEDIA'
diff --git a/usr/sbin/pc-sysinstall/backend-query/test-netup.sh b/usr/sbin/pc-sysinstall/backend-query/test-netup.sh
index dc8c71a..aa3e277 100755
--- a/usr/sbin/pc-sysinstall/backend-query/test-netup.sh
+++ b/usr/sbin/pc-sysinstall/backend-query/test-netup.sh
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend-query/test-netup.sh,v 1.2 2010/06/27 16:46:11 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend-query/test-netup.sh,v 1.3 2010/08/24 06:11:46 imp Exp $
# Script which tests "fetch" when using a network connection, and saves
@@ -35,15 +35,15 @@ rm ${TMPDIR}/.testftp >/dev/null 2>/dev/null
ping -c 2 www.pcbsd.org >/dev/null 2>/dev/null
if [ "$?" = "0" ]
then
- echo "ftp: Up"
- exit 0
+ echo "ftp: Up"
+ exit 0
fi
ping -c 2 www.freebsd.org >/dev/null 2>/dev/null
if [ "$?" = "0" ]
then
- echo "ftp: Up"
- exit 0
+ echo "ftp: Up"
+ exit 0
fi
echo "ftp: Down"
diff --git a/usr/sbin/pc-sysinstall/backend-query/update-part-list.sh b/usr/sbin/pc-sysinstall/backend-query/update-part-list.sh
index 9a2a77e..7fb87ec 100755
--- a/usr/sbin/pc-sysinstall/backend-query/update-part-list.sh
+++ b/usr/sbin/pc-sysinstall/backend-query/update-part-list.sh
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend-query/update-part-list.sh,v 1.2 2010/06/27 16:46:11 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend-query/update-part-list.sh,v 1.3 2010/08/24 06:11:46 imp Exp $
# Need access to a some unmount functions
. ${PROGDIR}/backend/functions-unmount.sh
@@ -35,16 +35,17 @@ rm ${TMPDIR}/AvailUpgrades >/dev/null 2>/dev/null
FSMNT="/mnt"
# Get the freebsd version on this partition
-get_fbsd_ver() {
+get_fbsd_ver()
+{
VER="`file ${FSMNT}/bin/sh | grep 'for FreeBSD' | sed 's|for FreeBSD |;|g' | cut -d ';' -f 2 | cut -d ',' -f 1`"
if [ "$?" = "0" ] ; then
- file ${FSMNT}/bin/sh | grep '32-bit' >/dev/null 2>/dev/null
- if [ "${?}" = "0" ] ; then
- echo "${1}: FreeBSD ${VER} (32bit)"
- else
- echo "${1}: FreeBSD ${VER} (64bit)"
- fi
+ file ${FSMNT}/bin/sh | grep '32-bit' >/dev/null 2>/dev/null
+ if [ "${?}" = "0" ] ; then
+ echo "${1}: FreeBSD ${VER} (32bit)"
+ else
+ echo "${1}: FreeBSD ${VER} (64bit)"
+ fi
fi
}
@@ -62,7 +63,7 @@ do
# Make sure we don't find any cd devices
echo "${DEV}" | grep -e "^acd[0-9]" -e "^cd[0-9]" -e "^scd[0-9]" >/dev/null 2>/dev/null
if [ "$?" != "0" ] ; then
- DEVS="${DEVS} `ls /dev/${i}*`"
+ DEVS="${DEVS} `ls /dev/${i}*`"
fi
done
@@ -70,25 +71,25 @@ done
# Search for regular UFS / Geom Partitions to upgrade
for i in $DEVS
do
- if [ ! -e "${i}a.journal" -a ! -e "${i}a" -a ! -e "${i}p2" -a ! -e "${i}p2.journal" ] ; then
- continue
- fi
+ if [ ! -e "${i}a.journal" -a ! -e "${i}a" -a ! -e "${i}p2" -a ! -e "${i}p2.journal" ] ; then
+ continue
+ fi
- if [ -e "${i}a.journal" ] ; then
- _dsk="${i}a.journal"
- elif [ -e "${i}a" ] ; then
- _dsk="${i}a"
- elif [ -e "${i}p2" ] ; then
- _dsk="${i}p2"
- elif [ -e "${i}p2.journal" ] ; then
- _dsk="${i}p2.journal"
- fi
+ if [ -e "${i}a.journal" ] ; then
+ _dsk="${i}a.journal"
+ elif [ -e "${i}a" ] ; then
+ _dsk="${i}a"
+ elif [ -e "${i}p2" ] ; then
+ _dsk="${i}p2"
+ elif [ -e "${i}p2.journal" ] ; then
+ _dsk="${i}p2.journal"
+ fi
- mount -o ro ${_dsk} ${FSMNT} >>${LOGOUT} 2>>${LOGOUT}
- if [ "${?}" = "0" -a -e "${FSMNT}/bin/sh" ] ; then
- get_fbsd_ver "`echo ${_dsk} | sed 's|/dev/||g'`"
- umount -f ${FSMNT} >/dev/null 2>/dev/null
- fi
+ mount -o ro ${_dsk} ${FSMNT} >>${LOGOUT} 2>>${LOGOUT}
+ if [ "${?}" = "0" -a -e "${FSMNT}/bin/sh" ] ; then
+ get_fbsd_ver "`echo ${_dsk} | sed 's|/dev/||g'`"
+ umount -f ${FSMNT} >/dev/null 2>/dev/null
+ fi
done
# Now search for any ZFS root partitions
@@ -101,9 +102,9 @@ umount_all_dir "${FSMNT}"
_zps="`zpool list | grep -v 'NAME' | cut -d ' ' -f 1`"
for _zpools in ${_zps}
do
- mount -o ro -t zfs ${_zpools} ${FSMNT} >>${LOGOUT} 2>>${LOGOUT}
- if [ "${?}" = "0" -a -e "${FSMNT}/bin/sh" ] ; then
- get_fbsd_ver "${_zpools}"
- umount -f ${FSMNT} >/dev/null 2>/dev/null
- fi
+ mount -o ro -t zfs ${_zpools} ${FSMNT} >>${LOGOUT} 2>>${LOGOUT}
+ if [ "${?}" = "0" -a -e "${FSMNT}/bin/sh" ] ; then
+ get_fbsd_ver "${_zpools}"
+ umount -f ${FSMNT} >/dev/null 2>/dev/null
+ fi
done
diff --git a/usr/sbin/pc-sysinstall/backend-query/xkeyboard-layouts.sh b/usr/sbin/pc-sysinstall/backend-query/xkeyboard-layouts.sh
index 5257d5c..372696f 100755
--- a/usr/sbin/pc-sysinstall/backend-query/xkeyboard-layouts.sh
+++ b/usr/sbin/pc-sysinstall/backend-query/xkeyboard-layouts.sh
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend-query/xkeyboard-layouts.sh,v 1.2 2010/06/27 16:46:11 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend-query/xkeyboard-layouts.sh,v 1.3 2010/08/24 06:11:46 imp Exp $
FOUND="0"
@@ -36,7 +36,7 @@ do
echo $line | grep '! ' >/dev/null 2>/dev/null
if [ "$?" = "0" ]
then
- exit 0
+ exit 0
else
echo "$line"
fi
diff --git a/usr/sbin/pc-sysinstall/backend-query/xkeyboard-models.sh b/usr/sbin/pc-sysinstall/backend-query/xkeyboard-models.sh
index 4fdf652..f8e72c2 100755
--- a/usr/sbin/pc-sysinstall/backend-query/xkeyboard-models.sh
+++ b/usr/sbin/pc-sysinstall/backend-query/xkeyboard-models.sh
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend-query/xkeyboard-models.sh,v 1.2 2010/06/27 16:46:11 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend-query/xkeyboard-models.sh,v 1.3 2010/08/24 06:11:46 imp Exp $
FOUND="0"
@@ -36,7 +36,7 @@ do
echo $line | grep '! ' >/dev/null 2>/dev/null
if [ "$?" = "0" ]
then
- exit 0
+ exit 0
else
model="`echo $line | sed 's|(|[|g'`"
model="`echo $model | sed 's|)|]|g'`"
diff --git a/usr/sbin/pc-sysinstall/backend-query/xkeyboard-variants.sh b/usr/sbin/pc-sysinstall/backend-query/xkeyboard-variants.sh
index 8886bc8..cff6b0e 100755
--- a/usr/sbin/pc-sysinstall/backend-query/xkeyboard-variants.sh
+++ b/usr/sbin/pc-sysinstall/backend-query/xkeyboard-variants.sh
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend-query/xkeyboard-variants.sh,v 1.2 2010/06/27 16:46:11 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend-query/xkeyboard-variants.sh,v 1.3 2010/08/24 06:11:46 imp Exp $
FOUND="0"
@@ -36,7 +36,7 @@ do
echo $line | grep '! ' >/dev/null 2>/dev/null
if [ "$?" = "0" ]
then
- exit 0
+ exit 0
else
echo "$line"
fi
diff --git a/usr/sbin/pc-sysinstall/backend/Makefile b/usr/sbin/pc-sysinstall/backend/Makefile
index b4c517b..2b4693d 100755
--- a/usr/sbin/pc-sysinstall/backend/Makefile
+++ b/usr/sbin/pc-sysinstall/backend/Makefile
@@ -1,13 +1,13 @@
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/Makefile,v 1.4 2010/07/13 23:47:12 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/Makefile,v 1.6 2010/09/08 20:10:24 imp Exp $
FILES= functions-bsdlabel.sh functions-cleanup.sh functions-disk.sh \
functions-extractimage.sh functions-ftp.sh functions-installcomponents.sh \
- functions-localize.sh functions-mountdisk.sh \
+ functions-installpackages.sh functions-localize.sh functions-mountdisk.sh \
functions-mountoptical.sh functions-networking.sh \
functions-newfs.sh functions-packages.sh functions-parse.sh \
functions-runcommands.sh functions-unmount.sh \
functions-upgrade.sh functions-users.sh \
- functions.sh parseconfig.sh startautoinstall.sh
+ functions.sh parseconfig.sh startautoinstall.sh installimage.sh
FILESMODE= ${BINMODE}
FILESDIR=${SHAREDIR}/pc-sysinstall/backend
NO_OBJ=
diff --git a/usr/sbin/pc-sysinstall/backend/functions-bsdlabel.sh b/usr/sbin/pc-sysinstall/backend/functions-bsdlabel.sh
index c8cb4f1..316b46c 100755
--- a/usr/sbin/pc-sysinstall/backend/functions-bsdlabel.sh
+++ b/usr/sbin/pc-sysinstall/backend/functions-bsdlabel.sh
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh,v 1.2 2010/06/27 16:46:11 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh,v 1.9 2010/10/21 22:46:10 imp Exp $
# Functions related to disk operations using bsdlabel
@@ -58,20 +58,13 @@ get_fs_line_xvars()
echo $LINE | grep '^ZFS' >/dev/null 2>/dev/null
if [ "$?" = "0" ] ; then
ZTYPE="NONE"
- ZFSVARS="`echo $LINE | cut -d '(' -f 2- | cut -d ')' -f 1`"
+ ZFSVARS="`echo $LINE | cut -d '(' -f 2- | cut -d ')' -f 1 | xargs`"
- # Check if we are doing raidz setup
- echo $ZFSVARS | grep "^raidz:" >/dev/null 2>/dev/null
- if [ "$?" = "0" ] ; then
- ZTYPE="raidz"
- ZFSVARS="`echo $ZFSVARS | sed 's|raidz: ||g' | sed 's|raidz:||g'`"
- fi
-
- echo $ZFSVARS | grep "^mirror:" >/dev/null 2>/dev/null
- if [ "$?" = "0" ] ; then
- ZTYPE="mirror"
- ZFSVARS="`echo $ZFSVARS | sed 's|mirror: ||g' | sed 's|mirror:||g'`"
- fi
+ echo $ZFSVARS | grep -E "^(disk|file|mirror|raidz(1|2)?|spare|log|cache):" >/dev/null 2>/dev/null
+ if [ "$?" = "0" ] ; then
+ ZTYPE=`echo $ZFSVARS | cut -f1 -d:`
+ ZFSVARS=`echo $ZFSVARS | sed "s|$ZTYPE: ||g" | sed "s|$ZTYPE:||g"`
+ fi
# Return the ZFS options
if [ "${ZTYPE}" = "NONE" ] ; then
@@ -83,7 +76,6 @@ get_fs_line_xvars()
return
fi # End of ZFS block
-
fi # End of xtra-options block
# If we got here, set VAR to empty and export
@@ -93,30 +85,31 @@ get_fs_line_xvars()
};
# Init each zfs mirror disk with a boot sector so we can failover
-setup_zfs_mirror_parts() {
-
- _nZFS=""
- # Using mirroring, setup boot partitions on each disk
- _mirrline="`echo ${1} | sed 's|mirror ||g'`"
- for _zvars in $_mirrline
- do
- echo "Looping through _zvars: $_zvars" >>${LOGOUT}
- echo "$_zvars" | grep "${2}" >/dev/null 2>/dev/null
- if [ "$?" = "0" ] ; then continue ; fi
- if [ -z "$_zvars" ] ; then continue ; fi
-
- is_disk "$_zvars" >/dev/null 2>/dev/null
- if [ "$?" = "0" ] ; then
- echo "Setting up ZFS mirror disk $_zvars" >>${LOGOUT}
- init_gpt_full_disk "$_zvars" >/dev/null 2>/dev/null
- rc_halt "gpart bootcode -p /boot/gptzfsboot -i 1 ${_zvars}" >/dev/null 2>/dev/null
- rc_halt "gpart add -t freebsd-zfs ${_zvars}" >/dev/null 2>/dev/null
- _nZFS="$_nZFS ${_zvars}p2"
- else
- _nZFS="$_nZFS ${_zvars}"
- fi
- done
- echo "mirror $2 `echo $_nZFS | tr -s ' '`"
+setup_zfs_mirror_parts()
+{
+ _nZFS=""
+
+ # Using mirroring, setup boot partitions on each disk
+ _mirrline="`echo ${1} | sed 's|mirror ||g'`"
+ for _zvars in $_mirrline
+ do
+ echo "Looping through _zvars: $_zvars" >>${LOGOUT}
+ echo "$_zvars" | grep "${2}" >/dev/null 2>/dev/null
+ if [ "$?" = "0" ] ; then continue ; fi
+ if [ -z "$_zvars" ] ; then continue ; fi
+
+ is_disk "$_zvars" >/dev/null 2>/dev/null
+ if [ "$?" = "0" ] ; then
+ echo "Setting up ZFS mirror disk $_zvars" >>${LOGOUT}
+ init_gpt_full_disk "$_zvars" >/dev/null 2>/dev/null
+ rc_halt "gpart bootcode -p /boot/gptzfsboot -i 1 ${_zvars}" >/dev/null 2>/dev/null
+ rc_halt "gpart add -t freebsd-zfs ${_zvars}" >/dev/null 2>/dev/null
+ _nZFS="$_nZFS ${_zvars}p2"
+ else
+ _nZFS="$_nZFS ${_zvars}"
+ fi
+ done
+ echo "mirror $2 `echo $_nZFS | tr -s ' '`"
} ;
# Function which creates a unique label name for the specified mount
@@ -168,12 +161,10 @@ gen_glabel_name()
# Function to setup / stamp a legacy MBR bsdlabel
setup_mbr_partitions()
{
-
DISKTAG="$1"
WRKSLICE="$2"
FOUNDPARTS="1"
-
# Lets setup the BSDLABEL
BSDLABEL="${TMPDIR}/bsdLabel-${WRKSLICE}"
export BSDLABEL
@@ -201,6 +192,11 @@ setup_mbr_partitions()
SIZE=`echo $STRING | tr -s '\t' ' ' | cut -d ' ' -f 2`
MNT=`echo $STRING | tr -s '\t' ' ' | cut -d ' ' -f 3`
+ if echo $STRING | grep -E '^/.+' >/dev/null 2>&1
+ then
+ IMAGE=`echo ${STRING} | cut -f1 -d' '`
+ fi
+
# Check if we have a .eli extension on this FS
echo ${FS} | grep ".eli" >/dev/null 2>/dev/null
if [ "$?" = "0" ]
@@ -223,9 +219,17 @@ setup_mbr_partitions()
USINGENCROOT="0" ; export USINGENCROOT
fi
+ if [ -n "${IMAGE}" ]
+ then
+ FS="IMAGE"
+ SIZE=`ls -l "${IMAGE}" | awk '{ print $5 }'`
+ MNT=`echo $STRING | tr -s '\t' ' ' | cut -d ' ' -f 2`
+ SIZE=`convert_byte_to_megabyte $SIZE`
+ fi
+
# Now check that these values are sane
case $FS in
- UFS|UFS+S|UFS+J|ZFS|SWAP) ;;
+ UFS|UFS+S|UFS+J|UFS+SUJ|ZFS|SWAP|IMAGE) ;;
*) exit_err "ERROR: Invalid file system specified on $line" ;;
esac
@@ -262,20 +266,20 @@ setup_mbr_partitions()
# Check if we found a valid root partition
check_for_mount "${MNT}" "/"
if [ "$?" = "0" ] ; then
- FOUNDROOT="0" ; export FOUNDROOT
+ FOUNDROOT="0" ; export FOUNDROOT
fi
# Check if we have a "/boot" instead
check_for_mount "${MNT}" "/boot"
if [ "${?}" = "0" ] ; then
USINGBOOTPART="0" ; export USINGBOOTPART
- if [ "${FS}" != "UFS" -a "${FS}" != "UFS+S" -a "${FS}" != "UFS+J" ]
+ if [ "${FS}" != "UFS" -a "${FS}" != "UFS+S" -a "${FS}" != "UFS+J" -a "${FS}" != "UFS+SUJ" ]
then
exit_err "/boot partition must be formatted with UFS"
fi
fi
- else
+ else
# Done with the a: partitions
# Check if we found a valid root partition not on a:
@@ -314,7 +318,7 @@ setup_mbr_partitions()
fi
# Save this data to our partition config dir
- echo "${FS}:${MNT}:${ENC}:${PLABEL}:MBR:${XTRAOPTS}" >${PARTDIR}/${WRKSLICE}${PARTLETTER}
+ echo "${FS}:${MNT}:${ENC}:${PLABEL}:MBR:${XTRAOPTS}:${IMAGE}" >${PARTDIR}/${WRKSLICE}${PARTLETTER}
# If we have a enc password, save it as well
if [ ! -z "${ENCPASS}" ] ; then
@@ -323,18 +327,20 @@ setup_mbr_partitions()
# This partition letter is used, get the next one
case ${PARTLETTER} in
- a) PARTLETTER="b" ;;
- b) # When we hit b, add the special c: setup for bsdlabel
- echo "c: * * unused" >>${BSDLABEL}
- PARTLETTER="d" ;;
- d) PARTLETTER="e" ;;
- e) PARTLETTER="f" ;;
- f) PARTLETTER="g" ;;
- g) PARTLETTER="h" ;;
- h) PARTLETTER="ERR" ;;
- *) exit_err "ERROR: bsdlabel only supports up to letter h for partitions." ;;
+ a) PARTLETTER="b" ;;
+ b) # When we hit b, add the special c: setup for bsdlabel
+ echo "c: * * unused" >>${BSDLABEL}
+ PARTLETTER="d" ;;
+ d) PARTLETTER="e" ;;
+ e) PARTLETTER="f" ;;
+ f) PARTLETTER="g" ;;
+ g) PARTLETTER="h" ;;
+ h) PARTLETTER="ERR" ;;
+ *) exit_err "ERROR: bsdlabel only supports up to letter h for partitions." ;;
esac
+ unset IMAGE
+
fi # End of subsection locating a slice in config
echo $line | grep "^commitDiskLabel" >/dev/null 2>/dev/null
@@ -409,7 +415,7 @@ setup_gpt_partitions()
# Now check that these values are sane
case $FS in
- UFS|UFS+S|UFS+J|ZFS|SWAP) ;;
+ UFS|UFS+S|UFS+J|UFS+SUJ|ZFS|SWAP) ;;
*) exit_err "ERROR: Invalid file system specified on $line" ;;
esac
@@ -446,7 +452,7 @@ setup_gpt_partitions()
if [ "${?}" = "0" ] ; then
if [ "${CURPART}" = "2" ] ; then
USINGBOOTPART="0" ; export USINGBOOTPART
- if [ "${FS}" != "UFS" -a "${FS}" != "UFS+S" -a "${FS}" != "UFS+J" ]
+ if [ "${FS}" != "UFS" -a "${FS}" != "UFS+S" -a "${FS}" != "UFS+J" -a "${FS}" != "UFS+SUJ" ]
then
exit_err "/boot partition must be formatted with UFS"
fi
@@ -471,9 +477,9 @@ setup_gpt_partitions()
# Figure out the gpart type to use
case ${FS} in
- ZFS) PARTYPE="freebsd-zfs" ;;
- SWAP) PARTYPE="freebsd-swap" ;;
- *) PARTYPE="freebsd-ufs" ;;
+ ZFS) PARTYPE="freebsd-zfs" ;;
+ SWAP) PARTYPE="freebsd-swap" ;;
+ *) PARTYPE="freebsd-ufs" ;;
esac
# Create the partition
@@ -514,8 +520,8 @@ setup_gpt_partitions()
# If this is the boot disk, stamp the right gptboot
if [ ! -z "${BOOTTYPE}" ] ; then
case ${BOOTTYPE} in
- freebsd-ufs) rc_halt "gpart bootcode -p /boot/gptboot -i 1 ${DISK}" ;;
- freebsd-zfs) rc_halt "gpart bootcode -p /boot/gptzfsboot -i 1 ${DISK}" ;;
+ freebsd-ufs) rc_halt "gpart bootcode -p /boot/gptboot -i 1 ${DISK}" ;;
+ freebsd-zfs) rc_halt "gpart bootcode -p /boot/gptzfsboot -i 1 ${DISK}" ;;
esac
fi
@@ -574,7 +580,6 @@ populate_disk_label()
setup_disk_label()
{
# We are ready to start setting up the label, lets read the config and do the actions
-
# First confirm that we have a valid WORKINGSLICES
if [ -z "${WORKINGSLICES}" ]; then
exit_err "ERROR: No slices were setup! Please report this to the maintainers"
@@ -639,3 +644,176 @@ setup_disk_label()
fi
};
+check_fstab_mbr()
+{
+ local SLICE
+ local FSTAB
+
+ if [ -z "$2" ]
+ then
+ return 1
+ fi
+
+ SLICE="$1"
+ FSTAB="$2/etc/fstab"
+
+ if [ -f "${FSTAB}" ]
+ then
+ PARTLETTER=`echo "$SLICE" | sed -E 's|^.+([a-h])$|\1|'`
+
+ cat "${FSTAB}" | awk '{ print $2 }' | grep -E '^/$' >/dev/null 2>&1
+ if [ "$?" = "0" ]
+ then
+ if [ "${PARTLETTER}" = "a" ]
+ then
+ FOUNDROOT="0"
+ else
+ FOUNDROOT="1"
+ fi
+
+ ROOTIMAGE="1"
+
+ export FOUNDROOT
+ export ROOTIMAGE
+ fi
+
+ cat "${FSTAB}" | awk '{ print $2 }' | grep -E '^/boot$' >/dev/null 2>&1
+ if [ "$?" = "0" ]
+ then
+ if [ "${PARTLETTER}" = "a" ]
+ then
+ USINGBOOTPART="0"
+ else
+ exit_err "/boot partition must be first partition"
+ fi
+ export USINGBOOTPART
+ fi
+
+ return 0
+ fi
+
+ return 1
+};
+
+check_fstab_gpt()
+{
+ local SLICE
+ local FSTAB
+
+ if [ -z "$2" ]
+ then
+ return 1
+ fi
+
+ SLICE="$1"
+ FSTAB="$2/etc/fstab"
+
+ if [ -f "${FSTAB}" ]
+ then
+ PARTNUMBER=`echo "${SLICE}" | sed -E 's|^.+p([0-9]*)$|\1|'`
+
+ cat "${FSTAB}" | awk '{ print $2 }' | grep -E '^/$' >/dev/null 2>&1
+ if [ "$?" = "0" ]
+ then
+ if [ "${PARTNUMBER}" = "2" ]
+ then
+ FOUNDROOT="0"
+ else
+ FOUNDROOT="1"
+ fi
+
+ ROOTIMAGE="1"
+
+ export FOUNDROOT
+ export ROOTIMAGE
+ fi
+
+ cat "${FSTAB}" | awk '{ print $2 }' | grep -E '^/boot$' >/dev/null 2>&1
+ if [ "$?" = "0" ]
+ then
+ if [ "${PARTNUMBER}" = "2" ]
+ then
+ USINGBOOTPART="0"
+ else
+ exit_err "/boot partition must be first partition"
+ fi
+ export USINGBOOTPART
+ fi
+
+ return 0
+ fi
+
+
+ return 1
+};
+
+check_disk_layout()
+{
+ local SLICES
+ local TYPE
+ local DISK
+ local RES
+ local F
+
+ DISK="$1"
+ TYPE="MBR"
+
+ if [ -z "${DISK}" ]
+ then
+ return 1
+ fi
+
+ SLICES_MBR=`ls /dev/${DISK}s[1-4]*[a-h]* 2>/dev/null`
+ SLICES_GPT=`ls /dev/${DISK}p[0-9]* 2>/dev/null`
+ SLICES_SLICE=`ls /dev/${DISK}[a-h]* 2>/dev/null`
+
+ if [ -n "${SLICES_MBR}" ]
+ then
+ SLICES="${SLICES_MBR}"
+ TYPE="MBR"
+ RES=0
+ fi
+ if [ -n "${SLICES_GPT}" ]
+ then
+ SLICES="${SLICES_GPT}"
+ TYPE="GPT"
+ RES=0
+ fi
+ if [ -n "${SLICES_SLICE}" ]
+ then
+ SLICES="${SLICES_SLICE}"
+ TYPE="MBR"
+ RES=0
+ fi
+
+ for slice in ${SLICES}
+ do
+ F=1
+ mount ${slice} /mnt 2>/dev/null
+ if [ "$?" != "0" ]
+ then
+ continue
+ fi
+
+ if [ "${TYPE}" = "MBR" ]
+ then
+ check_fstab_mbr "${slice}" "/mnt"
+ F="$?"
+
+ elif [ "${TYPE}" = "GPT" ]
+ then
+ check_fstab_gpt "${slice}" "/mnt"
+ F="$?"
+ fi
+
+ if [ "${F}" = "0" ]
+ then
+ #umount /mnt
+ break
+ fi
+
+ #umount /mnt
+ done
+
+ return ${RES}
+};
diff --git a/usr/sbin/pc-sysinstall/backend/functions-cleanup.sh b/usr/sbin/pc-sysinstall/backend/functions-cleanup.sh
index ff2729f..be316c4 100755
--- a/usr/sbin/pc-sysinstall/backend/functions-cleanup.sh
+++ b/usr/sbin/pc-sysinstall/backend/functions-cleanup.sh
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh,v 1.3 2010/07/31 19:25:51 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh,v 1.5 2010/10/21 17:14:44 imp Exp $
# Functions which perform the final cleanup after an install
@@ -99,9 +99,9 @@ zfs_cleanup_unmount()
do
if [ "${ZMNT}" != "/" ]
then
- #rc_halt "/sbin/zfs set mountpoint=${ZMNT} ${ZPOOLNAME}${ZMNT}"
- #rc_halt "/sbin/zfs unmount ${ZPOOLNAME}${ZMNT}"
- #sleep 2
+ rc_halt "zfs set mountpoint=${ZMNT} ${ZPOOLNAME}${ZMNT}"
+ rc_halt "zfs unmount ${ZPOOLNAME}${ZMNT}"
+ sleep 2
fi
done
fi
@@ -166,8 +166,8 @@ setup_fstab()
# Set mount options for file-systems
case $PARTFS in
UFS+J) MNTOPTS="rw,noatime,async" ;;
- SWAP) MNTOPTS="sw" ;;
- *) MNTOPTS="rw,noatime" ;;
+ SWAP) MNTOPTS="sw" ;;
+ *) MNTOPTS="rw,noatime" ;;
esac
@@ -296,7 +296,7 @@ setup_geli_loading()
# If we have a passphrase, set it up now
if [ -e "${PARTDIR}-enc/${PART}-encpass" ] ; then
- cat ${PARTDIR}-enc/${PART}-encpass | geli setkey -S -n 0 -p -k ${KEYFILE} -K ${KEYFILE} ${PART}
+ geli setkey -J ${PARTDIR}-enc/${PART}-encpass -n 0 -p -k ${KEYFILE} -K ${KEYFILE} ${PART}
geli configure -b ${PART}
fi
@@ -349,9 +349,9 @@ setup_hostname()
mv ${FSMNT}/etc/rc.conf.new ${FSMNT}/etc/rc.conf
# Set the hostname now
-# echo_log "Setting hostname: ${HOSTNAME}"
-# echo "hostname=\"${HOSTNAME}\"" >> ${FSMNT}/etc/rc.conf
-# sed -i -e "s|my.domain|${HOSTNAME} ${HOSTNAME}|g" ${FSMNT}/etc/hosts
+ echo_log "Setting hostname: ${HOSTNAME}"
+ echo "hostname=\"${HOSTNAME}\"" >> ${FSMNT}/etc/rc.conf
+ sed -i -e "s|my.domain|${HOSTNAME} ${HOSTNAME}|g" ${FSMNT}/etc/hosts
};
@@ -391,30 +391,28 @@ set_root_pw()
run_final_cleanup()
{
+ # Check if we need to run any gmirror setup
+ ls ${MIRRORCFGDIR}/* >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
+ # Lets setup gmirror now
+ setup_gmirror
+ fi
- # Check if we need to run any gmirror setup
- ls ${MIRRORCFGDIR}/* >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
- then
- # Lets setup gmirror now
- setup_gmirror
- fi
-
- # Check if we need to save any geli keys
- ls ${GELIKEYDIR}/* >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
- then
- # Lets setup geli loading
- setup_geli_loading
- fi
-
- # Set a hostname on the install system
- setup_hostname
+ # Check if we need to save any geli keys
+ ls ${GELIKEYDIR}/* >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
+ # Lets setup geli loading
+ setup_geli_loading
+ fi
- # Set the root_pw if it is specified
- set_root_pw
+ # Set a hostname on the install system
+ setup_hostname
- # Generate the fstab for the installed system
- setup_fstab
+ # Set the root_pw if it is specified
+ set_root_pw
+ # Generate the fstab for the installed system
+ setup_fstab
};
diff --git a/usr/sbin/pc-sysinstall/backend/functions-disk.sh b/usr/sbin/pc-sysinstall/backend/functions-disk.sh
index 3ab86dd..2bb3ecc 100755
--- a/usr/sbin/pc-sysinstall/backend/functions-disk.sh
+++ b/usr/sbin/pc-sysinstall/backend/functions-disk.sh
@@ -23,18 +23,19 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-disk.sh,v 1.2 2010/06/27 16:46:11 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-disk.sh,v 1.8 2010/11/10 05:32:36 imp Exp $
# Functions related to disk operations using gpart
# See if device is a full disk or partition/slice
-is_disk() {
- for _dsk in `sysctl -n kern.disks`
- do
- if [ "$_dsk" = "${1}" ] ; then return 0 ; fi
- done
+is_disk()
+{
+ for _dsk in `sysctl -n kern.disks`
+ do
+ if [ "$_dsk" = "${1}" ] ; then return 0 ; fi
+ done
- return 1
+ return 1
}
# Get a MBR partitions sysid
@@ -190,9 +191,9 @@ get_disk_partitions()
for i in ${SLICES}
do
case $type in
- MBR) name="${1}s${i}" ;;
- GPT) name="${1}p${i}";;
- *) name="${1}s${i}";;
+ MBR) name="${1}s${i}" ;;
+ GPT) name="${1}p${i}";;
+ *) name="${1}s${i}";;
esac
if [ -z "${RSLICES}" ]
then
@@ -226,8 +227,16 @@ get_disk_heads()
VAL="${head}" ; export VAL
};
+# Function which returns a target disks mediasize in sectors
+get_disk_mediasize()
+{
+ mediasize=`diskinfo -v ${1} | grep "# mediasize in sectors" | tr -s ' ' | cut -f 2`
+ VAL="${mediasize}" ; export VAL
+};
+
# Function which exports all zpools, making them safe to overwrite potentially
-export_all_zpools() {
+export_all_zpools()
+{
# Export any zpools
for i in `zpool list -H -o name`
do
@@ -324,144 +333,216 @@ setup_disk_slice()
# We are ready to start setting up the disks, lets read the config and do the actions
while read line
do
- echo $line | grep "^disk${disknum}=" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
- then
-
- # Found a disk= entry, lets get the disk we are working on
- get_value_from_string "${line}"
- strip_white_space "$VAL"
- DISK="$VAL"
+ echo $line | grep "^disk${disknum}=" >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
+
+ # Found a disk= entry, lets get the disk we are working on
+ get_value_from_string "${line}"
+ strip_white_space "$VAL"
+ DISK="$VAL"
- # Before we go further, lets confirm this disk really exists
- if [ ! -e "/dev/${DISK}" ]
- then
- exit_err "ERROR: The disk ${DISK} does not exist!"
- fi
+ # Before we go further, lets confirm this disk really exists
+ if [ ! -e "/dev/${DISK}" ]
+ then
+ exit_err "ERROR: The disk ${DISK} does not exist!"
+ fi
- # Make sure we stop any gmirrors on this disk
- stop_all_gmirror ${DISK}
+ # Make sure we stop any gmirrors on this disk
+ stop_all_gmirror ${DISK}
- # Make sure we stop any geli stuff on this disk
- stop_all_geli ${DISK}
+ # Make sure we stop any geli stuff on this disk
+ stop_all_geli ${DISK}
- # Make sure we don't have any zpools loaded
- stop_all_zfs
+ # Make sure we don't have any zpools loaded
+ stop_all_zfs
- fi
+ fi
- # Lets look if this device will be mirrored on another disk
- echo $line | grep "^mirror=" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
- then
+ # Lets look if this device will be mirrored on another disk
+ echo $line | grep "^mirror=" >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
- # Found a disk= entry, lets get the disk we are working on
- get_value_from_string "${line}"
- strip_white_space "$VAL"
- MIRRORDISK="$VAL"
+ # Found a disk= entry, lets get the disk we are working on
+ get_value_from_string "${line}"
+ strip_white_space "$VAL"
+ MIRRORDISK="$VAL"
- # Before we go further, lets confirm this disk really exists
- if [ ! -e "/dev/${MIRRORDISK}" ]
- then
- exit_err "ERROR: The mirror disk ${MIRRORDISK} does not exist!"
- fi
- fi
+ # Before we go further, lets confirm this disk really exists
+ if [ ! -e "/dev/${MIRRORDISK}" ]
+ then
+ exit_err "ERROR: The mirror disk ${MIRRORDISK} does not exist!"
+ fi
+ fi
- # Lets see if we have been given a mirror balance choice
- echo $line | grep "^mirrorbal=" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
- then
+ # Lets see if we have been given a mirror balance choice
+ echo $line | grep "^mirrorbal=" >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
- # Found a disk= entry, lets get the disk we are working on
- get_value_from_string "${line}"
- strip_white_space "$VAL"
- MIRRORBAL="$VAL"
- fi
+ # Found a disk= entry, lets get the disk we are working on
+ get_value_from_string "${line}"
+ strip_white_space "$VAL"
+ MIRRORBAL="$VAL"
+ fi
- echo $line | grep "^partition=" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
- then
- # Found a partition= entry, lets read / set it
- get_value_from_string "${line}"
- strip_white_space "$VAL"
- PTYPE="$VAL"
-
- # We are using free space, figure out the slice number
- if [ "${PTYPE}" = "free" -o "${PTYPE}" = "FREE" ]
- then
- # Lets figure out what number this slice will be
- LASTSLICE="`gpart show ${DISK} | grep -v ${DISK} | grep -v ' free' |tr -s '\t' ' ' | cut -d ' ' -f 4 | sed '/^$/d' | tail -n 1`"
- if [ -z "${LASTSLICE}" ]
- then
- LASTSLICE="1"
- else
- LASTSLICE="`expr $LASTSLICE + 1`"
- fi
-
- if [ $LASTSLICE -gt 4 ]
- then
- exit_err "ERROR: BSD only supports primary partitions, and there are none availble on $DISK"
- fi
+ echo $line | grep "^partition=" >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
+ # Found a partition= entry, lets read / set it
+ get_value_from_string "${line}"
+ strip_white_space "$VAL"
+ PTYPE=`echo $VAL|tr A-Z a-z`
+
+ # We are using free space, figure out the slice number
+ if [ "${PTYPE}" = "free" ]
+ then
+ # Lets figure out what number this slice will be
+ LASTSLICE="`gpart show ${DISK} \
+ | grep -v ${DISK} \
+ | grep -v ' free' \
+ | tr -s '\t' ' ' \
+ | cut -d ' ' -f 4 \
+ | sed '/^$/d' \
+ | tail -n 1`"
+
+ if [ -z "${LASTSLICE}" ]
+ then
+ LASTSLICE="1"
+ else
+ LASTSLICE="`expr $LASTSLICE + 1`"
+ fi
+
+ if [ $LASTSLICE -gt 4 ]
+ then
+ exit_err "ERROR: BSD only supports primary partitions, and there are none availble on $DISK"
+ fi
+
+ fi
+ fi
- fi
- fi
+ # Check if we have an image file defined
+ echo $line | grep "^image=" >/dev/null 2>/dev/null
+ if [ "$?" = "0" ] ; then
+ # Found an image= entry, lets read / set it
+ get_value_from_string "${line}"
+ strip_white_space "$VAL"
+ IMAGE="$VAL"
+ if [ ! -f "$IMAGE" ] ; then
+ exit_err "$IMAGE file does not exist"
+ fi
+ fi
- echo $line | grep "^bootManager=" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
- then
- # Found a bootManager= entry, lets read /set it
- get_value_from_string "${line}"
- strip_white_space "$VAL"
- BMANAGER="$VAL"
- fi
+ # Check if we have a partscheme specified
+ echo $line | grep "^partscheme=" >/dev/null 2>/dev/null
+ if [ "$?" = "0" ] ; then
+ # Found a partscheme= entry, lets read / set it
+ get_value_from_string "${line}"
+ strip_white_space "$VAL"
+ PSCHEME="$VAL"
+ if [ "$PSCHEME" != "GPT" -a "$PSCHEME" != "MBR" ] ; then
+ exit_err "Unknown partition scheme: $PSCHEME"
+ fi
+ fi
- echo $line | grep "^commitDiskPart" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
- then
- # Found our flag to commit this disk setup / lets do sanity check and do it
- if [ ! -z "${DISK}" -a ! -z "${PTYPE}" ]
- then
- case ${PTYPE} in
- all|ALL) tmpSLICE="${DISK}p1"
- run_gpart_full "${DISK}" "${BMANAGER}" ;;
- s1|s2|s3|s4) tmpSLICE="${DISK}${PTYPE}"
- # Get the number of the slice we are working on
- s="`echo ${PTYPE} | awk '{print substr($0,length,1)}'`"
- run_gpart_slice "${DISK}" "${BMANAGER}" "${s}" ;;
- free|FREE) tmpSLICE="${DISK}s${LASTSLICE}"
- run_gpart_free "${DISK}" "${LASTSLICE}" "${BMANAGER}" ;;
- *) exit_err "ERROR: Unknown PTYPE: $PTYPE" ;;
- esac
-
- # Now save which disk<num> this is, so we can parse it later during slice partition setup
- echo "disk${disknum}" >${SLICECFGDIR}/$tmpSLICE
-
- # Save any mirror config
- if [ ! -z "$MIRRORDISK" ]
- then
- # Default to round-robin if the user didn't specify
- if [ -z "$MIRRORBAL" ]
- then
- MIRRORBAL="round-robin"
- fi
- echo "$MIRRORDISK:$MIRRORBAL" >${MIRRORCFGDIR}/$DISK
- fi
-
-
- # Increment our disk counter to look for next disk and unset
- unset BMANAGER PTYPE DISK MIRRORDISK MIRRORBAL
- disknum="`expr $disknum + 1`"
- else
- exit_err "ERROR: commitDiskPart was called without procceding disk<num>= and partition= entries!!!"
- fi
- fi
+ echo $line | grep "^bootManager=" >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
+ # Found a bootManager= entry, lets read /set it
+ get_value_from_string "${line}"
+ strip_white_space "$VAL"
+ BMANAGER="$VAL"
+ fi
+
+ echo $line | grep "^commitDiskPart" >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
+ # Found our flag to commit this disk setup / lets do sanity check and do it
+ if [ ! -z "${DISK}" -a ! -z "${PTYPE}" ]
+ then
+ case ${PTYPE} in
+ all)
+ if [ "$PSCHEME" = "MBR" -o -z "$PSCHEME" ] ; then
+ PSCHEME="MBR"
+ tmpSLICE="${DISK}s1"
+ else
+ tmpSLICE="${DISK}p1"
+ fi
+
+ run_gpart_full "${DISK}" "${BMANAGER}" "${PSCHEME}"
+ ;;
+
+ s1|s2|s3|s4)
+ tmpSLICE="${DISK}${PTYPE}"
+ # Get the number of the slice we are working on
+ s="`echo ${PTYPE} | awk '{print substr($0,length,1)}'`"
+ run_gpart_slice "${DISK}" "${BMANAGER}" "${s}"
+ ;;
+
+ free)
+ tmpSLICE="${DISK}s${LASTSLICE}"
+ run_gpart_free "${DISK}" "${LASTSLICE}" "${BMANAGER}"
+ ;;
+
+ image)
+ if [ -z "${IMAGE}" ]
+ then
+ exit_err "ERROR: partition type image specified with no image!"
+ fi
+ ;;
+
+ *) exit_err "ERROR: Unknown PTYPE: $PTYPE" ;;
+ esac
+
+
+ if [ -n "${IMAGE}" ]
+ then
+ local DEST
+
+ if [ -n "${tmpSLICE}" ]
+ then
+ DEST="${tmpSLICE}"
+ else
+ DEST="${DISK}"
+ fi
+
+ write_image "${IMAGE}" "${DEST}"
+ check_disk_layout "${DEST}"
+ fi
+
+ # Now save which disk<num> this is, so we can parse it later during slice partition setup
+ if [ -z "${IMAGE}" ]
+ then
+ echo "disk${disknum}" >${SLICECFGDIR}/$tmpSLICE
+ fi
+
+ # Save any mirror config
+ if [ ! -z "$MIRRORDISK" ]
+ then
+ # Default to round-robin if the user didn't specify
+ if [ -z "$MIRRORBAL" ]
+ then
+ MIRRORBAL="round-robin"
+ fi
+ echo "$MIRRORDISK:$MIRRORBAL" >${MIRRORCFGDIR}/$DISK
+ fi
+
+ # Increment our disk counter to look for next disk and unset
+ unset BMANAGER PTYPE DISK MIRRORDISK MIRRORBAL PSCHEME IMAGE
+ disknum="`expr $disknum + 1`"
+ else
+ exit_err "ERROR: commitDiskPart was called without procceding disk<num>= and partition= entries!!!"
+ fi
+ fi
done <${CFGF}
};
# Stop all gjournals on disk / slice
-stop_gjournal() {
+stop_gjournal()
+{
_gdsk="$1"
# Check if we need to shutdown any journals on this drive
ls /dev/${_gdsk}*.journal >/dev/null 2>/dev/null
@@ -477,7 +558,7 @@ stop_gjournal() {
fi
} ;
-# Function which runs gpart and creates a single large slice
+# Function which runs gpart and creates a single large GPT partition scheme
init_gpt_full_disk()
{
_intDISK=$1
@@ -506,14 +587,88 @@ init_gpt_full_disk()
}
+# Function which runs gpart and creates a single large MBR partition scheme
+init_mbr_full_disk()
+{
+ _intDISK=$1
+ _intBOOT=$2
+
+ startblock="63"
+
+ # Set our sysctl so we can overwrite any geom using drives
+ sysctl kern.geom.debugflags=16 >>${LOGOUT} 2>>${LOGOUT}
+
+ # Stop any journaling
+ stop_gjournal "${_intDISK}"
+
+ # Remove any existing partitions
+ delete_all_gpart "${_intDISK}"
+
+ #Erase any existing bootloader
+ echo_log "Cleaning up ${_intDISK}"
+ rc_halt "dd if=/dev/zero of=/dev/${_intDISK} count=2048"
+
+ sleep 2
+
+ echo_log "Running gpart on ${_intDISK}"
+ rc_halt "gpart create -s mbr ${_intDISK}"
+
+ # Lets figure out disk size in blocks
+ # Get the cyl of this disk
+ get_disk_cyl "${_intDISK}"
+ cyl="${VAL}"
+
+ # Get the heads of this disk
+ get_disk_heads "${_intDISK}"
+ head="${VAL}"
+
+ # Get the tracks/sectors of this disk
+ get_disk_sectors "${_intDISK}"
+ sec="${VAL}"
+
+ # Multiply them all together to get our total blocks
+ totalblocks="`expr ${cyl} \* ${head}`"
+ totalblocks="`expr ${totalblocks} \* ${sec}`"
+ if [ -z "${totalblocks}" ]
+ then
+ totalblocks=`gpart show "${_intDISK}"|tail -2|head -1|awk '{ print $2 }'`
+ fi
+
+ # Now set the ending block to the total disk block size
+ sizeblock="`expr ${totalblocks} - ${startblock}`"
+
+ # Install new partition setup
+ echo_log "Running gpart add on ${_intDISK}"
+ rc_halt "gpart add -b ${startblock} -s ${sizeblock} -t freebsd -i 1 ${_intDISK}"
+ sleep 2
+
+ echo_log "Cleaning up ${_intDISK}s1"
+ rc_halt "dd if=/dev/zero of=/dev/${_intDISK}s1 count=1024"
+
+ if [ "$_intBOOT" = "bsd" ] ; then
+ echo_log "Stamping boot0 on ${_intDISK}"
+ rc_halt "gpart bootcode -b /boot/boot0 ${_intDISK}"
+ else
+ echo_log "Stamping boot1 on ${_intDISK}"
+ rc_halt "gpart bootcode -b /boot/boot1 ${_intDISK}"
+ fi
+
+}
+
# Function which runs gpart and creates a single large slice
run_gpart_full()
{
DISK=$1
+ BOOT=$2
+ SCHEME=$3
- init_gpt_full_disk "$DISK"
-
- slice="${DISK}-1-gpt"
+ if [ "$SCHEME" = "MBR" ] ; then
+ init_mbr_full_disk "$DISK" "$BOOT"
+ slice="${DISK}-1-mbr"
+ else
+ init_gpt_full_disk "$DISK"
+ slice="${DISK}-1-gpt"
+ fi
# Lets save our slice, so we know what to look for in the config file later on
if [ -z "$WORKINGSLICES" ]
diff --git a/usr/sbin/pc-sysinstall/backend/functions-extractimage.sh b/usr/sbin/pc-sysinstall/backend/functions-extractimage.sh
index 1853e26..aeb585f 100755
--- a/usr/sbin/pc-sysinstall/backend/functions-extractimage.sh
+++ b/usr/sbin/pc-sysinstall/backend/functions-extractimage.sh
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh,v 1.2 2010/06/27 16:46:11 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh,v 1.8 2010/10/21 23:08:42 imp Exp $
# Functions which perform the extraction / installation of system to disk
@@ -54,39 +54,41 @@ start_extract_uzip_tar()
echo_log "pc-sysinstall: Starting Extraction"
case ${PACKAGETYPE} in
- uzip) # Start by mounting the uzip image
- MDDEVICE=`mdconfig -a -t vnode -o readonly -f ${INSFILE}`
- mkdir -p ${FSMNT}.uzip
- mount -r /dev/${MDDEVICE}.uzip ${FSMNT}.uzip
- if [ "$?" != "0" ]
- then
- exit_err "ERROR: Failed mounting the ${INSFILE}"
- fi
- cd ${FSMNT}.uzip
-
- # Copy over all the files now!
- tar cvf - . 2>/dev/null | tar -xpv -C ${FSMNT} ${TAROPTS} -f - 2>&1 | tee -a ${FSMNT}/.tar-extract.log
- if [ "$?" != "0" ]
- then
- cd /
- echo "TAR failure occured:" >>${LOGOUT}
- cat ${FSMNT}/.tar-extract.log | grep "tar:" >>${LOGOUT}
- umount ${FSMNT}.uzip
- mdconfig -d -u ${MDDEVICE}
- exit_err "ERROR: Failed extracting the tar image"
- fi
-
- # All finished, now lets umount and cleanup
- cd /
- umount ${FSMNT}.uzip
- mdconfig -d -u ${MDDEVICE}
- ;;
- tar) tar -xpv -C ${FSMNT} -f ${INSFILE} ${TAROPTS} >&1 2>&1
- if [ "$?" != "0" ]
- then
- exit_err "ERROR: Failed extracting the tar image"
- fi
- ;;
+ uzip)
+ # Start by mounting the uzip image
+ MDDEVICE=`mdconfig -a -t vnode -o readonly -f ${INSFILE}`
+ mkdir -p ${FSMNT}.uzip
+ mount -r /dev/${MDDEVICE}.uzip ${FSMNT}.uzip
+ if [ "$?" != "0" ]
+ then
+ exit_err "ERROR: Failed mounting the ${INSFILE}"
+ fi
+ cd ${FSMNT}.uzip
+
+ # Copy over all the files now!
+ tar cvf - . 2>/dev/null | tar -xpv -C ${FSMNT} ${TAROPTS} -f - 2>&1 | tee -a ${FSMNT}/.tar-extract.log
+ if [ "$?" != "0" ]
+ then
+ cd /
+ echo "TAR failure occurred:" >>${LOGOUT}
+ cat ${FSMNT}/.tar-extract.log | grep "tar:" >>${LOGOUT}
+ umount ${FSMNT}.uzip
+ mdconfig -d -u ${MDDEVICE}
+ exit_err "ERROR: Failed extracting the tar image"
+ fi
+
+ # All finished, now lets umount and cleanup
+ cd /
+ umount ${FSMNT}.uzip
+ mdconfig -d -u ${MDDEVICE}
+ ;;
+ tar)
+ tar -xpv -C ${FSMNT} -f ${INSFILE} ${TAROPTS} >&1 2>&1
+ if [ "$?" != "0" ]
+ then
+ exit_err "ERROR: Failed extracting the tar image"
+ fi
+ ;;
esac
# Check if this was a FTP download and clean it up now
@@ -120,10 +122,10 @@ start_extract_split()
DIRS=`ls -d ${INSDIR}/*|grep -Ev '(uzip|kernels|src)'`
for dir in ${DIRS}
do
- cd "${dir}"
- if [ -f "install.sh" ]
- then
- echo "Extracting" `basename ${dir}`
+ cd "${dir}"
+ if [ -f "install.sh" ]
+ then
+ echo_log "Extracting" `basename ${dir}`
echo "y" | sh install.sh >/dev/null
if [ "$?" != "0" ]
then
@@ -139,13 +141,14 @@ start_extract_split()
cd "${KERNELS}"
if [ -f "install.sh" ]
then
- echo "Extracting" `basename ${KERNELS}`
+ echo_log "Extracting" `basename ${KERNELS}`
echo "y" | sh install.sh generic >/dev/null
if [ "$?" != "0" ]
then
exit_err "ERROR: Failed extracting ${KERNELS}"
fi
- echo 'kernel="GENERIC"' > "${FSMNT}/boot/loader.conf"
+ rm -rf "${FSMNT}/boot/kernel"
+ mv "${FSMNT}/boot/GENERIC" "${FSMNT}/boot/kernel"
else
exit_err "ERROR: ${KERNELS}/install.sh does not exist"
fi
@@ -155,7 +158,7 @@ start_extract_split()
cd "${SOURCE}"
if [ -f "install.sh" ]
then
- echo "Extracting" `basename ${SOURCE}`
+ echo_log "Extracting" `basename ${SOURCE}`
echo "y" | sh install.sh all >/dev/null
if [ "$?" != "0" ]
then
@@ -203,7 +206,76 @@ fetch_install_file()
};
-# Function which does the rsync download from the server specifed in cfg
+# Function which will download freebsd install files
+fetch_split_files()
+{
+ get_ftpHost
+ if [ -z "$VAL" ]
+ then
+ exit_err "ERROR: Install medium was set to ftp, but no ftpHost was provided!"
+ fi
+ FTPHOST="${VAL}"
+
+ get_ftpDir
+ if [ -z "$VAL" ]
+ then
+ exit_err "ERROR: Install medium was set to ftp, but no ftpDir was provided!"
+ fi
+ FTPDIR="${VAL}"
+
+ # Check if we have a /usr partition to save the download
+ if [ -d "${FSMNT}/usr" ]
+ then
+ OUTFILE="${FSMNT}/usr/.fetch-${INSFILE}"
+ else
+ OUTFILE="${FSMNT}/.fetch-${INSFILE}"
+ fi
+
+ DIRS="base catpages dict doc games info manpages proflibs kernels src"
+ if [ "${FBSD_ARCH}" = "amd64" ]
+ then
+ DIRS="${DIRS} lib32"
+ fi
+
+ for d in ${DIRS}
+ do
+ mkdir -p "${OUTFILE}/${d}"
+ done
+
+
+ NETRC="${OUTFILE}/.netrc"
+ cat<<EOF>"${NETRC}"
+machine ${FTPHOST}
+login anonymous
+password anonymous
+macdef INSTALL
+bin
+prompt
+EOF
+
+ for d in ${DIRS}
+ do
+ cat<<EOF>>"${NETRC}"
+cd ${FTPDIR}/${d}
+lcd ${OUTFILE}/${d}
+mreget *
+EOF
+ done
+
+ cat<<EOF>>"${NETRC}"
+bye
+
+
+EOF
+
+ # Fetch the files via ftp
+ echo "$ INSTALL" | ftp -N "${NETRC}" "${FTPHOST}"
+
+ # Done fetching, now reset the INSFILE to our downloaded archived
+ INSFILE="${OUTFILE}" ; export INSFILE
+}
+
+# Function which does the rsync download from the server specified in cfg
start_rsync_copy()
{
# Load our rsync config values
@@ -257,6 +329,46 @@ start_rsync_copy()
};
+start_image_install()
+{
+ if [ -z "${IMAGE_FILE}" ]
+ then
+ exit_err "ERROR: installMedium set to image but no image file specified!"
+ fi
+
+ # We are ready to start mounting, lets read the config and do it
+ while read line
+ do
+ echo $line | grep "^disk0=" >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
+ # Found a disk= entry, lets get the disk we are working on
+ get_value_from_string "${line}"
+ strip_white_space "$VAL"
+ DISK="$VAL"
+ fi
+
+ echo $line | grep "^commitDiskPart" >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
+ # Found our flag to commit this disk setup / lets do sanity check and do it
+ if [ ! -z "${DISK}" ]
+ then
+
+ # Write the image
+ write_image "${IMAGE_FILE}" "${DISK}"
+
+ # Increment our disk counter to look for next disk and unset
+ unset DISK
+ break
+
+ else
+ exit_err "ERROR: commitDiskPart was called without procceding disk<num>= and partition= entries!!!"
+ fi
+ fi
+
+ done <${CFGF}
+};
# Entrance function, which starts the installation process
init_extraction()
@@ -272,19 +384,19 @@ init_extraction()
if [ "$INSTALLTYPE" = "FreeBSD" ]
then
case $PACKAGETYPE in
- uzip) INSFILE="${FBSD_UZIP_FILE}" ;;
- tar) INSFILE="${FBSD_TAR_FILE}" ;;
- split)
- INSDIR="${FBSD_BRANCH_DIR}"
-
- # This is to trick opt_mount into not failing
- INSFILE="${INSDIR}"
- ;;
+ uzip) INSFILE="${FBSD_UZIP_FILE}" ;;
+ tar) INSFILE="${FBSD_TAR_FILE}" ;;
+ split)
+ INSDIR="${FBSD_BRANCH_DIR}"
+
+ # This is to trick opt_mount into not failing
+ INSFILE="${INSDIR}"
+ ;;
esac
else
case $PACKAGETYPE in
- uzip) INSFILE="${UZIP_FILE}" ;;
- tar) INSFILE="${TAR_FILE}" ;;
+ uzip) INSFILE="${UZIP_FILE}" ;;
+ tar) INSFILE="${TAR_FILE}" ;;
esac
fi
export INSFILE
diff --git a/usr/sbin/pc-sysinstall/backend/functions-ftp.sh b/usr/sbin/pc-sysinstall/backend/functions-ftp.sh
index 93d9eae..fa05e3f 100755
--- a/usr/sbin/pc-sysinstall/backend/functions-ftp.sh
+++ b/usr/sbin/pc-sysinstall/backend/functions-ftp.sh
@@ -23,13 +23,15 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-ftp.sh,v 1.2 2010/07/13 23:47:12 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-ftp.sh,v 1.4 2010/08/24 06:11:46 imp Exp $
# Functions which runs commands on the system
. ${BACKEND}/functions.sh
. ${BACKEND}/functions-parse.sh
+DEFAULT_FTP_SERVER="ftp.freebsd.org"
+
MAIN_FTP_SERVERS="\
Main Site: ftp.freebsd.org"
@@ -274,7 +276,48 @@ show_mirrors()
done
IFS="${SAVE_IFS}"
fi
-}
+};
+
+set_ftp_mirror()
+{
+ MIRROR="${1}"
+ echo "${MIRROR}" > "${CONFDIR}/mirrors.conf"
+};
+
+get_ftp_mirror()
+{
+ MIRROR="${DEFAULT_FTP_SERVER}"
+ if [ -f "${CONFDIR}/mirrors.conf" ]
+ then
+ MIRROR=`cat "${CONFDIR}/mirrors.conf"`
+ fi
+
+ VAL="${MIRROR}"
+ export VAL
+};
+
+
+get_ftpHost()
+{
+ get_value_from_cfg ftpPath
+ ftpPath="$VAL"
+
+ ftpHost=`echo "${ftpPath}" | sed -E 's|^(ftp://)([^/]*)(.*)|\2|'`
+ VAL="${ftpHost}"
+
+ export VAL
+};
+
+get_ftpDir()
+{
+ get_value_from_cfg ftpPath
+ ftpPath="$VAL"
+
+ ftpDir=`echo "${ftpPath}" | sed -E 's|^(ftp://)([^/]*)(.*)|\3|'`
+ VAL="${ftpDir}"
+
+ export VAL
+};
get_ftp_mirrors()
{
@@ -371,4 +414,4 @@ get_ftp_mirrors()
fi
export VAL
-}
+};
diff --git a/usr/sbin/pc-sysinstall/backend/functions-installcomponents.sh b/usr/sbin/pc-sysinstall/backend/functions-installcomponents.sh
index 4744765..5aa6f84 100755
--- a/usr/sbin/pc-sysinstall/backend/functions-installcomponents.sh
+++ b/usr/sbin/pc-sysinstall/backend/functions-installcomponents.sh
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-installcomponents.sh,v 1.2 2010/06/27 16:46:11 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-installcomponents.sh,v 1.4 2010/09/08 20:10:24 imp Exp $
# Functions which check and load any optional modules specified in the config
@@ -52,23 +52,27 @@ copy_component()
CFILEMD5="`echo $line | cut -d ':' -f 2`"
CFILE2MD5="`echo $line | cut -d ':' -f 3`"
-
case ${INSTALLMEDIUM} in
- dvd|usb) # On both dvd / usb, we can just copy the file
- cp ${CDMNT}/${COMPFILEDIR}/${SUBDIR}/${CFILE} \
- ${FSMNT}/${COMPTMPDIR} >>${LOGOUT} 2>>${LOGOUT}
- RESULT="$?"
- ;;
- ftp) get_value_from_cfg ftpPath
- if [ -z "$VAL" ]
- then
- exit_err "ERROR: Install medium was set to ftp, but no ftpPath was provided!"
- fi
- FTPPATH="${VAL}"
-
- fetch_file "${FTPPATH}/${COMPFILEDIR}/${SUBDIR}/${CFILE}" "${FSMNT}/${COMPTMPDIR}/${CFILE}" "0"
+ dvd|usb)
+ # On both dvd / usb, we can just copy the file
+ cp ${CDMNT}/${COMPFILEDIR}/${SUBDIR}/${CFILE} \
+ ${FSMNT}/${COMPTMPDIR} >>${LOGOUT} 2>>${LOGOUT}
RESULT="$?"
- ;;
+ ;;
+
+ ftp)
+ get_value_from_cfg ftpPath
+ if [ -z "$VAL" ]
+ then
+ exit_err "ERROR: Install medium was set to ftp, but no ftpPath was provided!"
+ fi
+ FTPPATH="${VAL}"
+
+ fetch_file "${FTPPATH}/${COMPFILEDIR}/${SUBDIR}/${CFILE}" "${FSMNT}/${COMPTMPDIR}/${CFILE}" "0"
+ RESULT="$?"
+ ;;
+
+ sftp) ;;
esac
if [ "${RESULT}" != "0" ]
@@ -120,47 +124,44 @@ export CFILE
sh ${COMPTMPDIR}/install.sh
" >${FSMNT}/.componentwrapper.sh
- chmod 755 ${FSMNT}/.componentwrapper.sh
+ chmod 755 ${FSMNT}/.componentwrapper.sh
- # Copy over the install script for this component
- cp ${COMPDIR}/${COMPONENT}/install.sh ${FSMNT}/${COMPTMPDIR}/
-
- echo_log "INSTALL COMPONENT: ${i}"
- chroot ${FSMNT} /.componentwrapper.sh >>${LOGOUT} 2>>${LOGOUT}
- rm ${FSMNT}/.componentwrapper.sh
+ # Copy over the install script for this component
+ cp ${COMPDIR}/${COMPONENT}/install.sh ${FSMNT}/${COMPTMPDIR}/
+ echo_log "INSTALL COMPONENT: ${i}"
+ chroot ${FSMNT} /.componentwrapper.sh >>${LOGOUT} 2>>${LOGOUT}
+ rm ${FSMNT}/.componentwrapper.sh
};
# Check for any modules specified, and begin loading them
install_components()
{
- # First, lets check and see if we even have any optional modules
- get_value_from_cfg installComponents
- if [ ! -z "${VAL}" ]
- then
- # Lets start by cleaning up the string and getting it ready to parse
- strip_white_space ${VAL}
- COMPONENTS=`echo ${VAL} | sed -e "s|,| |g"`
- for i in $COMPONENTS
- do
- if [ ! -e "${COMPDIR}/${i}/install.sh" -o ! -e "${COMPDIR}/${i}/distfiles" ]
- then
- echo_log "WARNING: Component ${i} doesn't seem to exist"
- else
-
- # Make the tmpdir on the disk
- mkdir -p ${FSMNT}/${COMPTMPDIR} >>${LOGOUT} 2>>${LOGOUT}
-
- # Start by grabbing the component files
- copy_component ${i}
+ # First, lets check and see if we even have any optional modules
+ get_value_from_cfg installComponents
+ if [ ! -z "${VAL}" ]
+ then
+ # Lets start by cleaning up the string and getting it ready to parse
+ strip_white_space ${VAL}
+ COMPONENTS=`echo ${VAL} | sed -e "s|,| |g"`
+ for i in $COMPONENTS
+ do
+ if [ ! -e "${COMPDIR}/${i}/install.sh" -o ! -e "${COMPDIR}/${i}/distfiles" ]
+ then
+ echo_log "WARNING: Component ${i} doesn't seem to exist"
+ else
- # Remove the tmpdir now
- rm -rf ${FSMNT}/${COMPTMPDIR} >>${LOGOUT} 2>>${LOGOUT}
+ # Make the tmpdir on the disk
+ mkdir -p ${FSMNT}/${COMPTMPDIR} >>${LOGOUT} 2>>${LOGOUT}
- fi
- done
+ # Start by grabbing the component files
+ copy_component ${i}
- fi
+ # Remove the tmpdir now
+ rm -rf ${FSMNT}/${COMPTMPDIR} >>${LOGOUT} 2>>${LOGOUT}
+ fi
+ done
+ fi
};
diff --git a/usr/sbin/pc-sysinstall/backend/functions-installpackages.sh b/usr/sbin/pc-sysinstall/backend/functions-installpackages.sh
new file mode 100644
index 0000000..b8f383a
--- /dev/null
+++ b/usr/sbin/pc-sysinstall/backend/functions-installpackages.sh
@@ -0,0 +1,125 @@
+#!/bin/sh
+#-
+# Copyright (c) 2010 iXsystems, Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-installpackages.sh,v 1.3 2010/08/24 06:11:46 imp Exp $
+
+# Functions which check and load any optional packages specified in the config
+
+. ${BACKEND}/functions.sh
+. ${BACKEND}/functions-parse.sh
+
+# Recursively determine all dependencies for this package
+determine_package_dependencies()
+{
+ local PKGNAME="${1}"
+ local DEPFILE="${2}"
+
+ grep "${PKGNAME}" "${DEPFILE}" >/dev/null
+ if [ "$?" -ne "0" ]
+ then
+ echo "${PKGNAME}" >> "${DEPFILE}"
+ get_package_dependencies "${PKGNAME}" "1"
+
+ local DEPS="${VAL}"
+ for d in ${DEPS}
+ do
+ determine_package_dependencies "${d}" "${DEPFILE}"
+ done
+ fi
+};
+
+# Fetch packages dependencies from a file
+fetch_package_dependencies()
+{
+ local DEPFILE
+ local DEPS
+ local SAVEDIR
+
+ DEPFILE="${1}"
+ DEPS=`cat "${DEPFILE}"`
+ SAVEDIR="${2}"
+
+ for d in ${DEPS}
+ do
+ get_package_short_name "${d}"
+ SNAME="${VAL}"
+
+ get_package_category "${SNAME}"
+ CATEGORY="${VAL}"
+
+ fetch_package "${CATEGORY}" "${d}" "${SAVEDIR}"
+ done
+};
+
+# Check for any packages specified, and begin loading them
+install_packages()
+{
+ # First, lets check and see if we even have any packages to install
+ get_value_from_cfg installPackages
+ if [ ! -z "${VAL}" ]
+ then
+ HERE=`pwd`
+ rc_nohalt "mkdir -p ${FSMNT}/${PKGTMPDIR}"
+ rc_nohalt "cd ${FSMNT}/${PKGTMPDIR}"
+
+ if [ ! -f "${CONFDIR}/INDEX" ]
+ then
+ get_package_index
+ fi
+
+ if [ ! -f "${CONFDIR}/INDEX.parsed" ]
+ then
+ parse_package_index
+ fi
+
+ # Lets start by cleaning up the string and getting it ready to parse
+ strip_white_space ${VAL}
+ PACKAGES=`echo ${VAL} | sed -e "s|,| |g"`
+ for i in $PACKAGES
+ do
+ if get_package_name "${i}"
+ then
+ PKGNAME="${VAL}"
+ DEPFILE="${FSMNT}/${PKGTMPDIR}/.${PKGNAME}.deps"
+
+ rc_nohalt "touch ${DEPFILE}"
+ determine_package_dependencies "${PKGNAME}" "${DEPFILE}"
+ fetch_package_dependencies "${DEPFILE}" "${FSMNT}/${PKGTMPDIR}"
+
+ # If the package is not already installed, install it!
+ if ! run_chroot_cmd "pkg_info -e ${PKGNAME}"
+ then
+ rc_nohalt "pkg_add -C ${FSMNT} ${PKGTMPDIR}/${PKGNAME}.tbz"
+ fi
+
+ rc_nohalt "rm ${DEPFILE}"
+ fi
+
+ rc_nohalt "cd ${HERE}"
+ done
+
+ rm -rf "${FSMNT}/${PKGTMPDIR}"
+ fi
+};
diff --git a/usr/sbin/pc-sysinstall/backend/functions-localize.sh b/usr/sbin/pc-sysinstall/backend/functions-localize.sh
index 107a6ae..a56f957 100755
--- a/usr/sbin/pc-sysinstall/backend/functions-localize.sh
+++ b/usr/sbin/pc-sysinstall/backend/functions-localize.sh
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-localize.sh,v 1.2 2010/06/27 16:46:11 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-localize.sh,v 1.3 2010/08/24 06:11:46 imp Exp $
# Functions which runs commands on the system
@@ -63,66 +63,66 @@ localize_pcbsd()
localize_x_keyboard()
{
- KEYMOD="$1"
- KEYLAY="$2"
- KEYVAR="$3"
- COUNTRY="$4"
- OPTION="grp:alt_shift_toggle"
- SETXKBMAP=""
-
- if [ "${COUNTRY}" = "NONE" -o "${COUNTRY}" = "us" -o "${COUNTRY}" = "C" ] ; then
- #In this case we don't need any additional language
- COUNTRY=""
- OPTION=""
- else
- COUNTRY=",${COUNTRY}"
- fi
-
- if [ "${KEYMOD}" != "NONE" ]
- then
- SETXKBMAP="-model ${KEYMOD}"
- KXMODEL="${KEYMOD}"
- else
- KXMODEL="pc104"
- fi
-
- if [ "${KEYLAY}" != "NONE" ]
- then
- localize_key_layout "$KEYLAY"
- SETXKBMAP="${SETXKBMAP} -layout ${KEYLAY}"
- KXLAYOUT="${KEYLAY}"
- else
- KXLAYOUT="us"
- fi
-
- if [ "${KEYVAR}" != "NONE" ]
- then
- SETXKBMAP="${SETXKBMAP} -variant ${KEYVAR}"
- KXVAR="(${KEYVAR})"
- else
- KXVAR=""
- fi
-
- # Setup .xprofile with our setxkbmap call now
- if [ ! -z "${SETXKBMAP}" ]
- then
- if [ ! -e "${FSMNT}/usr/share/skel/.xprofile" ]
- then
- echo "#!/bin/sh" >${FSMNT}/usr/share/skel/.xprofile
- fi
-
- # Save the keyboard layout for user / root X logins
- echo "setxkbmap ${SETXKBMAP}" >>${FSMNT}/usr/share/skel/.xprofile
- chmod 755 ${FSMNT}/usr/share/skel/.xprofile
- cp ${FSMNT}/usr/share/skel/.xprofile ${FSMNT}/root/.xprofile
-
- # Save it for KDM
- echo "setxkbmap ${SETXKBMAP}" >>${FSMNT}/usr/local/kde4/share/config/kdm/Xsetup
- fi
+ KEYMOD="$1"
+ KEYLAY="$2"
+ KEYVAR="$3"
+ COUNTRY="$4"
+ OPTION="grp:alt_shift_toggle"
+ SETXKBMAP=""
+
+ if [ "${COUNTRY}" = "NONE" -o "${COUNTRY}" = "us" -o "${COUNTRY}" = "C" ] ; then
+ #In this case we don't need any additional language
+ COUNTRY=""
+ OPTION=""
+ else
+ COUNTRY=",${COUNTRY}"
+ fi
+
+ if [ "${KEYMOD}" != "NONE" ]
+ then
+ SETXKBMAP="-model ${KEYMOD}"
+ KXMODEL="${KEYMOD}"
+ else
+ KXMODEL="pc104"
+ fi
+
+ if [ "${KEYLAY}" != "NONE" ]
+ then
+ localize_key_layout "$KEYLAY"
+ SETXKBMAP="${SETXKBMAP} -layout ${KEYLAY}"
+ KXLAYOUT="${KEYLAY}"
+ else
+ KXLAYOUT="us"
+ fi
+
+ if [ "${KEYVAR}" != "NONE" ]
+ then
+ SETXKBMAP="${SETXKBMAP} -variant ${KEYVAR}"
+ KXVAR="(${KEYVAR})"
+ else
+ KXVAR=""
+ fi
+
+ # Setup .xprofile with our setxkbmap call now
+ if [ ! -z "${SETXKBMAP}" ]
+ then
+ if [ ! -e "${FSMNT}/usr/share/skel/.xprofile" ]
+ then
+ echo "#!/bin/sh" >${FSMNT}/usr/share/skel/.xprofile
+ fi
+
+ # Save the keyboard layout for user / root X logins
+ echo "setxkbmap ${SETXKBMAP}" >>${FSMNT}/usr/share/skel/.xprofile
+ chmod 755 ${FSMNT}/usr/share/skel/.xprofile
+ cp ${FSMNT}/usr/share/skel/.xprofile ${FSMNT}/root/.xprofile
+
+ # Save it for KDM
+ echo "setxkbmap ${SETXKBMAP}" >>${FSMNT}/usr/local/kde4/share/config/kdm/Xsetup
+ fi
# Create the kxkbrc configuration using these options
- echo "[Layout]
+ echo "[Layout]
DisplayNames=${KXLAYOUT}${COUNTRY}
IndicatorOnly=false
LayoutList=${KXLAYOUT}${KXVAR}${COUNTRY}
@@ -211,157 +211,194 @@ localize_get_codes()
TARGETLANG="${1}"
# Setup the presets for the specific lang
case $TARGETLANG in
- af) COUNTRY="C"
- SETLANG="af"
- LOCALE="af_ZA"
- ;;
- ar) COUNTRY="C"
- SETLANG="ar"
- LOCALE="en_US"
- ;;
- az) COUNTRY="C"
- SETLANG="az"
- LOCALE="en_US"
- ;;
- ca) COUNTRY="es"
- SETLANG="es:ca"
- LOCALE="ca_ES"
- ;;
- be) COUNTRY="be"
- SETLANG="be"
- LOCALE="be_BY"
- ;;
- bn) COUNTRY="bn"
- SETLANG="bn"
- LOCALE="en_US"
- ;;
- bg) COUNTRY="bg"
- SETLANG="bg"
- LOCALE="bg_BG"
- ;;
- cs) COUNTRY="cz"
- SETLANG="cs"
- LOCALE="cs_CZ"
- ;;
- da) COUNTRY="dk"
- SETLANG="da"
- LOCALE="da_DK"
- ;;
- de) COUNTRY="de"
- SETLANG="de"
- LOCALE="de_DE"
- ;;
- en_GB) COUNTRY="gb"
- SETLANG="en_GB:cy"
- LOCALE="en_GB"
- ;;
- el) COUNTRY="gr"
- SETLANG="el:gr"
- LOCALE="el_GR"
- ;;
- es) COUNTRY="es"
- SETLANG="es"
- LOCALE="es_ES"
- ;;
- es_LA) COUNTRY="us"
- SETLANG="es:en_US"
- LOCALE="es_ES"
- ;;
- et) COUNTRY="ee"
- SETLANG="et"
- LOCALE="et_EE"
- ;;
- fr) COUNTRY="fr"
- SETLANG="fr"
- LOCALE="fr_FR"
- ;;
- he) COUNTRY="il"
- SETLANG="he:ar"
- LOCALE="he_IL"
- ;;
- hr) COUNTRY="hr"
- SETLANG="hr"
- LOCALE="hr_HR"
- ;;
- hu) COUNTRY="hu"
- SETLANG="hu"
- LOCALE="hu_HU"
- ;;
- it) COUNTRY="it"
- SETLANG="it"
- LOCALE="it_IT"
- ;;
- ja) COUNTRY="jp"
- SETLANG="ja"
- LOCALE="ja_JP"
- ;;
- ko) COUNTRY="kr"
- SETLANG="ko"
- LOCALE="ko_KR"
- ;;
- nl) COUNTRY="nl"
- SETLANG="nl"
- LOCALE="nl_NL"
- ;;
- nn) COUNTRY="no"
- SETLANG="nn"
- LOCALE="en_US"
- ;;
- pa) COUNTRY="pa"
- SETLANG="pa"
- LOCALE="en_US"
- ;;
- pl) COUNTRY="pl"
- SETLANG="pl"
- LOCALE="pl_PL"
- ;;
- pt) COUNTRY="pt"
- SETLANG="pt"
- LOCALE="pt_PT"
- ;;
- pt_BR) COUNTRY="br"
- SETLANG="pt_BR"
- LOCALE="pt_BR"
- ;;
- ru) COUNTRY="ru"
- SETLANG="ru"
- LOCALE="ru_RU"
- ;;
- sl) COUNTRY="si"
- SETLANG="sl"
- LOCALE="sl_SI"
- ;;
- sk) COUNTRY="sk"
- SETLANG="sk"
- LOCALE="sk_SK"
- ;;
- sv) COUNTRY="se"
- SETLANG="sv"
- LOCALE="sv_SE"
- ;;
- uk) COUNTRY="ua"
- SETLANG="uk"
- LOCALE="uk_UA"
- ;;
- vi) COUNTRY="vn"
- SETLANG="vi"
- LOCALE="en_US"
- ;;
- zh_CN) COUNTRY="cn"
- SETLANG="zh_CN"
- LOCALE="zh_CN"
- ;;
- zh_TW) COUNTRY="tw"
- SETLANG="zh_TW"
- LOCALE="zh_TW"
- ;;
- *) COUNTRY="C"
+ af)
+ COUNTRY="C"
+ SETLANG="af"
+ LOCALE="af_ZA"
+ ;;
+ ar)
+ COUNTRY="C"
+ SETLANG="ar"
+ LOCALE="en_US"
+ ;;
+ az)
+ COUNTRY="C"
+ SETLANG="az"
+ LOCALE="en_US"
+ ;;
+ ca)
+ COUNTRY="es"
+ SETLANG="es:ca"
+ LOCALE="ca_ES"
+ ;;
+ be)
+ COUNTRY="be"
+ SETLANG="be"
+ LOCALE="be_BY"
+ ;;
+ bn)
+ COUNTRY="bn"
+ SETLANG="bn"
+ LOCALE="en_US"
+ ;;
+ bg)
+ COUNTRY="bg"
+ SETLANG="bg"
+ LOCALE="bg_BG"
+ ;;
+ cs)
+ COUNTRY="cz"
+ SETLANG="cs"
+ LOCALE="cs_CZ"
+ ;;
+ da)
+ COUNTRY="dk"
+ SETLANG="da"
+ LOCALE="da_DK"
+ ;;
+ de)
+ COUNTRY="de"
+ SETLANG="de"
+ LOCALE="de_DE"
+ ;;
+ en_GB)
+ COUNTRY="gb"
+ SETLANG="en_GB:cy"
+ LOCALE="en_GB"
+ ;;
+ el)
+ COUNTRY="gr"
+ SETLANG="el:gr"
+ LOCALE="el_GR"
+ ;;
+ es)
+ COUNTRY="es"
+ SETLANG="es"
+ LOCALE="es_ES"
+ ;;
+ es_LA)
+ COUNTRY="us"
+ SETLANG="es:en_US"
+ LOCALE="es_ES"
+ ;;
+ et)
+ COUNTRY="ee"
+ SETLANG="et"
+ LOCALE="et_EE"
+ ;;
+ fr)
+ COUNTRY="fr"
+ SETLANG="fr"
+ LOCALE="fr_FR"
+ ;;
+ he)
+ COUNTRY="il"
+ SETLANG="he:ar"
+ LOCALE="he_IL"
+ ;;
+ hr)
+ COUNTRY="hr"
+ SETLANG="hr"
+ LOCALE="hr_HR"
+ ;;
+ hu)
+ COUNTRY="hu"
+ SETLANG="hu"
+ LOCALE="hu_HU"
+ ;;
+ it)
+ COUNTRY="it"
+ SETLANG="it"
+ LOCALE="it_IT"
+ ;;
+ ja)
+ COUNTRY="jp"
+ SETLANG="ja"
+ LOCALE="ja_JP"
+ ;;
+ ko)
+ COUNTRY="kr"
+ SETLANG="ko"
+ LOCALE="ko_KR"
+ ;;
+ nl)
+ COUNTRY="nl"
+ SETLANG="nl"
+ LOCALE="nl_NL"
+ ;;
+ nn)
+ COUNTRY="no"
+ SETLANG="nn"
+ LOCALE="en_US"
+ ;;
+ pa)
+ COUNTRY="pa"
+ SETLANG="pa"
+ LOCALE="en_US"
+ ;;
+ pl)
+ COUNTRY="pl"
+ SETLANG="pl"
+ LOCALE="pl_PL"
+ ;;
+ pt)
+ COUNTRY="pt"
+ SETLANG="pt"
+ LOCALE="pt_PT"
+ ;;
+ pt_BR)
+ COUNTRY="br"
+ SETLANG="pt_BR"
+ LOCALE="pt_BR"
+ ;;
+ ru)
+ COUNTRY="ru"
+ SETLANG="ru"
+ LOCALE="ru_RU"
+ ;;
+ sl)
+ COUNTRY="si"
+ SETLANG="sl"
+ LOCALE="sl_SI"
+ ;;
+ sk)
+ COUNTRY="sk"
+ SETLANG="sk"
+ LOCALE="sk_SK"
+ ;;
+ sv)
+ COUNTRY="se"
+ SETLANG="sv"
+ LOCALE="sv_SE"
+ ;;
+ uk)
+ COUNTRY="ua"
+ SETLANG="uk"
+ LOCALE="uk_UA"
+ ;;
+ vi)
+ COUNTRY="vn"
+ SETLANG="vi"
+ LOCALE="en_US"
+ ;;
+ zh_CN)
+ COUNTRY="cn"
+ SETLANG="zh_CN"
+ LOCALE="zh_CN"
+ ;;
+ zh_TW)
+ COUNTRY="tw"
+ SETLANG="zh_TW"
+ LOCALE="zh_TW"
+ ;;
+ *)
+ COUNTRY="C"
SETLANG="${TARGETLANG}"
LOCALE="en_US"
;;
esac
- export COUNTRY SETLANG LOCALE
+ export COUNTRY SETLANG LOCALE
};
diff --git a/usr/sbin/pc-sysinstall/backend/functions-mountdisk.sh b/usr/sbin/pc-sysinstall/backend/functions-mountdisk.sh
index e4f94af..9424a62 100755
--- a/usr/sbin/pc-sysinstall/backend/functions-mountdisk.sh
+++ b/usr/sbin/pc-sysinstall/backend/functions-mountdisk.sh
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh,v 1.2 2010/06/27 16:46:11 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh,v 1.5 2010/10/09 08:52:09 imp Exp $
# Functions related mounting the newly formatted disk partitions
@@ -52,32 +52,32 @@ mount_partition()
#We are on ZFS, lets setup this mount-point
if [ "${PARTFS}" = "ZFS" ]
then
- ZPOOLNAME=$(get_zpool_name "${PART}")
-
- # Check if we have multiple zfs mounts specified
- for ZMNT in `echo ${MNTPOINT} | sed 's|,| |g'`
- do
- # First make sure we create the mount point
- if [ ! -d "${FSMNT}${ZMNT}" ] ; then
- mkdir -p ${FSMNT}${ZMNT} >>${LOGOUT} 2>>${LOGOUT}
- fi
-
- if [ "${ZMNT}" = "/" ] ; then
- ZNAME=""
- else
- ZNAME="${ZMNT}"
- echo_log "zfs create -p ${ZPOOLNAME}${ZNAME}"
- rc_halt "zfs create -p ${ZPOOLNAME}${ZNAME}"
- fi
- sleep 2
- rc_halt "zfs set mountpoint=${FSMNT}${ZNAME} ${ZPOOLNAME}${ZNAME}"
-
- # Disable atime for this zfs partition, speed increase
- rc_nohalt "zfs set atime=off ${ZPOOLNAME}${ZNAME}"
- done
+ ZPOOLNAME=$(get_zpool_name "${PART}")
+
+ # Check if we have multiple zfs mounts specified
+ for ZMNT in `echo ${MNTPOINT} | sed 's|,| |g'`
+ do
+ # First make sure we create the mount point
+ if [ ! -d "${FSMNT}${ZMNT}" ] ; then
+ mkdir -p ${FSMNT}${ZMNT} >>${LOGOUT} 2>>${LOGOUT}
+ fi
+
+ if [ "${ZMNT}" = "/" ] ; then
+ ZNAME=""
+ else
+ ZNAME="${ZMNT}"
+ echo_log "zfs create -p ${ZPOOLNAME}${ZNAME}"
+ rc_halt "zfs create -p ${ZPOOLNAME}${ZNAME}"
+ fi
+ sleep 2
+ rc_halt "zfs set mountpoint=${FSMNT}${ZNAME} ${ZPOOLNAME}${ZNAME}"
+
+ # Disable atime for this zfs partition, speed increase
+ rc_nohalt "zfs set atime=off ${ZPOOLNAME}${ZNAME}"
+ done
else
- # If we are not on ZFS, lets do the mount now
+ # If we are not on ZFS, lets do the mount now
# First make sure we create the mount point
if [ ! -d "${FSMNT}${MNTPOINT}" ]
then
@@ -94,17 +94,17 @@ mount_partition()
# Mounts all the new file systems to prepare for installation
mount_all_filesystems()
{
- # Make sure our mount point exists
- mkdir -p ${FSMNT} >/dev/null 2>/dev/null
-
- # First lets find and mount the / partition
- #########################################################
- for PART in `ls ${PARTDIR}`
- do
- if [ ! -e "/dev/${PART}" ]
- then
- exit_err "ERROR: The partition ${PART} does not exist. Failure in bsdlabel?"
- fi
+ # Make sure our mount point exists
+ mkdir -p ${FSMNT} >/dev/null 2>/dev/null
+
+ # First lets find and mount the / partition
+ #########################################################
+ for PART in `ls ${PARTDIR}`
+ do
+ if [ ! -e "/dev/${PART}" ]
+ then
+ exit_err "ERROR: The partition ${PART} does not exist. Failure in bsdlabel?"
+ fi
PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`"
PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`"
@@ -122,69 +122,70 @@ mount_all_filesystems()
if [ "$?" = "0" -o "$PARTMNT" = "/" ]
then
case ${PARTFS} in
- UFS) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime"
- ;;
- UFS+S) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime"
- ;;
- UFS+J) mount_partition ${PART}${EXT}.journal ${PARTFS} ${PARTMNT} "async,noatime"
- ;;
- ZFS) mount_partition ${PART} ${PARTFS} ${PARTMNT}
- ;;
- *) exit_err "ERROR: Got unknown file-system type $PARTFS" ;;
+ UFS) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime" ;;
+ UFS+S) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime" ;;
+ UFS+SUJ) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime" ;;
+ UFS+J) mount_partition ${PART}${EXT}.journal ${PARTFS} ${PARTMNT} "async,noatime" ;;
+ ZFS) mount_partition ${PART} ${PARTFS} ${PARTMNT} ;;
+ IMAGE) mount_partition ${PART} ${PARTFS} ${PARTMNT} ;;
+ *) exit_err "ERROR: Got unknown file-system type $PARTFS" ;;
esac
-
fi
+ done
+
+ # Now that we've mounted "/" lets do any other remaining mount-points
+ ##################################################################
+ for PART in `ls ${PARTDIR}`
+ do
+ if [ ! -e "/dev/${PART}" ]
+ then
+ exit_err "ERROR: The partition ${PART} does not exist. Failure in bsdlabel?"
+ fi
- done
-
- # Now that we've mounted "/" lets do any other remaining mount-points
- ##################################################################
- for PART in `ls ${PARTDIR}`
- do
- if [ ! -e "/dev/${PART}" ]
- then
- exit_err "ERROR: The partition ${PART} does not exist. Failure in bsdlabel?"
- fi
-
- PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`"
- PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`"
- PARTENC="`cat ${PARTDIR}/${PART} | cut -d ':' -f 3`"
-
- if [ "${PARTENC}" = "ON" ]
- then
- EXT=".eli"
- else
- EXT=""
- fi
-
- # Check if we've found "/" again, don't need to mount it twice
- echo "$PARTMNT" | grep "/," >/dev/null
- if [ "$?" != "0" -a "$PARTMNT" != "/" ]
- then
+ PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`"
+ PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`"
+ PARTENC="`cat ${PARTDIR}/${PART} | cut -d ':' -f 3`"
+
+ if [ "${PARTENC}" = "ON" ]
+ then
+ EXT=".eli"
+ else
+ EXT=""
+ fi
+
+ # Check if we've found "/" again, don't need to mount it twice
+ echo "$PARTMNT" | grep "/," >/dev/null
+ if [ "$?" != "0" -a "$PARTMNT" != "/" ]
+ then
case ${PARTFS} in
- UFS) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime"
- ;;
- UFS+S) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime"
- ;;
- UFS+J) mount_partition ${PART}${EXT}.journal ${PARTFS} ${PARTMNT} "async,noatime"
- ;;
- ZFS) mount_partition ${PART} ${PARTFS} ${PARTMNT}
- ;;
- SWAP) # Lets enable this swap now
- if [ "$PARTENC" = "ON" ]
- then
- echo_log "Enabling encrypted swap on /dev/${PART}"
- rc_halt "geli onetime -d -e 3des ${PART}"
- sleep 5
- rc_halt "swapon /dev/${PART}.eli"
- else
- echo_log "swapon ${PART}"
- sleep 5
- rc_halt "swapon /dev/${PART}"
- fi
- ;;
- *) exit_err "ERROR: Got unknown file-system type $PARTFS" ;;
- esac
- fi
- done
+ UFS) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime" ;;
+ UFS+S) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime" ;;
+ UFS+SUJ) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime" ;;
+ UFS+J) mount_partition ${PART}${EXT}.journal ${PARTFS} ${PARTMNT} "async,noatime" ;;
+ ZFS) mount_partition ${PART} ${PARTFS} ${PARTMNT} ;;
+ SWAP)
+ # Lets enable this swap now
+ if [ "$PARTENC" = "ON" ]
+ then
+ echo_log "Enabling encrypted swap on /dev/${PART}"
+ rc_halt "geli onetime -d -e 3des ${PART}"
+ sleep 5
+ rc_halt "swapon /dev/${PART}.eli"
+ else
+ echo_log "swapon ${PART}"
+ sleep 5
+ rc_halt "swapon /dev/${PART}"
+ fi
+ ;;
+ IMAGE)
+ if [ ! -d "${PARTMNT}" ]
+ then
+ mkdir -p "${PARTMNT}"
+ fi
+ mount_partition ${PART} ${PARTFS} ${PARTMNT}
+ ;;
+ *) exit_err "ERROR: Got unknown file-system type $PARTFS" ;;
+ esac
+ fi
+ done
};
diff --git a/usr/sbin/pc-sysinstall/backend/functions-mountoptical.sh b/usr/sbin/pc-sysinstall/backend/functions-mountoptical.sh
index e9147ca..1e0eff3 100755
--- a/usr/sbin/pc-sysinstall/backend/functions-mountoptical.sh
+++ b/usr/sbin/pc-sysinstall/backend/functions-mountoptical.sh
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-mountoptical.sh,v 1.2 2010/06/27 16:46:11 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-mountoptical.sh,v 1.3 2010/08/24 06:11:46 imp Exp $
# Functions which perform mounting / unmounting and switching of
# optical / usb media
@@ -34,114 +34,114 @@
# Displays an optical failure message
opt_fail()
{
- # If we got here, we must not have a DVD/USB we can find :(
- get_value_from_cfg installInteractive
- if [ "${VAL}" = "yes" ]
- then
- # We are running interactive, and didn't find a DVD, prompt user again
- echo_log "DISK ERROR: Unable to find installation disk!"
- echo_log "Please insert the installation disk and press enter."
- read tmp
- else
- exit_err "ERROR: Unable to locate installation DVD/USB"
- fi
+ # If we got here, we must not have a DVD/USB we can find :(
+ get_value_from_cfg installInteractive
+ if [ "${VAL}" = "yes" ]
+ then
+ # We are running interactive, and didn't find a DVD, prompt user again
+ echo_log "DISK ERROR: Unable to find installation disk!"
+ echo_log "Please insert the installation disk and press enter."
+ read tmp
+ else
+ exit_err "ERROR: Unable to locate installation DVD/USB"
+ fi
};
# Performs the extraction of data to disk
opt_mount()
{
- FOUND="0"
-
- # Ensure we have a directory where its supposed to be
- if [ ! -d "${CDMNT}" ]
- then
- mkdir -p ${CDMNT}
- fi
-
-
- # Start by checking if we already have a cd mounted at CDMNT
- mount | grep "${CDMNT} " >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
- then
- if [ -e "${CDMNT}/${INSFILE}" ]
- then
- echo "MOUNTED" >${TMPDIR}/cdmnt
- echo_log "FOUND DVD: MOUNTED"
- FOUND="1"
- return
- fi
-
- # failed to find optical disk
- opt_fail
- return
- fi
-
-# Setup our loop to search for installation media
- while
- z=1
- do
-
- # Loop though and look for an installation disk
- for i in `ls -1 /dev/acd* /dev/cd* /dev/scd* /dev/rscd* 2>/dev/null`
- do
- # Find the CD Device
- /sbin/mount_cd9660 $i ${CDMNT}
-
- # Check the package type to see if we have our install data
- if [ -e "${CDMNT}/${INSFILE}" ]
- then
- echo "${i}" >${TMPDIR}/cdmnt
- echo_log "FOUND DVD: ${i}"
- FOUND="1"
- break
- fi
- /sbin/umount ${CDMNT} >/dev/null 2>/dev/null
- done
-
- # If no DVD found, try USB
- if [ "$FOUND" != "1" ]
- then
- # Loop though and look for an installation disk
- for i in `ls -1 /dev/da* 2>/dev/null`
- do
- # Check if we can mount this device UFS
- /sbin/mount -r $i ${CDMNT}
-
- # Check the package type to see if we have our install data
- if [ -e "${CDMNT}/${INSFILE}" ]
- then
- echo "${i}" >${TMPDIR}/cdmnt
- echo_log "FOUND USB: ${i}"
- FOUND="1"
- break
- fi
- /sbin/umount ${CDMNT} >/dev/null 2>/dev/null
-
- # Also check if it is a FAT mount
- /sbin/mount -r -t msdosfs $i ${CDMNT}
-
- # Check the package type to see if we have our install data
- if [ -e "${CDMNT}/${INSFILE}" ]
- then
- echo "${i}" >${TMPDIR}/cdmnt
- echo_log "FOUND USB: ${i}"
- FOUND="1"
- break
- fi
- /sbin/umount ${CDMNT} >/dev/null 2>/dev/null
- done
- fi # End of USB Check
-
-
- if [ "$FOUND" = "1" ]
- then
- break
- fi
+ FOUND="0"
+
+ # Ensure we have a directory where its supposed to be
+ if [ ! -d "${CDMNT}" ]
+ then
+ mkdir -p ${CDMNT}
+ fi
+
+
+ # Start by checking if we already have a cd mounted at CDMNT
+ mount | grep "${CDMNT} " >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
+ if [ -e "${CDMNT}/${INSFILE}" ]
+ then
+ echo "MOUNTED" >${TMPDIR}/cdmnt
+ echo_log "FOUND DVD: MOUNTED"
+ FOUND="1"
+ return
+ fi
+
+ # failed to find optical disk
+ opt_fail
+ return
+ fi
+
+ # Setup our loop to search for installation media
+ while
+ z=1
+ do
+
+ # Loop though and look for an installation disk
+ for i in `ls -1 /dev/acd* /dev/cd* /dev/scd* /dev/rscd* 2>/dev/null`
+ do
+ # Find the CD Device
+ /sbin/mount_cd9660 $i ${CDMNT}
+
+ # Check the package type to see if we have our install data
+ if [ -e "${CDMNT}/${INSFILE}" ]
+ then
+ echo "${i}" >${TMPDIR}/cdmnt
+ echo_log "FOUND DVD: ${i}"
+ FOUND="1"
+ break
+ fi
+ #/sbin/umount ${CDMNT} >/dev/null 2>/dev/null
+ done
+
+ # If no DVD found, try USB
+ if [ "$FOUND" != "1" ]
+ then
+ # Loop though and look for an installation disk
+ for i in `ls -1 /dev/da* 2>/dev/null`
+ do
+ # Check if we can mount this device UFS
+ /sbin/mount -r $i ${CDMNT}
+
+ # Check the package type to see if we have our install data
+ if [ -e "${CDMNT}/${INSFILE}" ]
+ then
+ echo "${i}" >${TMPDIR}/cdmnt
+ echo_log "FOUND USB: ${i}"
+ FOUND="1"
+ break
+ fi
+ #/sbin/umount ${CDMNT} >/dev/null 2>/dev/null
+
+ # Also check if it is a FAT mount
+ /sbin/mount -r -t msdosfs $i ${CDMNT}
+
+ # Check the package type to see if we have our install data
+ if [ -e "${CDMNT}/${INSFILE}" ]
+ then
+ echo "${i}" >${TMPDIR}/cdmnt
+ echo_log "FOUND USB: ${i}"
+ FOUND="1"
+ break
+ fi
+ #/sbin/umount ${CDMNT} >/dev/null 2>/dev/null
+ done
+ fi # End of USB Check
+
+
+ if [ "$FOUND" = "1" ]
+ then
+ break
+ fi
- # Failed to find a disk, take action now
- opt_fail
+ # Failed to find a disk, take action now
+ opt_fail
- done
+ done
};
diff --git a/usr/sbin/pc-sysinstall/backend/functions-networking.sh b/usr/sbin/pc-sysinstall/backend/functions-networking.sh
index 95eeaad..fa0fa06 100755
--- a/usr/sbin/pc-sysinstall/backend/functions-networking.sh
+++ b/usr/sbin/pc-sysinstall/backend/functions-networking.sh
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-networking.sh,v 1.2 2010/06/27 16:46:11 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-networking.sh,v 1.3 2010/08/24 06:11:46 imp Exp $
# Functions which perform our networking setup
@@ -68,8 +68,8 @@ get_first_wired_nic()
check_is_wifi ${NIC}
if [ "$?" != "0" ]
then
- VAL="${NIC}" ; export VAL
- return
+ VAL="${NIC}" ; export VAL
+ return
fi
done < ${TMPDIR}/.niclist
fi
@@ -241,22 +241,23 @@ enable_auto_dhcp()
is_nic_active "${NIC}"
if [ "$?" = "0" ] ; then
- echo_log "Trying DHCP on $NIC $DESC"
- dhclient ${NIC} >/dev/null 2>/dev/null
- if [ "$?" = "0" ] ; then
- # Got a valid DHCP IP, we can return now
- WRKNIC="$NIC" ; export WRKNIC
- return 0
- fi
+ echo_log "Trying DHCP on $NIC $DESC"
+ dhclient ${NIC} >/dev/null 2>/dev/null
+ if [ "$?" = "0" ] ; then
+ # Got a valid DHCP IP, we can return now
+ WRKNIC="$NIC" ; export WRKNIC
+ return 0
+ fi
fi
done < ${TMPDIR}/.niclist
};
# Get the mac address of a target NIC
-get_nic_mac() {
- FOUNDMAC="`ifconfig ${1} | grep 'ether' | tr -d '\t' | cut -d ' ' -f 2`"
- export FOUNDMAC
+get_nic_mac()
+{
+ FOUNDMAC="`ifconfig ${1} | grep 'ether' | tr -d '\t' | cut -d ' ' -f 2`"
+ export FOUNDMAC
}
# Function which performs the manual setup of a target nic in the cfg
diff --git a/usr/sbin/pc-sysinstall/backend/functions-newfs.sh b/usr/sbin/pc-sysinstall/backend/functions-newfs.sh
index ec333f9..5525d1c 100755
--- a/usr/sbin/pc-sysinstall/backend/functions-newfs.sh
+++ b/usr/sbin/pc-sysinstall/backend/functions-newfs.sh
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-newfs.sh,v 1.3 2010/07/31 19:27:43 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-newfs.sh,v 1.6 2010/10/09 08:52:09 imp Exp $
# Functions related to disk operations using newfs
@@ -81,102 +81,137 @@ setup_zfs_filesystem()
setup_filesystems()
{
- # Create the keydir
- rm -rf ${GELIKEYDIR} >/dev/null 2>/dev/null
- mkdir ${GELIKEYDIR}
-
- # Lets go ahead and read through the saved partitions we created, and determine if we need to run
- # newfs on any of them
- for PART in `ls ${PARTDIR}`
- do
- if [ ! -e "/dev/${PART}" ]
- then
- exit_err "ERROR: The partition ${PART} does not exist. Failure in bsdlabel?"
- fi
+ # Create the keydir
+ rm -rf ${GELIKEYDIR} >/dev/null 2>/dev/null
+ mkdir ${GELIKEYDIR}
+
+ # Lets go ahead and read through the saved partitions we created, and determine if we need to run
+ # newfs on any of them
+ for PART in `ls ${PARTDIR}`
+ do
+ if [ ! -e "/dev/${PART}" ]
+ then
+ exit_err "ERROR: The partition ${PART} does not exist. Failure in bsdlabel?"
+ fi
- PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`"
- PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`"
- PARTENC="`cat ${PARTDIR}/${PART} | cut -d ':' -f 3`"
- PARTLABEL="`cat ${PARTDIR}/${PART} | cut -d ':' -f 4`"
- PARTGEOM="`cat ${PARTDIR}/${PART} | cut -d ':' -f 5`"
- PARTXTRAOPTS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 6`"
-
- # Make sure journaling isn't enabled on this device
- if [ -e "/dev/${PART}.journal" ]
- then
- rc_nohalt "gjournal stop -f ${PART}.journal"
- rc_nohalt "gjournal clear ${PART}"
- fi
-
- # Setup encryption if necessary
- if [ "${PARTENC}" = "ON" -a "${PARTFS}" != "SWAP" ]
- then
- echo_log "Creating geli provider for ${PART}"
- rc_halt "dd if=/dev/random of=${GELIKEYDIR}/${PART}.key bs=64 count=1"
- rc_halt "geli init -b -s 4096 -P -K ${GELIKEYDIR}/${PART}.key /dev/${PART}"
- rc_halt "geli attach -p -k ${GELIKEYDIR}/${PART}.key /dev/${PART}"
-
- EXT=".eli"
- else
- # No Encryption
- EXT=""
- fi
-
- case ${PARTFS} in
- UFS) echo_log "NEWFS: /dev/${PART} - ${PARTFS}"
- sleep 2
- rc_halt "newfs /dev/${PART}${EXT}"
- sleep 2
- rc_halt "sync"
- rc_halt "glabel label ${PARTLABEL} /dev/${PART}${EXT}"
- rc_halt "sync"
-
- # Set flag that we've found a boot partition
- if [ "$PARTMNT" = "/boot" -o "${PARTMNT}" = "/" ] ; then
- HAVEBOOT="YES"
- fi
- sleep 2
- ;;
- UFS+S) echo_log "NEWFS: /dev/${PART} - ${PARTFS}"
- sleep 2
- rc_halt "newfs -U /dev/${PART}${EXT}"
- sleep 2
- rc_halt "sync"
- rc_halt "glabel label ${PARTLABEL} /dev/${PART}${EXT}"
- rc_halt "sync"
- # Set flag that we've found a boot partition
- if [ "$PARTMNT" = "/boot" -o "${PARTMNT}" = "/" ] ; then
- HAVEBOOT="YES"
- fi
- sleep 2
- ;;
- UFS+J) echo_log "NEWFS: /dev/${PART} - ${PARTFS}"
- sleep 2
- rc_halt "newfs /dev/${PART}${EXT}"
- sleep 2
- rc_halt "gjournal label -f /dev/${PART}${EXT}"
- sleep 2
- rc_halt "newfs -O 2 -J /dev/${PART}${EXT}.journal"
- sleep 2
- rc_halt "sync"
- rc_halt "glabel label ${PARTLABEL} /dev/${PART}${EXT}.journal"
- rc_halt "sync"
- # Set flag that we've found a boot partition
- if [ "$PARTMNT" = "/boot" -o "${PARTMNT}" = "/" ] ; then
- HAVEBOOT="YES"
- fi
- sleep 2
- ;;
- ZFS) echo_log "NEWFS: /dev/${PART} - ${PARTFS}"
- setup_zfs_filesystem "${PART}" "${PARTFS}" "${PARTMNT}" "${EXT}" "${PARTGEOM}" "${PARTXTRAOPTS}"
- ;;
- SWAP) rc_halt "sync"
- rc_halt "glabel label ${PARTLABEL} /dev/${PART}${EXT}"
- rc_halt "sync"
- sleep 2
- ;;
- *) exit_err "ERROR: Got unknown file-system type $PARTFS" ;;
- esac
-
- done
+ PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`"
+ PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`"
+ PARTENC="`cat ${PARTDIR}/${PART} | cut -d ':' -f 3`"
+ PARTLABEL="`cat ${PARTDIR}/${PART} | cut -d ':' -f 4`"
+ PARTGEOM="`cat ${PARTDIR}/${PART} | cut -d ':' -f 5`"
+ PARTXTRAOPTS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 6`"
+ PARTIMAGE="`cat ${PARTDIR}/${PART} | cut -d ':' -f 7`"
+
+ # Make sure journaling isn't enabled on this device
+ if [ -e "/dev/${PART}.journal" ]
+ then
+ rc_nohalt "gjournal stop -f ${PART}.journal"
+ rc_nohalt "gjournal clear ${PART}"
+ fi
+
+ # Setup encryption if necessary
+ if [ "${PARTENC}" = "ON" -a "${PARTFS}" != "SWAP" ]
+ then
+ echo_log "Creating geli provider for ${PART}"
+ rc_halt "dd if=/dev/random of=${GELIKEYDIR}/${PART}.key bs=64 count=1"
+ rc_halt "geli init -b -s 4096 -P -K ${GELIKEYDIR}/${PART}.key /dev/${PART}"
+ rc_halt "geli attach -p -k ${GELIKEYDIR}/${PART}.key /dev/${PART}"
+
+ EXT=".eli"
+ else
+ # No Encryption
+ EXT=""
+ fi
+
+ case ${PARTFS} in
+ UFS)
+ echo_log "NEWFS: /dev/${PART} - ${PARTFS}"
+ sleep 2
+ rc_halt "newfs /dev/${PART}${EXT}"
+ sleep 2
+ rc_halt "sync"
+ rc_halt "glabel label ${PARTLABEL} /dev/${PART}${EXT}"
+ rc_halt "sync"
+
+ # Set flag that we've found a boot partition
+ if [ "$PARTMNT" = "/boot" -o "${PARTMNT}" = "/" ] ; then
+ HAVEBOOT="YES"
+ fi
+ sleep 2
+ ;;
+
+ UFS+S)
+ echo_log "NEWFS: /dev/${PART} - ${PARTFS}"
+ sleep 2
+ rc_halt "newfs -U /dev/${PART}${EXT}"
+ sleep 2
+ rc_halt "sync"
+ rc_halt "glabel label ${PARTLABEL} /dev/${PART}${EXT}"
+ rc_halt "sync"
+ # Set flag that we've found a boot partition
+ if [ "$PARTMNT" = "/boot" -o "${PARTMNT}" = "/" ] ; then
+ HAVEBOOT="YES"
+ fi
+ sleep 2
+ ;;
+
+ UFS+SUJ)
+ echo_log "NEWFS: /dev/${PART} - ${PARTFS}"
+ sleep 2
+ rc_halt "newfs -U /dev/${PART}${EXT}"
+ sleep 2
+ rc_halt "sync"
+ rc_halt "tunefs -j enable /dev/${PART}${EXT}"
+ sleep 2
+ rc_halt "sync"
+ rc_halt "glabel label ${PARTLABEL} /dev/${PART}${EXT}"
+ rc_halt "sync"
+ # Set flag that we've found a boot partition
+ if [ "$PARTMNT" = "/boot" -o "${PARTMNT}" = "/" ] ; then
+ HAVEBOOT="YES"
+ fi
+ sleep 2
+ ;;
+
+
+ UFS+J)
+ echo_log "NEWFS: /dev/${PART} - ${PARTFS}"
+ sleep 2
+ rc_halt "newfs /dev/${PART}${EXT}"
+ sleep 2
+ rc_halt "gjournal label -f /dev/${PART}${EXT}"
+ sleep 2
+ rc_halt "newfs -O 2 -J /dev/${PART}${EXT}.journal"
+ sleep 2
+ rc_halt "sync"
+ rc_halt "glabel label ${PARTLABEL} /dev/${PART}${EXT}.journal"
+ rc_halt "sync"
+ # Set flag that we've found a boot partition
+ if [ "$PARTMNT" = "/boot" -o "${PARTMNT}" = "/" ] ; then
+ HAVEBOOT="YES"
+ fi
+ sleep 2
+ ;;
+
+ ZFS)
+ echo_log "NEWFS: /dev/${PART} - ${PARTFS}"
+ setup_zfs_filesystem "${PART}" "${PARTFS}" "${PARTMNT}" "${EXT}" "${PARTGEOM}" "${PARTXTRAOPTS}"
+ ;;
+
+ SWAP)
+ rc_halt "sync"
+ rc_halt "glabel label ${PARTLABEL} /dev/${PART}${EXT}"
+ rc_halt "sync"
+ sleep 2
+ ;;
+
+ IMAGE)
+ write_image "${PARTIMAGE}" "${PART}"
+ sleep 2
+ ;;
+
+ *) exit_err "ERROR: Got unknown file-system type $PARTFS" ;;
+ esac
+
+ done
};
diff --git a/usr/sbin/pc-sysinstall/backend/functions-packages.sh b/usr/sbin/pc-sysinstall/backend/functions-packages.sh
index 4166f9e..ac5e213 100755
--- a/usr/sbin/pc-sysinstall/backend/functions-packages.sh
+++ b/usr/sbin/pc-sysinstall/backend/functions-packages.sh
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-packages.sh,v 1.1 2010/07/13 23:47:12 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-packages.sh,v 1.6 2010/09/08 20:10:24 imp Exp $
# Functions which runs commands on the system
@@ -32,117 +32,345 @@
. ${BACKEND}/functions-ftp.sh
+get_package_index_by_ftp()
+{
+ local INDEX_FILE
+ local FTP_SERVER
+
+ FTP_SERVER="${1}"
+ INDEX_FILE="INDEX"
+ USE_BZIP2=0
+
+ if [ -f "/usr/bin/bzip2" ]
+ then
+ INDEX_FILE="${INDEX_FILE}.bz2"
+ USE_BZIP2=1
+ fi
+
+ INDEX_PATH="${CONFDIR}/${INDEX_FILE}"
+ fetch_file "${FTP_SERVER}/${INDEX_FILE}" "${INDEX_PATH}" "1"
+ if [ -f "${INDEX_PATH}" ] && [ "${USE_BZIP2}" -eq "1" ]
+ then
+ bzip2 -d "${INDEX_PATH}"
+ fi
+};
+
+get_package_index_by_fs()
+{
+ local INDEX_FILE
+
+ INDEX_FILE="${CDMNT}/packages/INDEX"
+ fetch_file "${INDEX_FILE}" "${CONFDIR}/" "0"
+};
+
+get_package_index_size()
+{
+ if [ -f "${CONFDIR}/INDEX" ]
+ then
+ SIZE=`ls -l ${CONFDIR}/INDEX | awk '{ print $5 }'`
+ else
+ get_ftp_mirror
+ FTPHOST="${VAL}"
+
+ FTPDIR="/pub/FreeBSD/releases/${FBSD_ARCH}/${FBSD_BRANCH}"
+ FTPPATH="ftp://${FTPHOST}${FTPDIR}/packages"
+
+ fetch -s "${FTPPATH}/INDEX.bz2"
+ fi
+};
+
get_package_index()
{
- FTP_SERVER="${1}"
- FTP_DIR="ftp://${FTP_SERVER}/pub/FreeBSD/releases/${FBSD_ARCH}/${FBSD_BRANCH}/packages"
- INDEX_FILE="INDEX"
- USE_BZIP2=0
-
- if [ -f "/usr/bin/bzip2" ]
- then
- INDEX_FILE="${INDEX_FILE}.bz2"
- USE_BZIP2=1
- fi
-
- ftp "${FTP_DIR}/${INDEX_FILE}"
- if [ -f "${INDEX_FILE}" ]
- then
- if [ "${USE_BZIP2}" -eq "1" ]
- then
- bzip2 -d "${INDEX_FILE}"
- INDEX_FILE="${INDEX_FILE%.bz2}"
- fi
-
- mv "${INDEX_FILE}" "${PKGDIR}"
- fi
-}
+ RES=0
+
+ if [ -z "${INSTALLMODE}" ]
+ then
+ get_ftp_mirror
+ FTPHOST="${VAL}"
+
+ FTPDIR="/pub/FreeBSD/releases/${FBSD_ARCH}/${FBSD_BRANCH}"
+ FTPPATH="ftp://${FTPHOST}${FTPDIR}/packages"
+
+ get_package_index_by_ftp "${FTPPATH}"
+
+ else
+ get_value_from_cfg ftpHost
+ if [ -z "$VAL" ]
+ then
+ exit_err "ERROR: Install medium was set to ftp, but no ftpHost was provided!"
+ fi
+
+ FTPHOST="${VAL}"
+
+ get_value_from_cfg ftpDir
+ if [ -z "$VAL" ]
+ then
+ exit_err "ERROR: Install medium was set to ftp, but no ftpDir was provided!"
+ fi
+
+ FTPDIR="${VAL}"
+ FTPPATH="ftp://${FTPHOST}${FTPDIR}"
+
+ case "${INSTALLMEDIUM}" in
+ usb|dvd) get_package_index_by_fs ;;
+ ftp) get_package_index_by_ftp "${FTPPATH}" ;;
+ sftp) ;;
+ *) RES=1 ;;
+ esac
+
+ fi
+
+ return ${RES}
+};
parse_package_index()
{
- INDEX_FILE="${PKGDIR}/INDEX"
+ INDEX_FILE="${PKGDIR}/INDEX"
+
+ exec 3<&0
+ exec 0<"${INDEX_FILE}"
+
+ while read -r line
+ do
+ PKGNAME=""
+ CATEGORY=""
+ PACKAGE=""
+ DESC=""
+ DEPS=""
+ i=0
- exec 3<&0
- exec 0<"${INDEX_FILE}"
+ SAVE_IFS="${IFS}"
+ IFS="|"
- while read -r line
- do
- CATEGORY=""
- PACKAGE=""
- DESC=""
- i=0
+ for part in ${line}
+ do
+ if [ "${i}" -eq "0" ]
+ then
+ PKGNAME="${part}"
- SAVE_IFS="${IFS}"
- IFS="|"
+ elif [ "${i}" -eq "1" ]
+ then
+ PACKAGE=`basename "${part}"`
- for part in ${line}
- do
- if [ "${i}" -eq "1" ]
- then
- PACKAGE=`basename "${part}"`
+ elif [ "${i}" -eq "3" ]
+ then
+ DESC="${part}"
- elif [ "${i}" -eq "3" ]
- then
- DESC="${part}"
+ elif [ "${i}" -eq "6" ]
+ then
+ CATEGORY=`echo "${part}" | cut -f1 -d' '`
- elif [ "${i}" -eq "6" ]
- then
- CATEGORY=`echo "${part}" | cut -f1 -d' '`
- fi
+ elif [ "${i}" -eq "8" ]
+ then
+ DEPS="${part}"
+ fi
- i=$((i+1))
- done
+ i=$((i+1))
+ done
- echo "${CATEGORY}|${PACKAGE}|${DESC}" >> "${INDEX_FILE}.parsed"
- IFS="${SAVE_IFS}"
- done
+ echo "${CATEGORY}|${PACKAGE}|${DESC}" >> "${INDEX_FILE}.parsed"
+ echo "${PACKAGE}|${PKGNAME}|${DEPS}" >> "${INDEX_FILE}.deps"
- exec 0<&3
-}
+ IFS="${SAVE_IFS}"
+ done
+
+ exec 0<&3
+};
show_package_file()
{
- PKGFILE="${1}"
+ PKGFILE="${1}"
+
+ echo "Available Packages:"
- exec 3<&0
- exec 0<"${PKGFILE}"
+ exec 3<&0
+ exec 0<"${PKGFILE}"
- while read -r line
- do
- CATEGORY=`echo "${line}" | cut -f1 -d'|'`
- PACKAGE=`echo "${line}" | cut -f2 -d'|'`
- DESC=`echo "${line}" | cut -f3 -d'|'`
+ while read -r line
+ do
+ CATEGORY=`echo "${line}" | cut -f1 -d'|'`
+ PACKAGE=`echo "${line}" | cut -f2 -d'|'`
+ DESC=`echo "${line}" | cut -f3 -d'|'`
- echo "${CATEGORY}/${PACKAGE}:${DESC}"
- done
+ echo "${CATEGORY}/${PACKAGE}:${DESC}"
+ done
- exec 0<&3
-}
+ exec 0<&3
+};
show_packages_by_category()
{
- CATEGORY="${1}"
- INDEX_FILE="${PKGDIR}/INDEX.parsed"
- TMPFILE="/tmp/.pkg.cat"
+ CATEGORY="${1}"
+ INDEX_FILE="${PKGDIR}/INDEX.parsed"
+ TMPFILE="/tmp/.pkg.cat"
- grep "^${CATEGORY}|" "${INDEX_FILE}" > "${TMPFILE}"
- show_package_file "${TMPFILE}"
- rm "${TMPFILE}"
-}
+ grep "^${CATEGORY}|" "${INDEX_FILE}" > "${TMPFILE}"
+ show_package_file "${TMPFILE}"
+ rm "${TMPFILE}"
+};
show_package_by_name()
{
- CATEGORY="${1}"
- PACKAGE="${2}"
- INDEX_FILE="${PKGDIR}/INDEX.parsed"
- TMPFILE="/tmp/.pkg.cat.pak"
+ CATEGORY="${1}"
+ PACKAGE="${2}"
+ INDEX_FILE="${PKGDIR}/INDEX.parsed"
+ TMPFILE="/tmp/.pkg.cat.pak"
- grep "^${CATEGORY}|${PACKAGE}" "${INDEX_FILE}" > "${TMPFILE}"
- show_package_file "${TMPFILE}"
- rm "${TMPFILE}"
-}
+ grep "^${CATEGORY}|${PACKAGE}" "${INDEX_FILE}" > "${TMPFILE}"
+ show_package_file "${TMPFILE}"
+ rm "${TMPFILE}"
+};
show_packages()
{
- show_package_file "${PKGDIR}/INDEX.parsed"
-}
+ show_package_file "${PKGDIR}/INDEX.parsed"
+};
+
+get_package_dependencies()
+{
+ PACKAGE="${1}"
+ LONG="${2:-0}"
+ RES=0
+
+ INDEX_FILE="${PKGDIR}/INDEX.deps"
+ REGEX="^${PACKAGE}|"
+
+ if [ "${LONG}" -ne "0" ]
+ then
+ REGEX="^.*|${PACKAGE}|"
+ fi
+
+ LINE=`grep "${REGEX}" "${INDEX_FILE}" 2>/dev/null`
+ DEPS=`echo "${LINE}"|cut -f3 -d'|'`
+
+ VAL="${DEPS}"
+ export VAL
+
+ if [ -z "${VAL}" ]
+ then
+ RES=1
+ fi
+
+ return ${RES}
+};
+
+get_package_name()
+{
+ PACKAGE="${1}"
+ RES=0
+
+ INDEX_FILE="${PKGDIR}/INDEX.deps"
+ REGEX="^${PACKAGE}|"
+
+ LINE=`grep "${REGEX}" "${INDEX_FILE}" 2>/dev/null`
+ NAME=`echo "${LINE}"|cut -f2 -d'|'`
+
+ VAL="${NAME}"
+ export VAL
+
+ if [ -z "${VAL}" ]
+ then
+ RES=1
+ fi
+
+ return ${RES}
+};
+
+get_package_short_name()
+{
+ PACKAGE="${1}"
+ RES=0
+
+ INDEX_FILE="${PKGDIR}/INDEX.deps"
+ REGEX="^.*|${PACKAGE}|"
+
+ LINE=`grep "${REGEX}" "${INDEX_FILE}" 2>/dev/null`
+ NAME=`echo "${LINE}"|cut -f1 -d'|'`
+
+ VAL="${NAME}"
+ export VAL
+
+ if [ -z "${VAL}" ]
+ then
+ RES=1
+ fi
+
+ return ${RES}
+};
+
+get_package_category()
+{
+ PACKAGE="${1}"
+ INDEX_FILE="${PKGDIR}/INDEX.parsed"
+ RES=0
+
+ LINE=`grep "|${PACKAGE}|" "${INDEX_FILE}" 2>/dev/null`
+ NAME=`echo "${LINE}"|cut -f1 -d'|'`
+
+ VAL="${NAME}"
+ export VAL
+
+ if [ -z "${VAL}" ]
+ then
+ RES=1
+ fi
+
+ return ${RES}
+};
+
+fetch_package_by_ftp()
+{
+ CATEGORY="${1}"
+ PACKAGE="${2}"
+ SAVEDIR="${3}"
+
+ get_value_from_cfg ftpHost
+ if [ -z "$VAL" ]
+ then
+ exit_err "ERROR: Install medium was set to ftp, but no ftpHost was provided!"
+ fi
+ FTPHOST="${VAL}"
+
+ get_value_from_cfg ftpDir
+ if [ -z "$VAL" ]
+ then
+ exit_err "ERROR: Install medium was set to ftp, but no ftpDir was provided!"
+ fi
+ FTPDIR="${VAL}"
+
+ PACKAGE="${PACKAGE}.tbz"
+ FTP_SERVER="ftp://${FTPHOST}${FTPDIR}"
+
+ if [ ! -f "${SAVEDIR}/${PACKAGE}" ]
+ then
+ PKGPATH="${CATEGORY}/${PACKAGE}"
+ FTP_PATH="${FTP_HOST}/packages/${PKGPATH}"
+ fetch_file "${FTP_PATH}" "${SAVEDIR}/" "0"
+ fi
+};
+
+fetch_package_by_fs()
+{
+ CATEGORY="${1}"
+ PACKAGE="${2}"
+ SAVEDIR="${3}"
+
+ PACKAGE="${PACKAGE}.tbz"
+ if [ ! -f "${SAVEDIR}/${PACKAGE}" ]
+ then
+ fetch_file "${CDMNT}/packages/${CATEGORY}/${PACKAGE}" "${SAVEDIR}/" "0"
+ fi
+};
+
+fetch_package()
+{
+ CATEGORY="${1}"
+ PACKAGE="${2}"
+ SAVEDIR="${3}"
+
+ case "${INSTALLMEDIUM}" in
+ usb|dvd) fetch_package_by_fs "${CATEGORY}" "${PACKAGE}" "${SAVEDIR}" ;;
+ ftp) fetch_package_by_ftp "${CATEGORY}" "${PACKAGE}" "${SAVEDIR}" ;;
+ sftp) ;;
+ esac
+};
diff --git a/usr/sbin/pc-sysinstall/backend/functions-parse.sh b/usr/sbin/pc-sysinstall/backend/functions-parse.sh
index a9453cc..d8e5723 100755
--- a/usr/sbin/pc-sysinstall/backend/functions-parse.sh
+++ b/usr/sbin/pc-sysinstall/backend/functions-parse.sh
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-parse.sh,v 1.2 2010/06/27 16:46:11 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-parse.sh,v 1.4 2010/09/08 20:10:24 imp Exp $
# functions.sh
# Library of functions which pc-sysinstall may call upon for parsing the config
@@ -85,6 +85,7 @@ if_check_value_exists()
VALID="1"
for i in ${2}
do
+ VAL=`echo "$VAL"|tr A-Z a-z`
if [ "$VAL" = "${i}" ]
then
VALID="0"
@@ -132,19 +133,19 @@ file_sanity_check()
then
for i in $1
do
- grep "^${i}=" $CFGF >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
- then
- LN=`grep "^${i}=" ${CFGF} | head -n 1 | cut -d '=' -f 2 | tr -d ' '`
- if [ -z "${LN}" ]
- then
- echo "Error: Config fails sanity test! ${i}= is empty"
- exit 1
- fi
- else
- echo "Error: Config fails sanity test! Missing ${i}="
- exit 1
- fi
+ grep "^${i}=" $CFGF >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
+ LN=`grep "^${i}=" ${CFGF} | head -n 1 | cut -d '=' -f 2 | tr -d ' '`
+ if [ -z "${LN}" ]
+ then
+ echo "Error: Config fails sanity test! ${i}= is empty"
+ exit 1
+ fi
+ else
+ echo "Error: Config fails sanity test! Missing ${i}="
+ exit 1
+ fi
done
else
echo "Error: Missing config file, and / or values to sanity check for!"
diff --git a/usr/sbin/pc-sysinstall/backend/functions-runcommands.sh b/usr/sbin/pc-sysinstall/backend/functions-runcommands.sh
index daa8e6d..29e3606 100755
--- a/usr/sbin/pc-sysinstall/backend/functions-runcommands.sh
+++ b/usr/sbin/pc-sysinstall/backend/functions-runcommands.sh
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-runcommands.sh,v 1.2 2010/06/27 16:46:11 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-runcommands.sh,v 1.3 2010/08/19 05:59:27 imp Exp $
# Functions which runs commands on the system
@@ -37,7 +37,10 @@ run_chroot_cmd()
echo "$CMD" >${FSMNT}/.runcmd.sh
chmod 755 ${FSMNT}/.runcmd.sh
chroot ${FSMNT} sh /.runcmd.sh
+ RES=$?
+
rm ${FSMNT}/.runcmd.sh
+ return ${RES}
};
run_chroot_script()
@@ -50,8 +53,10 @@ run_chroot_script()
echo_log "Running chroot script: ${SCRIPT}"
chroot ${FSMNT} /.${SBASE}
+ RES=$?
rm ${FSMNT}/.${SBASE}
+ return ${RES}
};
@@ -64,7 +69,10 @@ run_ext_cmd()
echo "${CMD}"> ${TMPDIR}/.runcmd.sh
chmod 755 ${TMPDIR}/.runcmd.sh
sh ${TMPDIR}/.runcmd.sh
+ RES=$?
+
rm ${TMPDIR}/.runcmd.sh
+ return ${RES}
};
diff --git a/usr/sbin/pc-sysinstall/backend/functions-unmount.sh b/usr/sbin/pc-sysinstall/backend/functions-unmount.sh
index d0121dd..367cb27 100755
--- a/usr/sbin/pc-sysinstall/backend/functions-unmount.sh
+++ b/usr/sbin/pc-sysinstall/backend/functions-unmount.sh
@@ -23,18 +23,19 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-unmount.sh,v 1.2 2010/06/27 16:46:11 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-unmount.sh,v 1.4 2010/10/09 07:45:24 imp Exp $
# Functions which unmount all mounted disk filesystems
# Unmount all mounted partitions under specified dir
-umount_all_dir() {
- _udir="$1"
- _umntdirs=`mount | sort -r | grep "on $_udir" | cut -d ' ' -f 3`
- for _ud in $_umntdirs
- do
- umount -f ${_ud}
- done
+umount_all_dir()
+{
+ _udir="$1"
+ _umntdirs=`mount | sort -r | grep "on $_udir" | cut -d ' ' -f 3`
+ for _ud in $_umntdirs
+ do
+ umount -f ${_ud}
+ done
}
# Script that adds our gmirror devices for syncing
@@ -58,93 +59,95 @@ start_gmirror_sync()
# Unmounts all our mounted file-systems
unmount_all_filesystems()
{
- # Copy the logfile to disk before we unmount
- cp ${LOGOUT} ${FSMNT}/root/pc-sysinstall.log
- cd /
+ # Copy the logfile to disk before we unmount
+ cp ${LOGOUT} ${FSMNT}/root/pc-sysinstall.log
+ cd /
- # Start by unmounting any ZFS partitions
- zfs_cleanup_unmount
+ # Start by unmounting any ZFS partitions
+ zfs_cleanup_unmount
- # Lets read our partition list, and unmount each
- ##################################################################
- for PART in `ls ${PARTDIR}`
- do
-
- PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`"
- PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`"
- PARTENC="`cat ${PARTDIR}/${PART} | cut -d ':' -f 3`"
- PARTLABEL="`cat ${PARTDIR}/${PART} | cut -d ':' -f 4`"
-
- if [ "${PARTENC}" = "ON" ]
- then
- EXT=".eli"
- else
- EXT=""
- fi
-
- #if [ "${PARTFS}" = "SWAP" ]
- #then
- # rc_nohalt "swapoff /dev/${PART}${EXT}"
- #fi
-
- # Check if we've found "/", and unmount that last
- if [ "$PARTMNT" != "/" -a "${PARTMNT}" != "none" -a "${PARTFS}" != "ZFS" ]
- then
- #rc_halt "umount -f /dev/${PART}${EXT}"
-
- # Re-check if we are missing a label for this device and create it again if so
- if [ ! -e "/dev/label/${PARTLABEL}" ]
- then
- case ${PARTFS} in
- UFS) glabel label ${PARTLABEL} /dev/${PART}${EXT} ;;
- UFS+S) glabel label ${PARTLABEL} /dev/${PART}${EXT} ;;
- UFS+J) glabel label ${PARTLABEL} /dev/${PART}${EXT}.journal ;;
- *) ;;
- esac
- fi
- fi
-
- # Check if we've found "/" and make sure the label exists
- if [ "$PARTMNT" = "/" -a "${PARTFS}" != "ZFS" ]
- then
- if [ ! -e "/dev/label/${PARTLABEL}" ]
- then
- case ${PARTFS} in
- UFS) ROOTRELABEL="glabel label ${PARTLABEL} /dev/${PART}${EXT}" ;;
- UFS+S) ROOTRELABEL="glabel label ${PARTLABEL} /dev/${PART}${EXT}" ;;
- UFS+J) ROOTRELABEL="glabel label ${PARTLABEL} /dev/${PART}${EXT}.journal" ;;
- *) ;;
- esac
- fi
- fi
- done
-
- # Last lets the /mnt partition
- #########################################################
- #rc_nohalt "umount -f ${FSMNT}"
-
- # If are using a ZFS on "/" set it to legacy
- if [ ! -z "${FOUNDZFSROOT}" ]
- then
- #rc_halt "zfs set mountpoint=legacy ${FOUNDZFSROOT}"
- fi
+ # Lets read our partition list, and unmount each
+ ##################################################################
+ for PART in `ls ${PARTDIR}`
+ do
+
+ PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`"
+ PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`"
+ PARTENC="`cat ${PARTDIR}/${PART} | cut -d ':' -f 3`"
+ PARTLABEL="`cat ${PARTDIR}/${PART} | cut -d ':' -f 4`"
- # If we need to relabel "/" do it now
- if [ ! -z "${ROOTRELABEL}" ]
- then
- ${ROOTRELABEL}
- fi
+ if [ "${PARTENC}" = "ON" ]
+ then
+ EXT=".eli"
+ else
+ EXT=""
+ fi
- # Unmount our CDMNT
- #rc_nohalt "umount -f ${CDMNT}" >/dev/null 2>/dev/null
+ #if [ "${PARTFS}" = "SWAP" ]
+ #then
+ # rc_nohalt "swapoff /dev/${PART}${EXT}"
+ #fi
- # Check if we need to run any gmirror syncing
- ls ${MIRRORCFGDIR}/* >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
- then
- # Lets start syncing now
- start_gmirror_sync
- fi
+ # Check if we've found "/", and unmount that last
+ if [ "$PARTMNT" != "/" -a "${PARTMNT}" != "none" -a "${PARTFS}" != "ZFS" ]
+ then
+ #rc_halt "umount -f /dev/${PART}${EXT}"
+
+ # Re-check if we are missing a label for this device and create it again if so
+ if [ ! -e "/dev/label/${PARTLABEL}" ]
+ then
+ case ${PARTFS} in
+ UFS) glabel label ${PARTLABEL} /dev/${PART}${EXT} ;;
+ UFS+S) glabel label ${PARTLABEL} /dev/${PART}${EXT} ;;
+ UFS+SUJ) glabel label ${PARTLABEL} /dev/${PART}${EXT} ;;
+ UFS+J) glabel label ${PARTLABEL} /dev/${PART}${EXT}.journal ;;
+ *) ;;
+ esac
+ fi
+ fi
+
+ # Check if we've found "/" and make sure the label exists
+ if [ "$PARTMNT" = "/" -a "${PARTFS}" != "ZFS" ]
+ then
+ if [ ! -e "/dev/label/${PARTLABEL}" ]
+ then
+ case ${PARTFS} in
+ UFS) ROOTRELABEL="glabel label ${PARTLABEL} /dev/${PART}${EXT}" ;;
+ UFS+S) ROOTRELABEL="glabel label ${PARTLABEL} /dev/${PART}${EXT}" ;;
+ UFS+SUJ) ROOTRELABEL="glabel label ${PARTLABEL} /dev/${PART}${EXT}" ;;
+ UFS+J) ROOTRELABEL="glabel label ${PARTLABEL} /dev/${PART}${EXT}.journal" ;;
+ *) ;;
+ esac
+ fi
+ fi
+ done
+
+ # Last lets the /mnt partition
+ #########################################################
+ #rc_nohalt "umount -f ${FSMNT}"
+
+ # If are using a ZFS on "/" set it to legacy
+ if [ ! -z "${FOUNDZFSROOT}" ]
+ then
+ rc_halt "zfs set mountpoint=legacy ${FOUNDZFSROOT}"
+ fi
+
+ # If we need to relabel "/" do it now
+ if [ ! -z "${ROOTRELABEL}" ]
+ then
+ ${ROOTRELABEL}
+ fi
+
+ # Unmount our CDMNT
+ #rc_nohalt "umount -f ${CDMNT}" >/dev/null 2>/dev/null
+
+ # Check if we need to run any gmirror syncing
+ ls ${MIRRORCFGDIR}/* >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
+ # Lets start syncing now
+ start_gmirror_sync
+ fi
};
@@ -164,43 +167,43 @@ unmount_all_filesystems_failure()
for PART in `ls ${PARTDIR}`
do
- PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`"
- PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`"
- PARTENC="`cat ${PARTDIR}/${PART} | cut -d ':' -f 3`"
-
- #if [ "${PARTFS}" = "SWAP" ]
- #then
- # if [ "${PARTENC}" = "ON" ]
- # then
- # rc_nohalt "swapoff /dev/${PART}.eli"
- # else
- # rc_nohalt "swapoff /dev/${PART}"
- # fi
- #fi
-
- # Check if we've found "/" again, don't need to mount it twice
- if [ "$PARTMNT" != "/" -a "${PARTMNT}" != "none" -a "${PARTFS}" != "ZFS" ]
- then
- #rc_nohalt "umount -f /dev/${PART}"
- #rc_nohalt "umount -f ${FSMNT}${PARTMNT}"
- fi
- done
-
- # Last lets the /mnt partition
- #########################################################
- #rc_nohalt "umount -f ${FSMNT}"
+ PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`"
+ PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`"
+ PARTENC="`cat ${PARTDIR}/${PART} | cut -d ':' -f 3`"
+
+ #if [ "${PARTFS}" = "SWAP" ]
+ #then
+ # if [ "${PARTENC}" = "ON" ]
+ # then
+ # rc_nohalt "swapoff /dev/${PART}.eli"
+ # else
+ # rc_nohalt "swapoff /dev/${PART}"
+ # fi
+ #fi
+
+ # Check if we've found "/" again, don't need to mount it twice
+ if [ "$PARTMNT" != "/" -a "${PARTMNT}" != "none" -a "${PARTFS}" != "ZFS" ]
+ then
+ #rc_nohalt "umount -f /dev/${PART}"
+ #rc_nohalt "umount -f ${FSMNT}${PARTMNT}"
+ fi
+ done
+
+ # Last lets the /mnt partition
+ #########################################################
+ #rc_nohalt "umount -f ${FSMNT}"
- fi
- else
- # We are doing a upgrade, try unmounting any of these filesystems
- chroot ${FSMNT} /sbin/umount -a >>${LOGOUT} >>${LOGOUT}
- umount -f ${FSMNT}/usr >>${LOGOUT} 2>>${LOGOUT}
- umount -f ${FSMNT}/dev >>${LOGOUT} 2>>${LOGOUT}
- umount -f ${FSMNT} >>${LOGOUT} 2>>${LOGOUT}
- rc_nohalt "sh ${TMPDIR}/.upgrade-unmount"
fi
+ else
+ # We are doing a upgrade, try unmounting any of these filesystems
+ chroot ${FSMNT} /sbin/umount -a >>${LOGOUT} >>${LOGOUT}
+ umount -f ${FSMNT}/usr >>${LOGOUT} 2>>${LOGOUT}
+ umount -f ${FSMNT}/dev >>${LOGOUT} 2>>${LOGOUT}
+ umount -f ${FSMNT} >>${LOGOUT} 2>>${LOGOUT}
+ rc_nohalt "sh ${TMPDIR}/.upgrade-unmount"
+ fi
- # Unmount our CDMNT
- #rc_nohalt "umount ${CDMNT}"
+ # Unmount our CDMNT
+ #rc_nohalt "umount ${CDMNT}"
};
diff --git a/usr/sbin/pc-sysinstall/backend/functions-upgrade.sh b/usr/sbin/pc-sysinstall/backend/functions-upgrade.sh
index bf9e704..0b06630 100755
--- a/usr/sbin/pc-sysinstall/backend/functions-upgrade.sh
+++ b/usr/sbin/pc-sysinstall/backend/functions-upgrade.sh
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-upgrade.sh,v 1.2 2010/06/27 16:46:11 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-upgrade.sh,v 1.3 2010/08/24 06:11:46 imp Exp $
# Functions which perform the mounting / unmount for upgrades
@@ -43,8 +43,8 @@ mount_target_slice()
if [ -e "/dev/${MPART}" ] ; then
rc_nohalt "mount /dev/${MPART} ${FSMNT}"
if [ "$?" != "0" ] ; then
- # Check if we have ZFS tank name
- rc_halt "mount -t zfs ${MPART} ${FSMNT}"
+ # Check if we have ZFS tank name
+ rc_halt "mount -t zfs ${MPART} ${FSMNT}"
fi
else
# Check if we have ZFS tank name
@@ -104,7 +104,7 @@ done
run_chroot_cmd "rm -rf /libexec" >/dev/null 2>/dev/null
fi
-}
+};
# Mount the target upgrade partitions
mount_upgrade()
@@ -116,33 +116,33 @@ mount_upgrade()
# We are ready to start mounting, lets read the config and do it
while read line
do
- echo $line | grep "^disk0=" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
- then
-
- # Found a disk= entry, lets get the disk we are working on
- get_value_from_string "${line}"
- strip_white_space "$VAL"
- DISK="$VAL"
- fi
-
- echo $line | grep "^commitDiskPart" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
- then
- # Found our flag to commit this disk setup / lets do sanity check and do it
- if [ ! -z "${DISK}" ]
- then
-
- # Start mounting this slice
- mount_target_slice "${DISK}"
-
- # Increment our disk counter to look for next disk and unset
- unset DISK
- break
- else
- exit_err "ERROR: commitDiskPart was called without procceding disk<num>= and partition= entries!!!"
- fi
- fi
+ echo $line | grep "^disk0=" >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
+
+ # Found a disk= entry, lets get the disk we are working on
+ get_value_from_string "${line}"
+ strip_white_space "$VAL"
+ DISK="$VAL"
+ fi
+
+ echo $line | grep "^commitDiskPart" >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
+ # Found our flag to commit this disk setup / lets do sanity check and do it
+ if [ ! -z "${DISK}" ]
+ then
+
+ # Start mounting this slice
+ mount_target_slice "${DISK}"
+
+ # Increment our disk counter to look for next disk and unset
+ unset DISK
+ break
+ else
+ exit_err "ERROR: commitDiskPart was called without procceding disk<num>= and partition= entries!!!"
+ fi
+ fi
done <${CFGF}
@@ -151,8 +151,8 @@ mount_upgrade()
copy_skel_files_upgrade()
{
- # Now make sure we fix any user profile scripts, which cause problems from 7.x->8.x
- echo '#!/bin/sh
+ # Now make sure we fix any user profile scripts, which cause problems from 7.x->8.x
+ echo '#!/bin/sh
cd /home
for i in `ls`
@@ -179,17 +179,17 @@ do
done
' >${FSMNT}/.fixUserProfile.sh
- chmod 755 ${FSMNT}/.fixUserProfile.sh
- chroot ${FSMNT} /.fixUserProfile.sh >/dev/null 2>/dev/null
- rm ${FSMNT}/.fixUserProfile.sh
+ chmod 755 ${FSMNT}/.fixUserProfile.sh
+ chroot ${FSMNT} /.fixUserProfile.sh >/dev/null 2>/dev/null
+ rm ${FSMNT}/.fixUserProfile.sh
- # if the user wants to keep their original .kde4 profile
- ###########################################################################
- get_value_from_cfg "upgradeKeepDesktopProfile"
- if [ "$VAL" = "YES" -o "$VAL" = "yes" ] ; then
- echo '#!/bin/sh
+ # if the user wants to keep their original .kde4 profile
+ ###########################################################################
+ get_value_from_cfg "upgradeKeepDesktopProfile"
+ if [ "$VAL" = "YES" -o "$VAL" = "yes" ] ; then
+ echo '#!/bin/sh
cd /home
for i in `ls`
do
@@ -202,11 +202,11 @@ do
fi
done
' >${FSMNT}/.fixUserProfile.sh
- chmod 755 ${FSMNT}/.fixUserProfile.sh
- chroot ${FSMNT} /.fixUserProfile.sh >/dev/null 2>/dev/null
- rm ${FSMNT}/.fixUserProfile.sh
+ chmod 755 ${FSMNT}/.fixUserProfile.sh
+ chroot ${FSMNT} /.fixUserProfile.sh >/dev/null 2>/dev/null
+ rm ${FSMNT}/.fixUserProfile.sh
- fi
+ fi
};
@@ -230,18 +230,18 @@ merge_old_configs()
unmount_upgrade()
{
- # If on PC-BSD, make sure we copy any fixed skel files
- if [ "$INSTALLTYPE" != "FreeBSD" ] ; then
- copy_skel_files_upgrade
- fi
+ # If on PC-BSD, make sure we copy any fixed skel files
+ if [ "$INSTALLTYPE" != "FreeBSD" ] ; then
+ copy_skel_files_upgrade
+ fi
- cd /
+ cd /
- # Unmount FS
- umount_all_dir "${FSMNT}"
+ # Unmount FS
+ umount_all_dir "${FSMNT}"
- # Run our saved unmount script for these file-systems
- rc_nohalt "umount -f ${FSMNT}"
+ # Run our saved unmount script for these file-systems
+ rc_nohalt "umount -f ${FSMNT}"
- umount ${CDMNT}
+ umount ${CDMNT}
};
diff --git a/usr/sbin/pc-sysinstall/backend/functions-users.sh b/usr/sbin/pc-sysinstall/backend/functions-users.sh
index 0c66279..be786a1 100755
--- a/usr/sbin/pc-sysinstall/backend/functions-users.sh
+++ b/usr/sbin/pc-sysinstall/backend/functions-users.sh
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-users.sh,v 1.2 2010/06/27 16:46:11 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-users.sh,v 1.3 2010/08/24 06:11:46 imp Exp $
# Functions which runs commands on the system
@@ -72,99 +72,99 @@ setup_users()
while read line
do
- echo $line | grep "^userName=" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
- then
- get_value_from_string "${line}"
- USERNAME="$VAL"
- fi
-
- echo $line | grep "^userComment=" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
- then
- get_value_from_string "${line}"
- USERCOMMENT="$VAL"
- fi
-
- echo $line | grep "^userPass=" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
- then
- get_value_from_string "${line}"
- USERPASS="$VAL"
- fi
-
- echo $line | grep "^userShell=" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
- then
- get_value_from_string "${line}"
- strip_white_space "$VAL"
- USERSHELL="$VAL"
- fi
-
- echo $line | grep "^userHome=" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
- then
- get_value_from_string "${line}"
- USERHOME="$VAL"
- fi
-
- echo $line | grep "^userGroups=" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
- then
- get_value_from_string "${line}"
- USERGROUPS="$VAL"
- fi
-
-
- echo $line | grep "^commitUser" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
- then
- # Found our flag to commit this user, lets check and do it
- if [ ! -z "${USERNAME}" ]
- then
-
- # Now add this user to the system, by building our args list
- ARGS="-n ${USERNAME}"
-
- if [ ! -z "${USERCOMMENT}" ]
- then
- ARGS="${ARGS} -c \"${USERCOMMENT}\""
- fi
+ echo $line | grep "^userName=" >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
+ get_value_from_string "${line}"
+ USERNAME="$VAL"
+ fi
+
+ echo $line | grep "^userComment=" >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
+ get_value_from_string "${line}"
+ USERCOMMENT="$VAL"
+ fi
+
+ echo $line | grep "^userPass=" >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
+ get_value_from_string "${line}"
+ USERPASS="$VAL"
+ fi
+
+ echo $line | grep "^userShell=" >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
+ get_value_from_string "${line}"
+ strip_white_space "$VAL"
+ USERSHELL="$VAL"
+ fi
+
+ echo $line | grep "^userHome=" >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
+ get_value_from_string "${line}"
+ USERHOME="$VAL"
+ fi
+
+ echo $line | grep "^userGroups=" >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
+ get_value_from_string "${line}"
+ USERGROUPS="$VAL"
+ fi
+
+
+ echo $line | grep "^commitUser" >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
+ # Found our flag to commit this user, lets check and do it
+ if [ ! -z "${USERNAME}" ]
+ then
+
+ # Now add this user to the system, by building our args list
+ ARGS="-n ${USERNAME}"
+
+ if [ ! -z "${USERCOMMENT}" ]
+ then
+ ARGS="${ARGS} -c \"${USERCOMMENT}\""
+ fi
- if [ ! -z "${USERPASS}" ]
- then
- ARGS="${ARGS} -h 0"
- echo "${USERPASS}" >${FSMNT}/.tmpPass
- else
- ARGS="${ARGS} -h -"
- rm ${FSMNT}/.tmpPass 2>/dev/null 2>/dev/null
- fi
-
- if [ ! -z "${USERSHELL}" ]
- then
- ARGS="${ARGS} -s \"${USERSHELL}\""
- else
- ARGS="${ARGS} -s \"/nonexistant\""
- fi
+ if [ ! -z "${USERPASS}" ]
+ then
+ ARGS="${ARGS} -h 0"
+ echo "${USERPASS}" >${FSMNT}/.tmpPass
+ else
+ ARGS="${ARGS} -h -"
+ rm ${FSMNT}/.tmpPass 2>/dev/null 2>/dev/null
+ fi
+
+ if [ ! -z "${USERSHELL}" ]
+ then
+ ARGS="${ARGS} -s \"${USERSHELL}\""
+ else
+ ARGS="${ARGS} -s \"/nonexistant\""
+ fi
- if [ ! -z "${USERHOME}" ]
- then
- ARGS="${ARGS} -m -d \"${USERHOME}\""
- fi
-
- if [ ! -z "${USERGROUPS}" ]
- then
- ARGS="${ARGS} -G \"${USERGROUPS}\""
- fi
-
- add_user "${ARGS}"
-
- # Unset our vars before looking for any more users
- unset USERNAME USERCOMMENT USERPASS USERSHELL USERHOME USERGROUPS
- else
- exit_err "ERROR: commitUser was called without any userName= entry!!!"
- fi
- fi
+ if [ ! -z "${USERHOME}" ]
+ then
+ ARGS="${ARGS} -m -d \"${USERHOME}\""
+ fi
+
+ if [ ! -z "${USERGROUPS}" ]
+ then
+ ARGS="${ARGS} -G \"${USERGROUPS}\""
+ fi
+
+ add_user "${ARGS}"
+
+ # Unset our vars before looking for any more users
+ unset USERNAME USERCOMMENT USERPASS USERSHELL USERHOME USERGROUPS
+ else
+ exit_err "ERROR: commitUser was called without any userName= entry!!!"
+ fi
+ fi
done <${CFGF}
diff --git a/usr/sbin/pc-sysinstall/backend/functions.sh b/usr/sbin/pc-sysinstall/backend/functions.sh
index 6221087..5d52009 100755
--- a/usr/sbin/pc-sysinstall/backend/functions.sh
+++ b/usr/sbin/pc-sysinstall/backend/functions.sh
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions.sh,v 1.2 2010/06/27 16:46:11 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions.sh,v 1.7 2010/10/21 22:33:50 imp Exp $
# functions.sh
# Library of functions which pc-sysinstall may call upon
@@ -98,18 +98,18 @@ strip_white_space()
# Displays an error message and exits with error 1
exit_err()
{
- # Echo the message for the users benefit
- echo "$1"
+ # Echo the message for the users benefit
+ echo "$1"
- # Save this error to the log file
- echo "${1}" >>$LOGOUT
+ # Save this error to the log file
+ echo "${1}" >>$LOGOUT
- # Check if we need to unmount any file-systems after this failure
- unmount_all_filesystems_failure
+ # Check if we need to unmount any file-systems after this failure
+ unmount_all_filesystems_failure
- echo "For more details see log file: $LOGOUT"
+ echo "For more details see log file: $LOGOUT"
- exit 1
+ exit 1
};
# Run-command, don't halt if command exits with non-0
@@ -138,7 +138,7 @@ rc_halt()
fi
echo "Running: ${CMD}" >>${LOGOUT}
- ${CMD} >>${LOGOUT} 2>>${LOGOUT}
+ eval ${CMD} >>${LOGOUT} 2>>${LOGOUT}
STATUS="$?"
if [ "${STATUS}" != "0" ]
then
@@ -195,66 +195,67 @@ echo_log()
};
# Make sure we have a numeric
-is_num() {
- expr $1 + 1 2>/dev/null
- return $?
+is_num()
+{
+ expr $1 + 1 2>/dev/null
+ return $?
}
# Function which uses "fetch" to download a file, and display a progress report
fetch_file()
{
-FETCHFILE="$1"
-FETCHOUTFILE="$2"
-EXITFAILED="$3"
-
-SIZEFILE="${TMPDIR}/.fetchSize"
-EXITFILE="${TMPDIR}/.fetchExit"
-
-rm ${SIZEFILE} 2>/dev/null >/dev/null
-rm ${FETCHOUTFILE} 2>/dev/null >/dev/null
-
-fetch -s "${FETCHFILE}" >${SIZEFILE}
-SIZE="`cat ${SIZEFILE}`"
-SIZE="`expr ${SIZE} / 1024`"
-echo "FETCH: ${FETCHFILE}"
-echo "FETCH: ${FETCHOUTFILE}" >>${LOGOUT}
-
-( fetch -o ${FETCHOUTFILE} "${FETCHFILE}" >/dev/null 2>/dev/null ; echo "$?" > ${EXITFILE} ) &
-PID="$!"
-while
-z=1
-do
-
- if [ -e "${FETCHOUTFILE}" ]
- then
- DSIZE=`du -k ${FETCHOUTFILE} | tr -d '\t' | cut -d '/' -f 1`
- if [ $(is_num "$DSIZE") ] ; then
- if [ $SIZE -lt $DSIZE ] ; then DSIZE="$SIZE"; fi
+ FETCHFILE="$1"
+ FETCHOUTFILE="$2"
+ EXITFAILED="$3"
+
+ SIZEFILE="${TMPDIR}/.fetchSize"
+ EXITFILE="${TMPDIR}/.fetchExit"
+
+ rm ${SIZEFILE} 2>/dev/null >/dev/null
+ rm ${FETCHOUTFILE} 2>/dev/null >/dev/null
+
+ fetch -s "${FETCHFILE}" >${SIZEFILE}
+ SIZE="`cat ${SIZEFILE}`"
+ SIZE="`expr ${SIZE} / 1024`"
+ echo "FETCH: ${FETCHFILE}"
+ echo "FETCH: ${FETCHOUTFILE}" >>${LOGOUT}
+
+ ( fetch -o ${FETCHOUTFILE} "${FETCHFILE}" >/dev/null 2>/dev/null ; echo "$?" > ${EXITFILE} ) &
+ PID="$!"
+ while
+ z=1
+ do
+
+ if [ -e "${FETCHOUTFILE}" ]
+ then
+ DSIZE=`du -k ${FETCHOUTFILE} | tr -d '\t' | cut -d '/' -f 1`
+ if [ $(is_num "$DSIZE") ] ; then
+ if [ $SIZE -lt $DSIZE ] ; then DSIZE="$SIZE"; fi
echo "SIZE: ${SIZE} DOWNLOADED: ${DSIZE}"
echo "SIZE: ${SIZE} DOWNLOADED: ${DSIZE}" >>${LOGOUT}
+ fi
fi
- fi
- # Check if the download is finished
- ps -p ${PID} >/dev/null 2>/dev/null
- if [ "$?" != "0" ]
- then
- break;
- fi
+ # Check if the download is finished
+ ps -p ${PID} >/dev/null 2>/dev/null
+ if [ "$?" != "0" ]
+ then
+ break;
+ fi
- sleep 2
-done
+ sleep 2
+ done
-echo "FETCHDONE"
+ echo "FETCHDONE"
-EXIT="`cat ${EXITFILE}`"
-if [ "${EXIT}" != "0" -a "$EXITFAILED" = "1" ]
-then
- exit_err "Error: Failed to download ${FETCHFILE}"
-fi
+ EXIT="`cat ${EXITFILE}`"
+ if [ "${EXIT}" != "0" -a "$EXITFAILED" = "1" ]
+ then
+ exit_err "Error: Failed to download ${FETCHFILE}"
+ fi
-return $EXIT
+ return $EXIT
};
@@ -282,3 +283,215 @@ get_zpool_name()
return
fi
};
+
+iscompressed()
+{
+ local FILE
+ local RES
+
+ FILE="$1"
+ RES=1
+
+ if echo "${FILE}" | \
+ grep -iE '\.(Z|lzo|lzw|lzma|gz|bz2|xz|zip)$' >/dev/null 2>&1
+ then
+ RES=0
+ fi
+
+ return ${RES}
+}
+
+get_compression_type()
+{
+ local FILE
+ local SUFFIX
+
+ FILE="$1"
+ SUFFIX=`echo "${FILE}" | sed -E 's|^(.+)\.(.+)$|\2|'`
+
+ VAL=""
+ SUFFIX=`echo "${SUFFIX}" | tr A-Z a-z`
+ case "${SUFFIX}" in
+ z) VAL="lzw" ;;
+ lzo) VAL="lzo" ;;
+ lzw) VAL="lzw" ;;
+ lzma) VAL="lzma" ;;
+ gz) VAL="gzip" ;;
+ bz2) VAL="bzip2" ;;
+ xz) VAL="xz" ;;
+ zip) VAL="zip" ;;
+ esac
+
+ export VAL
+}
+
+write_image()
+{
+ local DEVICE_FILE
+
+ IMAGE_FILE="$1"
+ DEVICE_FILE="$2"
+
+ if [ -z "${IMAGE_FILE}" ]
+ then
+ exit_err "ERROR: Image file not specified!"
+ fi
+
+ if [ -z "${DEVICE_FILE}" ]
+ then
+ exit_err "ERROR: Device file not specified!"
+ fi
+
+ if [ ! -f "${IMAGE_FILE}" ]
+ then
+ exit_err "ERROR: '${IMAGE_FILE}' does not exist!"
+ fi
+
+ DEVICE_FILE="${DEVICE_FILE#/dev/}"
+ DEVICE_FILE="/dev/${DEVICE_FILE}"
+
+ if [ ! -c "${DEVICE_FILE}" ]
+ then
+ exit_err "ERROR: '${DEVICE_FILE}' is not a character device!"
+ fi
+
+ if iscompressed "${IMAGE_FILE}"
+ then
+ local COMPRESSION
+
+ get_compression_type "${IMAGE_FILE}"
+ COMPRESSION="${VAL}"
+
+ case "${COMPRESSION}" in
+ lzw)
+ rc_halt "uncompress ${IMAGE_FILE} -c | dd of=${DEVICE_FILE}"
+ IMAGE_FILE="${IMAGE_FILE%.Z}"
+ ;;
+
+ lzo)
+ rc_halt "lzop -d $IMAGE_{FILE} -c | dd of=${DEVICE_FILE}"
+ IMAGE_FILE="${IMAGE_FILE%.lzo}"
+ ;;
+
+ lzma)
+ rc_halt "lzma -d ${IMAGE_FILE} -c | dd of=${DEVICE_FILE}"
+ IMAGE_FILE="${IMAGE_FILE%.lzma}"
+ ;;
+
+ gzip)
+ rc_halt "gunzip ${IMAGE_FILE} -c | dd of=${DEVICE_FILE}"
+ IMAGE_FILE="${IMAGE_FILE%.gz}"
+ ;;
+
+ bzip2)
+ rc_halt "bunzip2 ${IMAGE_FILE} -c | dd of=${DEVICE_FILE}"
+ IMAGE_FILE="${IMAGE_FILE%.bz2}"
+ ;;
+
+ xz)
+ rc_halt "xz -d ${IMAGE_FILE} -c | dd of=${DEVICE_FILE}"
+ IMAGE_FILE="${IMAGE_FILE%.xz}"
+ ;;
+
+ zip)
+ rc_halt "unzip ${IMAGE_FILE} -c | dd of=${DEVICE_FILE}"
+ IMAGE_FILE="${IMAGE_FILE%.zip}"
+ ;;
+
+ *)
+ exit_err "ERROR: ${COMPRESSION} compression is not supported"
+ ;;
+ esac
+
+ else
+ rc_halt "dd if=${IMAGE_FILE} of=${DEVICE_FILE}"
+
+ fi
+};
+
+install_fresh()
+{
+ # Lets start setting up the disk slices now
+ setup_disk_slice
+
+ if [ -z "${ROOTIMAGE}" ]
+ then
+
+ # Disk setup complete, now lets parse WORKINGSLICES and setup the bsdlabels
+ setup_disk_label
+
+ # Now we've setup the bsdlabels, lets go ahead and run newfs / zfs
+ # to setup the filesystems
+ setup_filesystems
+
+ # Lets mount the partitions now
+ mount_all_filesystems
+
+ # We are ready to begin extraction, lets start now
+ init_extraction
+
+ # Check if we have any optional modules to load
+ install_components
+
+ # Check if we have any packages to install
+ install_packages
+
+ # Do any localization in configuration
+ run_localize
+
+ # Save any networking config on the installed system
+ save_networking_install
+
+ # Now add any users
+ setup_users
+
+ # Now run any commands specified
+ run_commands
+
+ # Do any last cleanup / setup before unmounting
+ run_final_cleanup
+
+ # Unmount and finish up
+ unmount_all_filesystems
+ fi
+
+ echo_log "Installation finished!"
+};
+
+install_image()
+{
+ # We are ready to begin extraction, lets start now
+ init_extraction
+
+ echo_log "Installation finished!"
+};
+
+install_upgrade()
+{
+ # We're going to do an upgrade, skip all the disk setup
+ # and start by mounting the target drive/slices
+ mount_upgrade
+
+ # Start the extraction process
+ init_extraction
+
+ # Do any localization in configuration
+ run_localize
+
+ # ow run any commands specified
+ run_commands
+
+ # Merge any old configuration files
+ merge_old_configs
+
+ # Check if we have any optional modules to load
+ install_components
+
+ # Check if we have any packages to install
+ install_packages
+
+ # All finished, unmount the file-systems
+ unmount_upgrade
+
+ echo_log "Upgrade finished!"
+};
diff --git a/usr/sbin/pc-sysinstall/backend/installimage.sh b/usr/sbin/pc-sysinstall/backend/installimage.sh
new file mode 100644
index 0000000..3ef77dd
--- /dev/null
+++ b/usr/sbin/pc-sysinstall/backend/installimage.sh
@@ -0,0 +1,34 @@
+#!/bin/sh
+#-
+# Copyright (c) 2010 iXsystems, Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/installimage.sh,v 1.1 2010/09/09 03:33:07 imp Exp $
+
+# Source our functions scripts
+. ${BACKEND}/functions.sh
+
+IMAGE_FILE="${1}"
+DEVICE_FILE="${2}"
+
+write_image "${IMAGE_FILE}" "${DEVICE_FILE}"
diff --git a/usr/sbin/pc-sysinstall/backend/parseconfig.sh b/usr/sbin/pc-sysinstall/backend/parseconfig.sh
index 7d4a800..83c6042 100755
--- a/usr/sbin/pc-sysinstall/backend/parseconfig.sh
+++ b/usr/sbin/pc-sysinstall/backend/parseconfig.sh
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/parseconfig.sh,v 1.2 2010/06/27 16:46:11 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/parseconfig.sh,v 1.6 2010/10/09 08:52:09 imp Exp $
# Main install configuration parsing script
#
@@ -35,12 +35,15 @@
. ${BACKEND}/functions-disk.sh
. ${BACKEND}/functions-extractimage.sh
. ${BACKEND}/functions-installcomponents.sh
+. ${BACKEND}/functions-installpackages.sh
. ${BACKEND}/functions-localize.sh
. ${BACKEND}/functions-mountdisk.sh
. ${BACKEND}/functions-networking.sh
. ${BACKEND}/functions-newfs.sh
+. ${BACKEND}/functions-packages.sh
. ${BACKEND}/functions-parse.sh
. ${BACKEND}/functions-runcommands.sh
+. ${BACKEND}/functions-ftp.sh
. ${BACKEND}/functions-unmount.sh
. ${BACKEND}/functions-upgrade.sh
. ${BACKEND}/functions-users.sh
@@ -95,73 +98,23 @@ PACKAGETYPE="${VAL}" ; export PACKAGETYPE
start_networking
# If we are not doing an upgrade, lets go ahead and setup the disk
-if [ "${INSTALLMODE}" = "fresh" ]
-then
-
- # Lets start setting up the disk slices now
- setup_disk_slice
-
- # Disk setup complete, now lets parse WORKINGSLICES and setup the bsdlabels
- setup_disk_label
-
- # Now we've setup the bsdlabels, lets go ahead and run newfs / zfs
- # to setup the filesystems
- setup_filesystems
-
- # Lets mount the partitions now
- mount_all_filesystems
-
- # We are ready to begin extraction, lets start now
- init_extraction
-
- # Check if we have any optional modules to load
- install_components
-
- # Do any localization in configuration
- run_localize
-
- # Save any networking config on the installed system
- save_networking_install
-
- # Now add any users
- setup_users
-
- # Now run any commands specified
- run_commands
-
- # Do any last cleanup / setup before unmounting
- run_final_cleanup
-
- # Unmount and finish up
- unmount_all_filesystems
-
- echo_log "Installation finished!"
- exit 0
-
-else
- # We're going to do an upgrade, skip all the disk setup
- # and start by mounting the target drive/slices
- mount_upgrade
-
- # Start the extraction process
- init_extraction
-
- # Do any localization in configuration
- run_localize
-
- # Now run any commands specified
- run_commands
-
- # Merge any old configuration files
- merge_old_configs
-
- # Check if we have any optional modules to load
- install_components
-
- # All finished, unmount the file-systems
- unmount_upgrade
-
- echo_log "Upgrade finished!"
- exit 0
-fi
-
+case "${INSTALLMODE}" in
+ fresh)
+ if [ "${INSTALLMEDIUM}" = "image" ]
+ then
+ install_image
+ else
+ install_fresh
+ fi
+ ;;
+
+ upgrade)
+ install_upgrade
+ ;;
+
+ *)
+ exit 1
+ ;;
+esac
+
+exit 0
diff --git a/usr/sbin/pc-sysinstall/conf/pc-sysinstall.conf b/usr/sbin/pc-sysinstall/conf/pc-sysinstall.conf
index 83ae443..92a5b3e 100644
--- a/usr/sbin/pc-sysinstall/conf/pc-sysinstall.conf
+++ b/usr/sbin/pc-sysinstall/conf/pc-sysinstall.conf
@@ -1,5 +1,5 @@
#!/bin/sh
-# $FreeBSD: src/usr.sbin/pc-sysinstall/conf/pc-sysinstall.conf,v 1.2 2010/06/27 17:04:03 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/conf/pc-sysinstall.conf,v 1.4 2010/10/09 08:52:09 imp Exp $
# Configuration options for pc-sysinstall
TMPDIR="/tmp/.pc-sysinstall"
@@ -51,6 +51,10 @@ export COMPFILEDIR
COMPTMPDIR="/usr/.componenttmp"
export COMPTMPDIR
+# set the package temp directory, which is relative to FSMNT
+PKGTMPDIR="/usr/.pkgtmp"
+export PKGTMPDIR
+
# Variables to set the location of installation data
UZIP_FILE="PCBSD.ufs.uzip"
TAR_FILE="PCBSD.tbz"
@@ -64,6 +68,10 @@ FBSD_BRANCH_DIR="${FBSD_BRANCH}"
FBSD_ARCH=`uname -m`
export FBSD_UZIP_FILE FBSD_TAR_FILE FBSD_BRANCH FBSD_BRANCH_DIR FBSD_ARCH
+# Location of image file
+IMAGE_FILE="/home/john/tmp/PCBSD8.1-x86-USB.img"
+export IMAGE_FILE
+
# Our internet mirror listing file location
NETSERVER="http://updates.pcbsd.org"
ARCH="`uname -m`"
diff --git a/usr/sbin/pc-sysinstall/doc/help-index b/usr/sbin/pc-sysinstall/doc/help-index
index d9e52b5..bad401f 100644
--- a/usr/sbin/pc-sysinstall/doc/help-index
+++ b/usr/sbin/pc-sysinstall/doc/help-index
@@ -9,6 +9,8 @@ Help Commands
Display the help data for the specified command
System Query Commands
+ install-image <image> <device>
+ Installs an image file to a device file
disk-list
Provides a listing of the disk drives detected on this system
@@ -34,10 +36,10 @@ System Query Commands
list-components
Returns a listing of the available components which can be installed
- list-mirrors
+ list-mirrors [country]
Returns a listing of the available FTP mirrors
- list-packages
+ list-packages [category] [package]
Returns a listing of the available packages
list-rsync-backups <user> <host> <port>
@@ -55,6 +57,9 @@ System Query Commands
sys-mem
Return the size of installed system RAM in MegaBytes
+ set-mirror <mirror>
+ Set FTP mirror
+
test-netup
Test if an internet connection is available
diff --git a/usr/sbin/pc-sysinstall/examples/README b/usr/sbin/pc-sysinstall/examples/README
index 20cb019..7d9fd5e 100644
--- a/usr/sbin/pc-sysinstall/examples/README
+++ b/usr/sbin/pc-sysinstall/examples/README
@@ -114,7 +114,7 @@ root zpool of the target system to update. I.E:
# disk0=ada0s1a
-# partition=(all, free, s1, s1, s3, s4)
+# partition=(all, free, s1, s1, s3, s4, image)
After setting disk[0-9], the partition= variable is used to specify which target
partition we will be working with for this device.
@@ -124,10 +124,17 @@ Setting this to "all" will setup the disk with a single FreeBSD slice as "s1"
Setting this to "free" will allow pc-sysinstall to search for the first available
primary slice with free space, and create the slice.
-Setting this to "s1, s2, s3 or s4" will use the specified MBR slice
+Setting this to "s1, s2, s3 or s4" will use the specified MBR slice.
+
+Setting this to "image" will use an image to configure the disk.
(This tag is unused for upgrades)
+# partscheme=(MBR/GPT)
+
+When performing a "full" disk (partition=all), the partscheme= variable is used
+to determine the partition scheme type gpart will be using on the disk. Valid
+choices are MBR or GPT.
# mirror=(disk device such as ad1)
@@ -146,6 +153,11 @@ specified this defaults to "round-robin"
Setting this option will instruct pc-sysinstall to install the BSD boot Manager,
or leave it empty
+# image=(/path/to/image/file) (/mountpoint)
+
+Setting this option will instruct pc-sysinstall to write the image file
+specified by the path to the disk.
+
# commitDiskPart
This command must be placed at the end of the diskX= section, before starting
@@ -177,13 +189,14 @@ The notation is as follows:
Available FileSystems:
UFS - Standard UFS2 FileSystem
UFS+S - UFS2 + Softupdates enabled
+UFS+SUJ - UFS2 + Soft Updates + Journaling enabled
UFS+J - UFS2 + Journaling through gjournal
ZFS - Z File System, pools / mounts created automatically
SWAP - BSD Swap space partition, mountpoint should be set to "none"
Adding the ".eli" extension to any of the above file systems
will enable disk encryption via geli
-(UFS.eli, UFS+S.eli, UFS+J.eli, ZFS.eli, SWAP.eli)
+(UFS.eli, UFS+S.eli, UFS+SUJ.eli, UFS+J.eli, ZFS.eli, SWAP.eli)
If you with to use a passphrase with this encrypted partition, on the next line
the flag "encpass=" should be entered:
@@ -205,7 +218,7 @@ If you with to just include the disk into the pool in "basic" mode, then use (ad
The following settings specify the type, locations and sources
for this installation
-# installMedium=(dvd, usb, ftp, rsync)
+# installMedium=(dvd, usb, ftp, rsync, image)
Set installMedium= to the source type we will be using for this install.
@@ -214,6 +227,7 @@ Available Types:
usb - Search for and mount the USB drive which contains the install archive
ftp - The install archive will be fetched from a FTP / HTTP server before install
rsync - Pull the system data from a ssh + rsync server, specified with variables below
+image - Install system from an image
# installType=(PCBSD, FreeBSD)
@@ -352,4 +366,4 @@ localizeKeyVariant is used to update the xorg config to set the keyboard variant
Setting autoLoginUser will enable the specified user to log into the desktop
automatically without entering a password
-$FreeBSD: src/usr.sbin/pc-sysinstall/examples/README,v 1.1 2010/06/24 22:21:47 imp Exp $
+$FreeBSD: src/usr.sbin/pc-sysinstall/examples/README,v 1.5 2010/10/09 08:52:09 imp Exp $
diff --git a/usr/sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.8 b/usr/sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.8
index 69556f4..2b42bbb 100644
--- a/usr/sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.8
+++ b/usr/sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.8
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD: src/usr.sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.8,v 1.2 2010/07/06 23:29:55 imp Exp $
+.\" $FreeBSD: src/usr.sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.8,v 1.5 2010/10/08 12:40:16 uqs Exp $
.\"
.Dd June 24, 2010
.Dt PC-SYSINSTALL 8
@@ -53,16 +53,15 @@ Perform an installation as directed by
The
.Cm command
can be any one of the following:
-.Pp
.Bl -tag -width indent
.It help
Display a list of all commands.
.It help Ar command
-Dispay the help data for the specified command.
+Display the help data for the specified command.
.It disk-list
Provide a listing of the storage devices detected on this system.
.It disk-part Ar disk
-Queries the specified storage device and returns information about its
+Queries the specified storage device and returns information about its
partitions.
.It disk-info Ar disk
Returns information about a storage device's size, cylinders, heads, and
@@ -106,6 +105,7 @@ used by automated install scripts.
.It setup-ssh-keys Ar user Ar host Ar port
Setup SSH without a password for the target host, user, and port. Used to
prompt the user to log into a server before doing a rsync + ssh restore.
+.El
.Sh HISTORY
This version of
.Nm
@@ -117,4 +117,4 @@ first appeared in
This utility was written to install PC-BSD and has seen limited use as an
installer for FreeBSD. It's likely that usage to install FreeBSD will expose
edge cases that PC-BSD doesn't, as well as generate feature requests based
-on unforseen needs.
+on unforeseen needs.
diff --git a/usr/sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh b/usr/sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh
index 3ad2854..9f91e85 100755
--- a/usr/sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh
+++ b/usr/sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh
@@ -30,21 +30,27 @@
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh,v 1.6 2010/07/13 23:47:12 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh,v 1.11 2010/09/08 20:10:24 imp Exp $
#####################################################################
# User-editable configuration variables
# Set this to the program location
-PROGDIR="/usr/sbin/pc-sysinstall"
-export PROGDIR
+if [ -z "${PROGDIR}" ]
+then
+ PROGDIR="/usr/sbin/pc-sysinstall"
+ export PROGDIR
+fi
# Set this to the components location
COMPDIR="${PROGDIR}/components"
export COMPDIR
+CONFDIR="${PROGDIR}/conf"
+export CONFDIR
+
# Set this to the packages location
-PKGDIR="${PROGDIR}/conf"
+PKGDIR="${CONFDIR}"
export PKGDIR
# End of user-editable configuration
@@ -83,29 +89,35 @@ fi
# Check if we are called without any flags and display help
if [ -z "${1}" ]
then
- # Display the help index
- display_help
- exit 0
+ # Display the help index
+ display_help
+ exit 0
fi
case $1 in
# The -c flag has been given, time to parse the script
- -c) if [ -z "${2}" ]
- then
- display_help
- else
- ${BACKEND}/parseconfig.sh ${2}
- exit $?
- fi
+ -c)
+ if [ -z "${2}" ]
+ then
+ display_help
+ else
+ ${BACKEND}/parseconfig.sh ${2}
+ exit $?
+ fi
;;
# The user requsted help
- help) if [ -z "${2}" ]
- then
- display_help
- else
- display_command_help ${2}
- fi
+ help)
+ if [ -z "${2}" ]
+ then
+ display_help
+ else
+ display_command_help ${2}
+ fi
+ ;;
+
+ # Install an image file to a device
+ install-image) ${BACKEND}/installimage.sh "${2}" "${3}"
;;
# Parse an auto-install directive, and begin the installation
@@ -137,7 +149,7 @@ case $1 in
;;
# The user is wanting to query which disks are available
- disk-list) ${QUERYDIR}/disk-list.sh
+ disk-list) ${QUERYDIR}/disk-list.sh $*
;;
# The user is wanting to query a disk's partitions
@@ -184,6 +196,10 @@ case $1 in
get-packages) ${QUERYDIR}/get-packages.sh "${2}"
;;
+ # Function to set FTP mirror
+ set-mirror) ${QUERYDIR}/set-mirror.sh "${2}"
+ ;;
+
# Function which allows setting up of SSH keys
setup-ssh-keys) ${QUERYDIR}/setup-ssh-keys.sh "${2}" "${3}" "${4}"
;;
OpenPOWER on IntegriCloud