[pve-devel] [PATCH] added permission cleanup subroutine for removed vm

Alen Grizonic a.grizonic at proxmox.com
Wed Aug 12 16:04:58 CEST 2015


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

diff --git a/PVE/AccessControl.pm b/PVE/AccessControl.pm
index bfee816..807380b 100644
--- a/PVE/AccessControl.pm
+++ b/PVE/AccessControl.pm
@@ -1096,6 +1096,20 @@ sub check_permissions {
     return 1;
 }
 
+sub remove_vm_permissions {
+    my ($vmid) = @_;
+    my $delVMfromConfigFn = sub {
+        my $usercfg = cfs_read_file("user.cfg");
+        print Dumper($usercfg->{acl}->{'/vms/'.$vmid});
+        if (my $acl = $usercfg->{acl}->{'/vms/'.$vmid}) {
+            delete $usercfg->{acl}->{'/vms/'.$vmid};
+            cfs_write_file("user.cfg", $usercfg);
+        }
+    };
+
+    lock_user_config($delVMfromConfigFn, "permission cleanup for VM $vmid failed");
+}
+
 sub add_vm_to_pool {
     my ($vmid, $pool) = @_;
 
-- 
2.1.4





More information about the pve-devel mailing list