[pve-devel] [PATCH v3] access permissions cleanup fix

Alen Grizonic a.grizonic at proxmox.com
Wed Aug 19 10:32:19 CEST 2015


[PATCH v3] changes:

- cleanup of access permissions for removed storage

Signed-off-by: Alen Grizonic <a.grizonic at proxmox.com>
---
 PVE/AccessControl.pm | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/PVE/AccessControl.pm b/PVE/AccessControl.pm
index 0400aee..6d9543a 100644
--- a/PVE/AccessControl.pm
+++ b/PVE/AccessControl.pm
@@ -1112,6 +1112,26 @@ sub remove_vm_access {
     lock_user_config($delVMaccessFn, "access permissions cleanup for VM $vmid failed");
 }
 
+sub remove_storage_access {
+    my ($storeid) = @_;
+    my $delSTGaccessFn = 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($delSTGaccessFn, "access permissions cleanup for storage $storeid failed");
+}
+
 sub add_vm_to_pool {
     my ($vmid, $pool) = @_;
 
-- 
2.1.4





More information about the pve-devel mailing list