remove_storage_access: cleanup of access permissions for removed storage
authorAlen Grizonic <a.grizonic@proxmox.com>
Wed, 19 Aug 2015 08:32:19 +0000 (10:32 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 19 Aug 2015 13:25:15 +0000 (15:25 +0200)
Signed-off-by: Alen Grizonic <a.grizonic@proxmox.com>
PVE/AccessControl.pm

index 0400aee..9b70902 100644 (file)
@@ -1112,6 +1112,28 @@ sub remove_vm_access {
     lock_user_config($delVMaccessFn, "access permissions cleanup for VM $vmid failed");
 }
 
+sub remove_storage_access {
+    my ($storeid) = @_;
+
+    my $deleteStorageAccessFn = sub {
+        my $usercfg = cfs_read_file("user.cfg");
+       my $modified;
+
+        if (my $storage = $usercfg->{acl}->{"/storage/$storeid"}) {
+            delete $usercfg->{acl}->{"/storage/$storeid"};
+            $modified = 1;
+        }
+       foreach my $pool (keys %{$usercfg->{pools}}) {
+           delete $usercfg->{pools}->{$pool}->{storage}->{$storeid};
+           $modified = 1;
+       }
+        cfs_write_file("user.cfg", $usercfg) if $modified;
+    };
+
+    lock_user_config($deleteStorageAccessFn,
+                    "access permissions cleanup for storage $storeid failed");
+}
+
 sub add_vm_to_pool {
     my ($vmid, $pool) = @_;