X-Git-Url: https://git.proxmox.com/?p=pve-access-control.git;a=blobdiff_plain;f=PVE%2FAccessControl.pm;h=0400aee030522fd40e2e88536f448915acd23297;hp=d3f1cf6661b1fcc5221e2630a521d8b7cb8f9639;hb=57a704731b04392b2103b02573fdc4acdfd18a9e;hpb=66931b114112fc91d5bbffd357a7bf872ff03808 diff --git a/PVE/AccessControl.pm b/PVE/AccessControl.pm index d3f1cf6..0400aee 100644 --- a/PVE/AccessControl.pm +++ b/PVE/AccessControl.pm @@ -1093,18 +1093,20 @@ sub remove_vm_access { my ($vmid) = @_; my $delVMaccessFn = sub { my $usercfg = cfs_read_file("user.cfg"); + my $modified; - if (my $acl = $usercfg->{acl}->{'/vms/'.$vmid}) { - delete $usercfg->{acl}->{'/vms/'.$vmid}; - cfs_write_file("user.cfg", $usercfg); + if (my $acl = $usercfg->{acl}->{"/vms/$vmid"}) { + delete $usercfg->{acl}->{"/vms/$vmid"}; + $modified = 1; } if (my $pool = $usercfg->{vms}->{$vmid}) { if (my $data = $usercfg->{pools}->{$pool}) { delete $data->{vms}->{$vmid}; delete $usercfg->{vms}->{$vmid}; - cfs_write_file("user.cfg", $usercfg); + $modified = 1; } } + cfs_write_file("user.cfg", $usercfg) if $modified; }; lock_user_config($delVMaccessFn, "access permissions cleanup for VM $vmid failed");