summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorjim-p <jimp@pfsense.org>2011-05-18 16:56:12 -0400
committerjim-p <jimp@pfsense.org>2011-05-18 16:56:34 -0400
commitce107ca58c61c8f166e672a5ad93fa2daee7bec4 (patch)
treea289667e36d667c700eda69c84dbff4bb486106b /etc
parentee7f1647b9b12ed6daa480cccdb456d2b3cc86b3 (diff)
downloadpfsense-ce107ca58c61c8f166e672a5ad93fa2daee7bec4.zip
pfsense-ce107ca58c61c8f166e672a5ad93fa2daee7bec4.tar.gz
When converting 1.2.3 LB pools to 2.0 gateway groups, strip invalid characters from the group names and update any rules referencing the old name. Fixes #1515
Diffstat (limited to 'etc')
-rw-r--r--etc/inc/upgrade_config.inc20
1 files changed, 19 insertions, 1 deletions
diff --git a/etc/inc/upgrade_config.inc b/etc/inc/upgrade_config.inc
index 1d88880..a158ded 100644
--- a/etc/inc/upgrade_config.inc
+++ b/etc/inc/upgrade_config.inc
@@ -1804,13 +1804,26 @@ function upgrade_053_to_054() {
$lbpool_srv_arr = array();
$gateway_group_arr = array();
$gateways = return_gateways_array();
+ $group_name_changes = array();
if (! is_array($config['gateways']['gateway_item']))
$config['gateways']['gateway_item'] = array();
$a_gateways =& $config['gateways']['gateway_item'];
foreach($lbpool_arr as $lbpool) {
if($lbpool['type'] == "gateway") {
- $gateway_group['name'] = $lbpool['name'];
+ // Gateway Groups have to have valid names in pf, old lb pools did not. Clean them up.
+ $group_name = ereg_replace("[^A-Za-z0-9]", "", $lbpool['name'] );
+ // If we made and changes, check for collisions and note the change.
+ if ($group_name != $lbpool['name']) {
+ // Make sure the name isn't already in use.
+ foreach ($gateway_group_arr as $gwg) {
+ // If the name is in use, add some random bits to avoid collision.
+ if ($gwg['name'] == $group_name)
+ $group_name .= uniqid();
+ }
+ $group_name_changes[$lbpool['name']] = $group_name;
+ }
+ $gateway_group['name'] = $group_name;
$gateway_group['descr'] = $lbpool['descr'];
$gateway_group['trigger'] = "down";
$gateway_group['item'] = array();
@@ -1855,6 +1868,11 @@ function upgrade_053_to_054() {
// Only set the gateway group array if we converted any
if (count($gateway_group_arr) != 0) {
$config['gateways']['gateway_group'] = $gateway_group_arr;
+ // Update any rules that had a gateway change, if any.
+ if (count($group_name_changes) > 0)
+ foreach ($config['filter']['rule'] as & $rule)
+ if (!empty($rule["gateway"]) && array_key_exists($rule["gateway"], $group_name_changes))
+ $rule["gateway"] = $group_name_changes[$rule["gateway"]];
}
}
OpenPOWER on IntegriCloud