X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=src%2FPVE%2FAPI2%2FFirewall%2FGroups.pm;h=dfc181c90a2724c8ae19043e366fa4d427036108;hb=43be6155b467d6ba1170c0740cbf5eda88c1ab40;hp=e8f211603b687fc9705cb6acdb4ac77f7848bf9c;hpb=5c9da37bf649c4b23994a5342d3340c488a65999;p=pve-firewall.git diff --git a/src/PVE/API2/Firewall/Groups.pm b/src/PVE/API2/Firewall/Groups.pm index e8f2116..dfc181c 100644 --- a/src/PVE/API2/Firewall/Groups.pm +++ b/src/PVE/API2/Firewall/Groups.pm @@ -16,7 +16,7 @@ my $get_security_group_list = sub { my ($cluster_conf) = @_; my $res = []; - foreach my $group (keys %{$cluster_conf->{groups}}) { + foreach my $group (sort keys %{$cluster_conf->{groups}}) { my $data = { group => $group, }; @@ -101,6 +101,11 @@ __PACKAGE__->register_method({ raise_param_exc({ group => "Security group '$param->{rename}' does not exists" }) if !$cluster_conf->{groups}->{$param->{rename}}; + # prevent overwriting an existing group + raise_param_exc({ group => "Security group '$param->{group}' does already exist" }) + if $cluster_conf->{groups}->{$param->{group}} && + $param->{group} ne $param->{rename}; + my $data = delete $cluster_conf->{groups}->{$param->{rename}}; $cluster_conf->{groups}->{$param->{group}} = $data; if (my $comment = delete $cluster_conf->{group_comments}->{$param->{rename}}) {