From f8c462dd898b1b7f8518a4e5c40c40419e263afc Mon Sep 17 00:00:00 2001 From: Warren Baker Date: Sun, 12 Jun 2011 16:10:22 +0200 Subject: [PATCH 01/19] Allow packages to specify that their tabmenus should not be a drop-down list by using a tag. --- usr/local/www/pkg.php | 6 ++++-- usr/local/www/pkg_edit.php | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/usr/local/www/pkg.php b/usr/local/www/pkg.php index b3485f0eb4..0a119d991e 100755 --- a/usr/local/www/pkg.php +++ b/usr/local/www/pkg.php @@ -146,6 +146,8 @@ if ($pkg['tabs'] <> "") { } else { $active = false; } + if(isset($tab['no_drop_down'])) + $no_drop_down = true; $urltmp = ""; if($tab['url'] <> "") $urltmp = $tab['url']; if($tab['xml'] <> "") $urltmp = "pkg_edit.php?xml=" . $tab['xml']; @@ -170,8 +172,8 @@ if ($pkg['tabs'] <> "") { ksort($tab_array); foreach($tab_array as $tab) { - echo ''; - display_top_tabs($tab); + echo ''; + display_top_tabs($tab, $no_drop_down); echo ''; } } diff --git a/usr/local/www/pkg_edit.php b/usr/local/www/pkg_edit.php index 5361b51d52..64b1fa9a22 100755 --- a/usr/local/www/pkg_edit.php +++ b/usr/local/www/pkg_edit.php @@ -366,6 +366,8 @@ if ($pkg['tabs'] <> "") { } else { $active = false; } + if(isset($tab['no_drop_down'])) + $no_drop_down = true; $urltmp = ""; if($tab['url'] <> "") $urltmp = $tab['url']; if($tab['xml'] <> "") $urltmp = "pkg_edit.php?xml=" . $tab['xml']; @@ -390,9 +392,9 @@ if ($pkg['tabs'] <> "") { ksort($tab_array); foreach($tab_array as $tab) { - echo ''; - display_top_tabs($tab); - echo ''; + echo ''; + display_top_tabs($tab, $no_drop_down); + echo ''; } } ?> From 48de5a1069b5f18e14a606a3b9ac65b22896b04e Mon Sep 17 00:00:00 2001 From: Ermal Date: Mon, 13 Jun 2011 12:22:49 +0000 Subject: [PATCH 02/19] Do not test for availbility of voucher session_timeout in the database it is mandatory for vouchers. This will make sure that if ever a corrupted db happens a user will be required to relogin and correct the db. Possibly related to: http://forum.pfsense.org/index.php/topic,37636.0.html --- etc/inc/captiveportal.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/inc/captiveportal.inc b/etc/inc/captiveportal.inc index a87e73202e..413e3bc63c 100644 --- a/etc/inc/captiveportal.inc +++ b/etc/inc/captiveportal.inc @@ -691,7 +691,7 @@ function captiveportal_prune_old() { } /* if vouchers are configured, activate session timeouts */ - if (!$timedout && isset($config['voucher']['enable']) && !empty($cpentry[7])) { + if (!$timedout && isset($config['voucher']['enable'])) { if (time() >= ($cpentry[0] + $cpentry[7])) { $timedout = true; $term_cause = 5; // Session-Timeout From b09c2d86a1f019ff22448109615e11655f12690b Mon Sep 17 00:00:00 2001 From: Ermal Date: Mon, 13 Jun 2011 12:34:00 +0000 Subject: [PATCH 03/19] Do not call time() uselessly every time for each entry. Instead just snapshot it and use it in calculations. This helps performance and useless paranoic time fetching since every 60 seconds the code will be executed again. --- etc/inc/captiveportal.inc | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/etc/inc/captiveportal.inc b/etc/inc/captiveportal.inc index 413e3bc63c..b0cbf14845 100644 --- a/etc/inc/captiveportal.inc +++ b/etc/inc/captiveportal.inc @@ -653,6 +653,12 @@ function captiveportal_prune_old() { */ $unsetindexes = array(); $voucher_needs_sync = false; + /* + * Snapshot the time here to use for calculation to speed up the process. + * If something is missed next run will catch it! + */ + $pruning_time = time(); + $stop_time = $pruning_time; foreach ($cpdb as $cpentry) { $timedout = false; @@ -660,7 +666,7 @@ function captiveportal_prune_old() { /* hard timeout? */ if ($timeout) { - if ((time() - $cpentry[0]) >= $timeout) { + if (($pruning_time - $cpentry[0]) >= $timeout) { $timedout = true; $term_cause = 5; // Session-Timeout } @@ -668,7 +674,7 @@ function captiveportal_prune_old() { /* Session-Terminate-Time */ if (!$timedout && !empty($cpentry[9])) { - if (time() >= $cpentry[9]) { + if ($pruning_time >= $cpentry[9]) { $timedout = true; $term_cause = 5; // Session-Timeout } @@ -683,7 +689,7 @@ function captiveportal_prune_old() { * We "fix" this by setting lastact to the login timestamp. */ $lastact = $lastact ? $lastact : $cpentry[0]; - if ($lastact && ((time() - $lastact) >= $uidletimeout)) { + if ($lastact && (($pruning_time - $lastact) >= $uidletimeout)) { $timedout = true; $term_cause = 4; // Idle-Timeout $stop_time = $lastact; // Entry added to comply with WISPr @@ -692,7 +698,7 @@ function captiveportal_prune_old() { /* if vouchers are configured, activate session timeouts */ if (!$timedout && isset($config['voucher']['enable'])) { - if (time() >= ($cpentry[0] + $cpentry[7])) { + if ($pruning_time >= ($cpentry[0] + $cpentry[7])) { $timedout = true; $term_cause = 5; // Session-Timeout $voucher_needs_sync = true; @@ -701,7 +707,7 @@ function captiveportal_prune_old() { /* if radius session_timeout is enabled and the session_timeout is not null, then check if the user should be logged out */ if (!$timedout && isset($config['captiveportal']['radiussession_timeout']) && !empty($cpentry[7])) { - if (time() >= ($cpentry[0] + $cpentry[7])) { + if ($pruning_time >= ($cpentry[0] + $cpentry[7])) { $timedout = true; $term_cause = 5; // Session-Timeout } @@ -1615,6 +1621,9 @@ function portal_allow($clientip,$clientmac,$username,$password = null, $attribut } } + /* Snaphost the timestamp */ + $allow_time = time(); + foreach ($cpdb as $sid => $cpentry) { /* on the same ip */ if($cpentry[2] == $clientip) { @@ -1625,7 +1634,7 @@ function portal_allow($clientip,$clientmac,$username,$password = null, $attribut elseif (($attributes['voucher']) && ($username != 'unauthenticated') && ($cpentry[4] == $username)) { // user logged in with an active voucher. Check for how long and calculate // how much time we can give him (voucher credit - used time) - $remaining_time = $cpentry[0] + $cpentry[7] - time(); + $remaining_time = $cpentry[0] + $cpentry[7] - $allow_time; if ($remaining_time < 0) // just in case. $remaining_time = 0; @@ -1719,7 +1728,7 @@ function portal_allow($clientip,$clientmac,$username,$password = null, $attribut /* encode password in Base64 just in case it contains commas */ $bpassword = base64_encode($password); - $cpdb[] = array(time(), $ruleno, $clientip, $clientmac, $username, $sessionid, $bpassword, + $cpdb[] = array($allow_time, $ruleno, $clientip, $clientmac, $username, $sessionid, $bpassword, $attributes['session_timeout'], $attributes['idle_timeout'], $attributes['session_terminate_time']); /* rewrite information to database */ From 19ed162443aba106bfa51f88fc082af7f09738ab Mon Sep 17 00:00:00 2001 From: Ermal Date: Mon, 13 Jun 2011 15:04:59 +0000 Subject: [PATCH 04/19] unset after checking that no reconfiguring is needed. --- usr/local/www/xmlrpc.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/usr/local/www/xmlrpc.php b/usr/local/www/xmlrpc.php index 1689b852dc..95f4d639bd 100755 --- a/usr/local/www/xmlrpc.php +++ b/usr/local/www/xmlrpc.php @@ -198,11 +198,13 @@ function restore_config_section_xmlrpc($raw_params) { $anyproxyarp = false; foreach ($config['virtualip']['vip'] as $vip) { if (isset($oldvips[$vip['vhid']])) { - unset($oldvips[$vip['vhid']]); if ($oldvips[$vip['vhid']] == "{$vip['password']}{$vip['advskew']}{$vip['subnet']}{$vip['subnet_bits']}{$vip['advbase']}") { - if (does_interface_exist("vip{$vip['vhid']}")) + if (does_interface_exist("vip{$vip['vhid']}")) { + unset($oldvips[$vip['vhid']]); continue; // Skip reconfiguring this vips since nothing has changed. + } } + unset($oldvips[$vip['vhid']]); } switch ($vip['mode']) { From 63f81fbd88f69fe04bf385d81e97f64589debda8 Mon Sep 17 00:00:00 2001 From: Ermal Date: Mon, 13 Jun 2011 18:16:03 +0000 Subject: [PATCH 05/19] Do not assume that every merge is about vips. Found-by: Jim --- usr/local/www/xmlrpc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/local/www/xmlrpc.php b/usr/local/www/xmlrpc.php index 95f4d639bd..f3211dfd99 100755 --- a/usr/local/www/xmlrpc.php +++ b/usr/local/www/xmlrpc.php @@ -193,7 +193,7 @@ function restore_config_section_xmlrpc($raw_params) { * The real work on handling the vips specially * This is a copy of intefaces_vips_configure with addition of not reloading existing/not changed carps */ - if (is_array($config['virtualip']) && is_array($config['virtualip']['vip'])) { + if (isset($params[0]['virtualip']) && is_array($config['virtualip']) && is_array($config['virtualip']['vip'])) { $carp_setuped = false; $anyproxyarp = false; foreach ($config['virtualip']['vip'] as $vip) { From 7905df983103f1288fb22f6db192f3de64a0daa2 Mon Sep 17 00:00:00 2001 From: Ermal Date: Tue, 14 Jun 2011 09:57:17 +0000 Subject: [PATCH 06/19] Porvide information for the filter reload status screen. --- etc/rc.filter_synchronize | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/etc/rc.filter_synchronize b/etc/rc.filter_synchronize index af0e5cc88f..460824b19c 100755 --- a/etc/rc.filter_synchronize +++ b/etc/rc.filter_synchronize @@ -258,8 +258,10 @@ function carp_sync_xml($url, $password, $sections, $port = 80, $method = 'pfsens log_error($error); file_notice("sync_settings", $error, "Settings Sync", ""); exit; - } else + } else { log_error("XMLRPC sync successfully completed with {$url}:{$port}."); + update_filter_reload_status("XMLRPC sync successfully completed with {$url}:{$port}."); + } $numberofruns = 3; } $numberofruns++; From 2708a5cf1648c6d776588e0e4b9be1b6aad65994 Mon Sep 17 00:00:00 2001 From: Ermal Date: Tue, 14 Jun 2011 11:36:20 +0000 Subject: [PATCH 07/19] NEw functiong does_vip_exist() which works for carp and ipalias type vips to help in carp sync issues. Fixes #1598 --- etc/inc/interfaces.inc | 35 +++++++++++++++++++++++++++++++++++ usr/local/www/xmlrpc.php | 18 ++++++++++++++---- 2 files changed, 49 insertions(+), 4 deletions(-) diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index 22a88a8c3d..ee171af81a 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -84,6 +84,41 @@ function does_interface_exist($interface) { return false; } +/* + * does_vip_exist($vip): return true or false if a vip is + * configured. + */ +function does_vip_exist($vip) { + global $config; + + if(!$vip) + return false; + + $realif = get_real_interface($vip['interface']); + $ints = get_interface_arr(true); + if (in_array($realif, $ints)) + return true; + else + return false; + + switch ($vip['type']) { + case "carp": + case "carpdev": + case "ipalias": + $ifacedata = pfSense_getall_interface_addresses($realif); + foreach ($ifacedata as $vipips) { + if ($vipips == "{$vip['subnet']}/{$vip['subnet_bits']}") + return true; + } + break; + case "proxyarp": + /* XXX: Implement this */ + break; + } + + return false; +} + function interface_netgraph_needed($interface = "wan") { global $config; diff --git a/usr/local/www/xmlrpc.php b/usr/local/www/xmlrpc.php index f3211dfd99..2fbf5e39e5 100755 --- a/usr/local/www/xmlrpc.php +++ b/usr/local/www/xmlrpc.php @@ -166,7 +166,9 @@ function restore_config_section_xmlrpc($raw_params) { foreach ($config['virtualip']['vip'] as $vipindex => $vip) { if ($vip['mode'] == "carp") $oldvips[$vip['vhid']] = "{$vip['password']}{$vip['advskew']}{$vip['subnet']}{$vip['subnet_bits']}{$vip['advbase']}"; - else if ((($vip['mode'] == 'ipalias') || ($vip['mode'] == 'proxyarp')) && substr($vip['interface'], 0, 3) != "vip") + else if ($vip['mode'] == "ipalias" && substr($vip['interface'], 0, 3) == "vip") + $oldvips[$vip['subnet']] = "{$vip['interface']}{$vip['subnet']}{$vip['subnet_bits']}"; + else if (($vip['mode'] == "ipalias" || $vip['mode'] == 'proxyarp') && substr($vip['interface'], 0, 3) != "vip") $vipbackup[] = $vip; } } @@ -197,14 +199,22 @@ function restore_config_section_xmlrpc($raw_params) { $carp_setuped = false; $anyproxyarp = false; foreach ($config['virtualip']['vip'] as $vip) { - if (isset($oldvips[$vip['vhid']])) { + if ($vip['mode'] == "carp" && isset($oldvips[$vip['vhid']])) { if ($oldvips[$vip['vhid']] == "{$vip['password']}{$vip['advskew']}{$vip['subnet']}{$vip['subnet_bits']}{$vip['advbase']}") { - if (does_interface_exist("vip{$vip['vhid']}")) { + if (does_vip_exist($vip)) { unset($oldvips[$vip['vhid']]); continue; // Skip reconfiguring this vips since nothing has changed. } } unset($oldvips[$vip['vhid']]); + } else if ($vip['mode'] == "ipalias" && substr($vip['interface'], 0, 3) == "vip" && isset($oldvips[$vip['subnet']])) { + if ($oldvips[$vip['subnet']] = "{$vip['interface']}{$vip['subnet']}{$vip['subnet_bits']}") { + if (does_vip_exist($vip)) { + unset($oldvips[$vip['subnet']]); + continue; // Skip reconfiguring this vips since nothing has changed. + } + } + unset($oldvips[$vip['subnet']]); } switch ($vip['mode']) { @@ -226,7 +236,7 @@ function restore_config_section_xmlrpc($raw_params) { } /* Cleanup remaining old carps */ foreach ($oldvips as $oldvipif => $oldvippar) { - if (does_interface_exist("vip{$oldvipif}")) + if (!is_ipaddr($oldvipif) && does_interface_exist("vip{$oldvipif}")) pfSense_interface_destroy("vip{$oldvipif}"); } if ($carp_setuped == true) From 31d5d37e9e86c66bf099d3820205250ef73a2d7d Mon Sep 17 00:00:00 2001 From: Ermal Date: Tue, 14 Jun 2011 11:44:54 +0000 Subject: [PATCH 08/19] Ooops fix the function. Spotted-by: wagnosa(IRC) --- etc/inc/interfaces.inc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index ee171af81a..af99b0695f 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -96,9 +96,7 @@ function does_vip_exist($vip) { $realif = get_real_interface($vip['interface']); $ints = get_interface_arr(true); - if (in_array($realif, $ints)) - return true; - else + if (!in_array($realif, $ints)) return false; switch ($vip['type']) { From b526daafae3405b27fa7219d90a81272d0979f57 Mon Sep 17 00:00:00 2001 From: Ermal Date: Tue, 14 Jun 2011 12:50:14 +0000 Subject: [PATCH 09/19] Correct functiong does_vip_exist() to actually work. Fixes #1598 --- etc/inc/interfaces.inc | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index af99b0695f..4a3498b7b6 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -94,24 +94,31 @@ function does_vip_exist($vip) { if(!$vip) return false; - $realif = get_real_interface($vip['interface']); - $ints = get_interface_arr(true); - if (!in_array($realif, $ints)) - return false; - switch ($vip['type']) { + switch ($vip['mode']) { case "carp": case "carpdev": + $realif = "vip{$vip['vhid']}"; + if (!does_interface_exist($realif)) { + return false; + } + break; case "ipalias": - $ifacedata = pfSense_getall_interface_addresses($realif); - foreach ($ifacedata as $vipips) { - if ($vipips == "{$vip['subnet']}/{$vip['subnet_bits']}") - return true; + $realif = get_real_interface($vip['interface']); + if (!does_interface_exist($realif)) { + return false; } break; case "proxyarp": /* XXX: Implement this */ - break; + default: + return false; + } + + $ifacedata = pfSense_getall_interface_addresses($realif); + foreach ($ifacedata as $vipips) { + if ($vipips == "{$vip['subnet']}/{$vip['subnet_bits']}") + return true; } return false; From fb5830ef33f6e1154f3441d7f13ac90bbe547b3c Mon Sep 17 00:00:00 2001 From: Ermal Date: Tue, 14 Jun 2011 13:00:04 +0000 Subject: [PATCH 10/19] Actually correct check so it throws some errors during the second try. --- etc/rc.filter_synchronize | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/rc.filter_synchronize b/etc/rc.filter_synchronize index 460824b19c..c47905406a 100755 --- a/etc/rc.filter_synchronize +++ b/etc/rc.filter_synchronize @@ -104,7 +104,7 @@ function carp_check_version($url, $password, $port = 80, $method = 'pfsense.host /* XXX: Configurable from the GUI?! */ $username = "admin"; $cli->setCredentials($username, $password); - if($numberofruns > 1) + if($numberofruns > 0) $cli->setDebug(1); /* send our XMLRPC message and timeout after 240 seconds */ $resp = $cli->send($msg, "240"); @@ -239,7 +239,7 @@ function carp_sync_xml($url, $password, $sections, $port = 80, $method = 'pfsens /* XXX: Configurable from the GUI?! */ $username = "admin"; $cli->setCredentials($username, $password); - if($numberofruns > 1) + if($numberofruns > 0) $cli->setDebug(1); /* send our XMLRPC message and timeout after 240 seconds */ $resp = $cli->send($msg, "240"); From 1127df5f18fde5dc8a677f05b7858504c6b0e219 Mon Sep 17 00:00:00 2001 From: Ermal Date: Tue, 14 Jun 2011 13:16:00 +0000 Subject: [PATCH 11/19] Correct check for ipaliases over carp so we do not allow the deletion. --- usr/local/www/firewall_virtual_ip.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr/local/www/firewall_virtual_ip.php b/usr/local/www/firewall_virtual_ip.php index 63d0f7e289..ae3a1f717c 100755 --- a/usr/local/www/firewall_virtual_ip.php +++ b/usr/local/www/firewall_virtual_ip.php @@ -118,9 +118,9 @@ if ($_GET['act'] == "del") { $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']; + $vipiface = "vip{$a_vip[$_GET['id']]['vhid']}"; foreach ($a_vip as $vip) { - if ($vipiface == "vip{$vip['vhid']}" && $vip['mode'] == "ipalias") + if ($vipiface == $vip['interface'] && $vip['mode'] == "ipalias") $input_errors[] = gettext("This entry cannot be deleted because it is still referenced by ip alias entry") . " {$vip['descr']}."; } } From 01c170c4612a4afdbaa2d6e9bf98552dddc1cde3 Mon Sep 17 00:00:00 2001 From: Ermal Date: Tue, 14 Jun 2011 13:39:03 +0000 Subject: [PATCH 12/19] Correct displaying any availble default value. --- usr/local/www/pkg_edit.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/local/www/pkg_edit.php b/usr/local/www/pkg_edit.php index 64b1fa9a22..9f883cde45 100755 --- a/usr/local/www/pkg_edit.php +++ b/usr/local/www/pkg_edit.php @@ -464,7 +464,7 @@ if ($pkg['tabs'] <> "") { $value = $_POST[$fieldname]; if (is_array($value)) $value = implode(',', $value); } else { - if (isset($id) && $a_pkg[$id]) + if (isset($id) && $a_pkg[$id] && $a_pkg[$id][$fieldname]) $value = $a_pkg[$id][$fieldname]; else $value = $pkga['default_value']; From fddb3cd6b88c5ae55f299ded41844263e8b5c65c Mon Sep 17 00:00:00 2001 From: Ermal Date: Tue, 14 Jun 2011 13:40:17 +0000 Subject: [PATCH 13/19] Allow people to enter another user than admin for syncrhonizing in the carp settings page. --- usr/local/pkg/carp_settings.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/usr/local/pkg/carp_settings.xml b/usr/local/pkg/carp_settings.xml index f33523643e..32a9b8c312 100644 --- a/usr/local/pkg/carp_settings.xml +++ b/usr/local/pkg/carp_settings.xml @@ -85,6 +85,14 @@ input + + Remote System Username + username + admin + Enter the webConfigurator username of the system entered above for synchronizing your configuration. + <br><br>NOTE: <b>Do not use the Synchronize Config to IP and username option on backup cluster members!</b> + input + Remote System Password password From 88adfa28a848be5949015980aea0a367bc5ef61e Mon Sep 17 00:00:00 2001 From: Warren Baker Date: Tue, 14 Jun 2011 15:43:17 +0200 Subject: [PATCH 14/19] Allow Accounting Updates to become configurable when Accounting is selected. --- usr/local/www/services_captiveportal.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/usr/local/www/services_captiveportal.php b/usr/local/www/services_captiveportal.php index 4526028748..3d1bd51289 100755 --- a/usr/local/www/services_captiveportal.php +++ b/usr/local/www/services_captiveportal.php @@ -300,10 +300,10 @@ function enable_change(enable_change) { document.iform.radmac_secret.disabled = (radius_endis || !document.iform.radmac_enable.checked) && !enable_change; - var reauthenticate_dis = (radius_endis || !document.iform.reauthenticate.checked) && !enable_change; - document.iform.reauthenticateacct[0].disabled = reauthenticate_dis; - document.iform.reauthenticateacct[1].disabled = reauthenticate_dis; - document.iform.reauthenticateacct[2].disabled = reauthenticate_dis; + var radacct_dis = (radius_endis || !document.iform.radacct_enable.checked) && !enable_change; + document.iform.reauthenticateacct[0].disabled = radacct_dis; + document.iform.reauthenticateacct[1].disabled = radacct_dis; + document.iform.reauthenticateacct[2].disabled = radacct_dis; } //--> From e6ee8fc619d25fa3718cc1858042cd9b9869e3e8 Mon Sep 17 00:00:00 2001 From: Ermal Date: Tue, 14 Jun 2011 13:44:48 +0000 Subject: [PATCH 15/19] Upgrade sync username to latest config version. --- etc/inc/upgrade_config.inc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/etc/inc/upgrade_config.inc b/etc/inc/upgrade_config.inc index c380378eaa..29f0ac02d3 100644 --- a/etc/inc/upgrade_config.inc +++ b/etc/inc/upgrade_config.inc @@ -2497,4 +2497,15 @@ function upgrade_078_to_079() { unlink_if_exists("{$g['vardb_path']}/rrd/captiveportal-totalusers.rrd"); } +function upgrade_079_to_080() { + global $config; + + /* Upgrade config in 1.2.3 specifying a username other than admin for synching. */ + if (!empty($config['system']['username']) && is_array($config['installedpackages']['carpsettings']) && + is_array($config['installedpackages']['carpsettings']['config'])) { + $config['installedpackages']['carpsettings']['config'][0]['username'] = $config['system']['username']; + unset($config['system']['username']); + } +} + ?> From 34fb609cec76761102ff04aa300c39d2dbc3d57f Mon Sep 17 00:00:00 2001 From: Ermal Date: Tue, 14 Jun 2011 13:45:16 +0000 Subject: [PATCH 16/19] Up config number for username sync upgrade. --- etc/inc/globals.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/inc/globals.inc b/etc/inc/globals.inc index 6993148cdf..3bd0de295c 100644 --- a/etc/inc/globals.inc +++ b/etc/inc/globals.inc @@ -91,7 +91,7 @@ $g = array( "disablecrashreporter" => false, "crashreporterurl" => "http://crashreporter.pfsense.org/crash_reporter.php", "debug" => false, - "latest_config" => "7.9", + "latest_config" => "8.0", "nopkg_platforms" => array("cdrom"), "minimum_ram_warning" => "101", "minimum_ram_warning_text" => "128 MB", From 6a06d896acd0ec4e3ea344b0cc5c7c9a9f60463c Mon Sep 17 00:00:00 2001 From: Ermal Date: Tue, 14 Jun 2011 13:45:42 +0000 Subject: [PATCH 17/19] Up config number for username sync upgrade. --- conf.default/config.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf.default/config.xml b/conf.default/config.xml index 3a0bb64ee3..b3cbaf40ab 100644 --- a/conf.default/config.xml +++ b/conf.default/config.xml @@ -1,7 +1,7 @@ - 7.9 + 8.0 pfsense_ng From c333d60986353fd523b2a9380645f0a740ba20c0 Mon Sep 17 00:00:00 2001 From: Ermal Date: Tue, 14 Jun 2011 14:10:32 +0000 Subject: [PATCH 18/19] Use the new username field from the GUI or default to admin. --- etc/rc.filter_synchronize | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/etc/rc.filter_synchronize b/etc/rc.filter_synchronize index c47905406a..9468110a89 100755 --- a/etc/rc.filter_synchronize +++ b/etc/rc.filter_synchronize @@ -87,7 +87,7 @@ function remove_special_characters($string) { return $string; } -function carp_check_version($url, $password, $port = 80, $method = 'pfsense.host_firmware_version') { +function carp_check_version($url, $username, $password, $port = 80, $method = 'pfsense.host_firmware_version') { global $config, $g; if(file_exists("{$g['varrun_path']}/booting") || $g['booting']) @@ -101,8 +101,6 @@ function carp_check_version($url, $password, $port = 80, $method = 'pfsense.host while ($numberofruns < 2) { $msg = new XML_RPC_Message($method, $params); $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port); - /* XXX: Configurable from the GUI?! */ - $username = "admin"; $cli->setCredentials($username, $password); if($numberofruns > 0) $cli->setDebug(1); @@ -138,7 +136,7 @@ function carp_check_version($url, $password, $port = 80, $method = 'pfsense.host return false; } -function carp_sync_xml($url, $password, $sections, $port = 80, $method = 'pfsense.restore_config_section') { +function carp_sync_xml($url, $username, $password, $sections, $port = 80, $method = 'pfsense.restore_config_section') { global $config, $g; if(file_exists("{$g['varrun_path']}/booting") || $g['booting']) @@ -151,11 +149,11 @@ function carp_sync_xml($url, $password, $sections, $port = 80, $method = 'pfsens /* strip out nosync items */ if (is_array($config_copy['nat']['advancedoutbound']['rule'])) { - $rulescnt = count($config_copy['nat']['advancedoutbound']['rule']); - for ($x = 0; $x < $rulescnt; $x++) { - $config_copy['nat']['advancedoutbound']['rule'][$x]['descr'] = remove_special_characters($config_copy['nat']['advancedoutbound']['rule'][$x]['descr']); - if (isset ($config_copy['nat']['advancedoutbound']['rule'][$x]['nosync'])) - unset ($config_copy['nat']['advancedoutbound']['rule'][$x]); + $rulescnt = count($config_copy['nat']['advancedoutbound']['rule']); + for ($x = 0; $x < $rulescnt; $x++) { + $config_copy['nat']['advancedoutbound']['rule'][$x]['descr'] = remove_special_characters($config_copy['nat']['advancedoutbound']['rule'][$x]['descr']); + if (isset ($config_copy['nat']['advancedoutbound']['rule'][$x]['nosync'])) + unset ($config_copy['nat']['advancedoutbound']['rule'][$x]); } } if (is_array($config_copy['nat']['rule'])) { @@ -236,8 +234,6 @@ function carp_sync_xml($url, $password, $sections, $port = 80, $method = 'pfsens log_error("Beginning XMLRPC sync to {$url}:{$port}."); $msg = new XML_RPC_Message($method, $params); $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port); - /* XXX: Configurable from the GUI?! */ - $username = "admin"; $cli->setCredentials($username, $password); if($numberofruns > 0) $cli->setDebug(1); @@ -386,21 +382,23 @@ 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)) + if (empty($carp['username'])) + $username = "admin"; + else + $username = $carp['username']; + if (!carp_check_version($synchronizetoip, $username, $carp['password'], $port)) break; update_filter_reload_status("Signaling CARP reload signal..."); - carp_sync_xml($synchronizetoip, $carp['password'], $sections, $port); + carp_sync_xml($synchronizetoip, $username, $carp['password'], $sections, $port); if (is_array($mergesections)) - carp_sync_xml($synchronizetoip, $carp['password'], $mergesections, $port, 'pfsense.restore_config_section'); + carp_sync_xml($synchronizetoip, $username, $carp['password'], $mergesections, $port, 'pfsense.restore_config_section'); $cli = new XML_RPC_Client('/xmlrpc.php', $synchronizetoip, $port); $params = array( XML_RPC_encode($carp['password']) ); $msg = new XML_RPC_Message('pfsense.filter_configure', $params); - /* XXX: Configurable from the GUI */ - $username = "admin"; $cli->setCredentials($username, $carp['password']); $resp = $cli->send($msg, "900"); From 144fbff2a146d9eb3921e763f6bcc7bde39bf5f9 Mon Sep 17 00:00:00 2001 From: jim-p Date: Tue, 14 Jun 2011 16:35:48 -0400 Subject: [PATCH 19/19] Show the OpenVPN instance description when listing interfaces to assign in the gui. --- usr/local/www/interfaces_assign.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/usr/local/www/interfaces_assign.php b/usr/local/www/interfaces_assign.php index 714feb49c3..3e35b0ef26 100755 --- a/usr/local/www/interfaces_assign.php +++ b/usr/local/www/interfaces_assign.php @@ -143,6 +143,16 @@ if (is_array($config['ppps']['ppp']) && count($config['ppps']['ppp'])) { } } +$ovpn_descrs = array(); +if (is_array($config['openvpn'])) { + if (is_array($config['openvpn']['openvpn-server'])) + foreach ($config['openvpn']['openvpn-server'] as $s) + $ovpn_descrs[$s['vpnid']] = $s['description']; + if (is_array($config['openvpn']['openvpn-client'])) + foreach ($config['openvpn']['openvpn-client'] as $c) + $ovpn_descrs[$c['vpnid']] = $c['description']; +} + if ($_POST['apply']) { if (file_exists("/var/run/interface_mismatch_reboot_needed")) system_reboot(); @@ -452,6 +462,8 @@ if(file_exists("/var/run/interface_mismatch_reboot_needed")) echo htmlspecialchars($descr); } elseif ($portinfo['isqinq']) { echo htmlspecialchars($portinfo['descr']); + } elseif (substr($portname, 0, 4) == 'ovpn') { + echo htmlspecialchars($portname . " (" . $ovpn_descrs[substr($portname, 5, 1)] . ")"); } else echo htmlspecialchars($portname . " (" . $portinfo['mac'] . ")"); ?>