mirror of
https://github.com/pfsense/pfsense.git
synced 2025-10-26 11:38:35 +00:00
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
This commit is contained in:
parent
ee7f1647b9
commit
ce107ca58c
@ -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"]];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user