From e8567e895eb48e9e9bfb8328ae1c424468ba39a8 Mon Sep 17 00:00:00 2001 From: jim-p Date: Mon, 7 Mar 2011 10:07:58 -0500 Subject: [PATCH 1/7] When doing conf_mount_ro/rw on NanoBSD, pass sync,noatime to mount to preserve the options we have already set in fstab. Ticket #1279 and Ticket #444 --- etc/inc/config.lib.inc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/etc/inc/config.lib.inc b/etc/inc/config.lib.inc index c527fd7a3b..2edcea3d8c 100644 --- a/etc/inc/config.lib.inc +++ b/etc/inc/config.lib.inc @@ -311,23 +311,23 @@ function conf_mount_rw() { if (refcount_reference(1000) > 1) return; - $status = mwexec("/sbin/mount -u -w {$g['cf_path']}"); + $status = mwexec("/sbin/mount -u -w -o sync,noatime {$g['cf_path']}"); if($status <> 0) { if($g['booting']) echo "Disk is dirty. Running fsck -y\n"; mwexec("/sbin/fsck -y {$g['cf_path']}"); - $status = mwexec("/sbin/mount -u -w {$g['cf_path']}"); + $status = mwexec("/sbin/mount -u -w -o sync,noatime {$g['cf_path']}"); } /* if the platform is soekris or wrap or pfSense, lets mount the * compact flash cards root. */ - $status = mwexec("/sbin/mount -u -w /"); + $status = mwexec("/sbin/mount -u -w -o sync,noatime /"); /* we could not mount this correctly. kick off fsck */ if($status <> 0) { log_error("File system is dirty. Launching FSCK for /"); mwexec("/sbin/fsck -y /"); - $status = mwexec("/sbin/mount -u -w /"); + $status = mwexec("/sbin/mount -u -w -o sync,noatime /"); } mark_subsystem_dirty('mount'); @@ -355,8 +355,8 @@ function conf_mount_ro() { clear_subsystem_dirty('mount'); /* sync data, then force a remount of /cf */ pfSense_sync(); - mwexec("/sbin/mount -u -r -f {$g['cf_path']}"); - mwexec("/sbin/mount -u -r -f /"); + mwexec("/sbin/mount -u -r -f -o sync,noatime {$g['cf_path']}"); + mwexec("/sbin/mount -u -r -f -o sync,noatime /"); } /****f* config/convert_config From a5ccf623ff9b11fed77d7fb0f439208aa6d5eaca Mon Sep 17 00:00:00 2001 From: jim-p Date: Mon, 7 Mar 2011 12:24:27 -0500 Subject: [PATCH 2/7] Add cas(4) --- etc/inc/interfaces.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index 2533201b95..be118a88da 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -3481,7 +3481,7 @@ function is_altq_capable($int) { * Only the following drivers have ALTQ support */ $capable = array("age", "alc", "ale", "an", "ath", "aue", "awi", "bce", - "bfe", "bge", "bridge", "dc", "de", "ed", "em", "ep", "fxp", "gem", + "bfe", "bge", "bridge", "cas", "dc", "de", "ed", "em", "ep", "fxp", "gem", "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", From 214bd062189d3b1ffc16bfea645f3c4f155f4ae7 Mon Sep 17 00:00:00 2001 From: jim-p Date: Mon, 7 Mar 2011 15:03:21 -0500 Subject: [PATCH 3/7] Fix typo --- usr/local/www/vpn_ipsec_mobile.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/local/www/vpn_ipsec_mobile.php b/usr/local/www/vpn_ipsec_mobile.php index 4e9c5372a3..b4b1b059c0 100755 --- a/usr/local/www/vpn_ipsec_mobile.php +++ b/usr/local/www/vpn_ipsec_mobile.php @@ -386,7 +386,7 @@ function login_banner_change() { onClick="pool_change()"> -
+
From 06d30ce7db3a859687efdadd0263f0dfab0b32a3 Mon Sep 17 00:00:00 2001 From: Ermal Date: Mon, 7 Mar 2011 21:42:00 +0000 Subject: [PATCH 4/7] Handle the case on some special configs with a gateway of all 1's otherwise strange thing happens. --- sbin/dhclient-script | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbin/dhclient-script b/sbin/dhclient-script index aaa8144192..e7fee7a4d8 100755 --- a/sbin/dhclient-script +++ b/sbin/dhclient-script @@ -189,7 +189,7 @@ add_new_routes() { if [ -f "/tmp/${interface}_defaultgw" -o $EXISTSGW -eq 0 ]; then $ROUTE delete default for router in $new_routers; do - if [ "$new_ip_address" = "$router" ]; then + if [ "$new_ip_address" = "$router" -o "$router" = "255.255.255.255" ]; then $ROUTE add default -iface $interface echo $ROUTE add default -iface $interface | $LOGGER echo $router > /tmp/${interface}_router From 6b5e978b67ab12c124de352298553e7dcbbb9cfe Mon Sep 17 00:00:00 2001 From: Ermal Date: Mon, 7 Mar 2011 22:45:22 +0000 Subject: [PATCH 5/7] Use racoonctl now that ipsec-0.8 is back to reload the config. --- etc/inc/vpn.inc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/etc/inc/vpn.inc b/etc/inc/vpn.inc index 0e212240e3..6f48820bff 100644 --- a/etc/inc/vpn.inc +++ b/etc/inc/vpn.inc @@ -886,9 +886,7 @@ EOD; /* mange racoon process */ if (is_process_running("racoon")) { sleep("0.1"); - /* XXX: This seems to not work in ipsec-tools 0.7.3 but a HUP signal is equivalent. */ - //mwexec("/usr/local/sbin/racoonctl -s /var/db/racoon/racoon.sock reload-config", false); - sigkillbypid("{$g['varrun_path']}/racoon.pid", "HUP"); + mwexec("/usr/local/sbin/racoonctl -s /var/db/racoon/racoon.sock reload-config", false); /* load SPD without flushing to be safe on config additions or changes. */ mwexec("/usr/local/sbin/setkey -f {$g['varetc_path']}/spd.conf", false); } else { From c4ea369140ee6d250996cf98a0566a7f8d0a3355 Mon Sep 17 00:00:00 2001 From: Ermal Date: Tue, 8 Mar 2011 15:16:40 +0000 Subject: [PATCH 6/7] Properly do testing of voucher existing or not rather than relying on an obscure feature of php. Also do exclusive locking rather than shared one when writing dbs. --- etc/inc/voucher.inc | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/etc/inc/voucher.inc b/etc/inc/voucher.inc index febb0f799a..40be5a7659 100644 --- a/etc/inc/voucher.inc +++ b/etc/inc/voucher.inc @@ -100,7 +100,7 @@ EOF; function voucher_auth($voucher_received, $test = 0) { global $g, $config; - $voucherlck = lock('voucher'); + $voucherlck = lock('voucher', LOCK_EX); // XMLRPC Call over to the master Voucher node $a_voucher = &$config['voucher']; @@ -154,10 +154,10 @@ function voucher_auth($voucher_received, $test = 0) { if (!isset($active_vouchers[$roll])) $active_vouchers[$roll] = voucher_read_active_db($roll); // valid voucher. Store roll# and ticket# - if ($line = $active_vouchers[$roll][$voucher]) { - list($timestamp,$minutes) = explode(",", $line); + if (!empty($active_vouchers[$roll][$voucher])) { + list($timestamp,$minutes) = explode(",", $active_vouchers[$roll][$voucher]); // we have an already active voucher here. - $remaining = intval((($timestamp + 60*$minutes) - time())/60); + $remaining = intval((($timestamp + (60*$minutes)) - time())/60); $test_result[] = "$voucher ($roll/$nr) active and good for $remaining Minutes"; $total_minutes += $remaining; } else { @@ -238,8 +238,8 @@ function voucher_auth($voucher_received, $test = 0) { // log in later using just the first voucher. It also keeps username limited // to one voucher and that voucher shows the correct time credit in 'active vouchers' - if ($line = $active_vouchers[$first_voucher_roll][$first_voucher]) { - list($timestamp, $minutes) = explode(",", $line); + if (!empty($active_vouchers[$first_voucher_roll][$first_voucher])) { + list($timestamp, $minutes) = explode(",", $active_vouchers[$first_voucher_roll][$first_voucher]); } else { $timestamp = time(); // new voucher $minutes = $total_minutes; @@ -298,13 +298,13 @@ function voucher_configure() { 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); + unlock($voucherlck); if ($g['booting'] && is_array($config['voucher']['roll'])) { // create active and used DB per roll on ramdisk from config $a_roll = &$config['voucher']['roll']; - $voucherlck = lock('voucher'); + $voucherlck = lock('voucher', LOCK_EX); foreach ($a_roll as $rollent) { @@ -325,8 +325,8 @@ function voucher_configure() { } voucher_write_active_db($roll, $active_vouchers); } - - unlock($voucherlck); + + unlock($voucherlck); echo "done\n"; } @@ -363,7 +363,7 @@ function voucher_read_active_db($roll) { $line = trim(fgets($fd)); if ($line) { list($voucher,$timestamp,$minutes) = explode(",", $line); // voucher,timestamp - if ((($timestamp + 60*$minutes) - time()) > 0) + if ((($timestamp + (60*$minutes)) - time()) > 0) $active[$voucher] = "$timestamp,$minutes"; else $dirty=1; @@ -477,4 +477,4 @@ function voucher_save_db_to_config() { return; } -?> \ No newline at end of file +?> From 13927322394cd9d17318bad6bd377729a3ebe745 Mon Sep 17 00:00:00 2001 From: Ermal Date: Tue, 8 Mar 2011 15:23:51 +0000 Subject: [PATCH 7/7] Do a proper test otherwise a override of the total_minutes var might happen. --- etc/inc/voucher.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/inc/voucher.inc b/etc/inc/voucher.inc index 40be5a7659..3b34e93c3d 100644 --- a/etc/inc/voucher.inc +++ b/etc/inc/voucher.inc @@ -104,7 +104,7 @@ function voucher_auth($voucher_received, $test = 0) { // XMLRPC Call over to the master Voucher node $a_voucher = &$config['voucher']; - if($a_voucher['vouchersyncdbip']) { + if(!empty($a_voucher['vouchersyncdbip'])) { $syncip = $a_voucher['vouchersyncdbip']; $syncport = $a_voucher['vouchersyncport']; $syncpass = $a_voucher['vouchersyncpass']; @@ -215,7 +215,7 @@ function voucher_auth($voucher_received, $test = 0) { } // If we did a XMLRPC sync earlier check the timeleft - if($a_voucher['vouchersyncdbip']) + if(!empty($a_voucher['vouchersyncdbip'])) if($remote_time_used['timeleft'] < $total_minutes) $total_minutes = $remote_time_used['timeleft'];