]> git.proxmox.com Git - pve-access-control.git/commitdiff
rpcenv: skip undef propagation flag in more places
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Fri, 21 Jan 2022 10:52:08 +0000 (11:52 +0100)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Fri, 21 Jan 2022 13:21:04 +0000 (14:21 +0100)
these are just cosmetic fixes/safeguards against future bugs -
compute_api_permissions is used to set the 'cap' object to hide parts of
the GUI that are not usable without the corresponding privs in the
backend anyway, and get_effective_permissions is only used to return the
permission tree without a specific path query.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
src/PVE/RPCEnvironment.pm

index 5e0ef0421a2ac36d2008c785a3a14ef6c314273c..7725a4d5a6df45ab3129f80d97b5d8fcd8756bd3 100644 (file)
@@ -155,6 +155,8 @@ sub compute_api_permission {
        my $toplevel = ($path =~ /^\/(\w+)/) ? $1 : 'dc';
        if ($toplevel eq 'pool') {
            foreach my $priv (keys %$path_perm) {
+               next if !defined($path_perm->{$priv});
+
                if ($priv =~ m/^VM\./) {
                    $res->{vms}->{$priv} = 1;
                } elsif ($priv =~ m/^Datastore\./) {
@@ -167,6 +169,8 @@ sub compute_api_permission {
        } else {
            my $priv_regex = $priv_re_map->{$toplevel} // next;
            foreach my $priv (keys %$path_perm) {
+               next if !defined($path_perm->{$priv});
+
                next if $priv !~ m/^($priv_regex)/;
                $res->{$toplevel}->{$priv} = 1;
            }
@@ -212,6 +216,9 @@ sub get_effective_permissions {
     my $perms = {};
     foreach my $path (keys %$paths) {
        my $path_perms = $self->permissions($user, $path);
+       foreach my $priv (keys %$path_perms) {
+           delete $path_perms->{$priv} if !defined($path_perms->{$priv});
+       }
        # filter paths where user has NO permissions
        $perms->{$path} = $path_perms if %$path_perms;
     }