]> git.proxmox.com Git - pve-access-control.git/commitdiff
pools: record parent/subpool information
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Mon, 20 Nov 2023 07:22:40 +0000 (08:22 +0100)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 20 Nov 2023 09:22:45 +0000 (10:22 +0100)
and ensure a missing intermediate pool exists at all times.

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

index 4e3b0776ebcccc3d76ca871e20a5aa8d26f20931..461a64e54c203808d1e94d5728bef7c55f2ed141 100644 (file)
@@ -1529,7 +1529,21 @@ sub parse_user_config {
            }
 
            # make sure to add the pool (even if there are no members)
-           $cfg->{pools}->{$pool} = { vms => {}, storage => {} } if !$cfg->{pools}->{$pool};
+           $cfg->{pools}->{$pool} = { vms => {}, storage => {}, pools => {} }
+               if !$cfg->{pools}->{$pool};
+
+           if ($pool =~ m!/!) {
+               my $curr = $pool;
+               while ($curr =~ m!^(.+)/[^/]+$!) {
+                   # ensure nested pool info is correctly recorded
+                   my $parent = $1;
+                   $cfg->{pools}->{$curr}->{parent} = $parent;
+                   $cfg->{pools}->{$parent} = { vms => {}, storage => {}, pools => {} }
+                       if !$cfg->{pools}->{$parent};
+                   $cfg->{pools}->{$parent}->{pools}->{$curr} = 1;
+                   $curr = $parent;
+               }
+           }
 
            $cfg->{pools}->{$pool}->{comment} = PVE::Tools::decode_text($comment) if $comment;
 
index 65a70eb175d21eb3e8b6e25bf96b2c2cd295eb39..80c346b4cc883a0dc2afca149db0cf88a1a84f68 100755 (executable)
@@ -237,21 +237,25 @@ my $default_cfg = {
        'id' => 'testpool',
        vms => {},
        storage => {},
+       pools => {},
     },
     test_pool_members => {
        'id' => 'testpool',
        vms => { 123 => 1, 1234 => 1},
        storage => { 'local' => 1, 'local-zfs' => 1},
+       pools => {},
     },
     test_pool_duplicate_vms => {
        'id' => 'test_duplicate_vms',
        vms => {},
        storage => {},
+       pools => {},
     },
     test_pool_duplicate_storages => {
        'id' => 'test_duplicate_storages',
        vms => {},
        storage => { 'local' => 1, 'local-zfs' => 1},
+       pools => {},
     },
     acl_simple_user => {
        'path' => '/',