diff options
author | Stephen Beaver <sbeaver@netgate.com> | 2016-03-19 13:30:29 -0400 |
---|---|---|
committer | Stephen Beaver <sbeaver@netgate.com> | 2016-03-19 13:30:29 -0400 |
commit | 1a2d6d347736a198569ea89b7e061bc0b725efdd (patch) | |
tree | 2123b7ca82655232e0b05aa2168f59dee4a528b0 /src/etc/inc/upgrade_config.inc | |
parent | b76cc9789b2216a94d6fb8a110946f95b6a5a1e0 (diff) | |
download | pfsense-1a2d6d347736a198569ea89b7e061bc0b725efdd.zip pfsense-1a2d6d347736a198569ea89b7e061bc0b725efdd.tar.gz |
Ensure replacement group name is unique
Diffstat (limited to 'src/etc/inc/upgrade_config.inc')
-rw-r--r-- | src/etc/inc/upgrade_config.inc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/etc/inc/upgrade_config.inc b/src/etc/inc/upgrade_config.inc index 7767c43..bca2561 100644 --- a/src/etc/inc/upgrade_config.inc +++ b/src/etc/inc/upgrade_config.inc @@ -4718,8 +4718,21 @@ function upgrade_147_to_148() { // Ensure there are no spaces in group names by // replacing spaces with underscores if (is_array($config['system']['group'])) { + $exgrps = array(); + + // Make a list of the existing group names so we can check for dups + foreach ($config['system']['group'] as $grp) { + $exgrps[] = $grp['name']; + } + foreach ($config['system']['group'] as $grp) { $grp['name'] = str_replace(" ", "_", $grp['name']); + + // In the unlikely event that there is already a group with this name + // just replace the whole thing with a unique string + if (in_array($grp['name'], $exgrps)) { + $grp['name'] = uniqid(); + } } } } |