You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CLOUDSTACK-8580 Users are now able to view, expunge and recover their vm's themselves. Two configuration options are added to allow this behaviour on a global or per account scale. Configuration options default to false.
@@ -1713,8 +1714,10 @@ public UserVm recoverVirtualMachine(RecoverVMCmd cmd) throws ResourceAllocationE
1713
1714
thrownewInvalidParameterValueException("unable to find a virtual machine with id " + vmId);
1714
1715
}
1715
1716
1716
-
// check permissions
1717
-
_accountMgr.checkAccess(caller, null, true, vm);
1717
+
// When trying to expunge, permission is denied when the caller is not an admin and the AllowUserExpungeRecoverVm is false for the caller.
1718
+
if (!_accountMgr.isAdmin(userId) && !AllowUserExpungeRecoverVm.valueIn(userId)) {
1719
+
thrownewPermissionDeniedException("Recovering a vm can only be done by an Admin. Or when the allow.user.expunge.recover.vm key is set.");
1720
+
}
1718
1721
1719
1722
if (vm.getRemoved() != null) {
1720
1723
if (s_logger.isDebugEnabled()) {
@@ -2404,8 +2407,9 @@ public UserVm destroyVm(DestroyVMCmd cmd) throws ResourceUnavailableException, C
2404
2407
longvmId = cmd.getId();
2405
2408
booleanexpunge = cmd.getExpunge();
2406
2409
2407
-
if (!_accountMgr.isAdmin(ctx.getCallingAccount().getId()) && expunge) {
2408
-
thrownewPermissionDeniedException("Parameter " + ApiConstants.EXPUNGE + " can be passed by Admin only");
2410
+
// When trying to expunge, permission is denied when the caller is not an admin and the AllowUserExpungeRecoverVm is false for the caller.
2411
+
if (expunge && !_accountMgr.isAdmin(ctx.getCallingAccount().getId()) && !AllowUserExpungeRecoverVm.valueIn(cmd.getEntityOwnerId())) {
2412
+
thrownewPermissionDeniedException("Parameter " + ApiConstants.EXPUNGE + " can be passed by Admin only. Or when the allow.user.expunge.recover.vm key is set.");
0 commit comments