Skip to content

Commit 47fd67b

Browse files
author
Alena Prokharchyk
committed
CLOUDSTACK-4987: when addNic to vm, don't make account check if the call is made by ROOT admin
1 parent 3b8e5bd commit 47fd67b

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

‎server/src/com/cloud/vm/UserVmManagerImpl.java‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -966,8 +966,7 @@ public UserVm addNicToVirtualMachine(AddNicToVMCmd cmd) throws InvalidParameterV
966966
throw new InvalidParameterValueException("unable to find a network with id " + networkId);
967967
}
968968

969-
Account vmOwner = _accountMgr.getAccount(vmInstance.getAccountId());
970-
if (vmOwner.getType() != Account.ACCOUNT_TYPE_ADMIN) {
969+
if (caller.getType() != Account.ACCOUNT_TYPE_ADMIN) {
971970
if (!(network.getGuestType() == Network.GuestType.Shared && network.getAclType() == ACLType.Domain)
972971
&& !(network.getAclType() == ACLType.Account && network.getAccountId() == vmInstance.getAccountId())) {
973972
throw new InvalidParameterValueException("only shared network or isolated network with the same account_id can be added to vmId: " + vmId);
@@ -2638,8 +2637,8 @@ protected UserVm createVirtualMachine(DataCenter zone, ServiceOffering serviceOf
26382637
throw new InvalidParameterValueException("Network id=" + network.getId() + " doesn't belong to zone " + zone.getId());
26392638
}
26402639

2641-
Account vmOwner = _accountMgr.getAccount(accountId);
2642-
if (vmOwner.getType() != Account.ACCOUNT_TYPE_ADMIN) {
2640+
//relax the check if the caller is admin account
2641+
if (caller.getType() != Account.ACCOUNT_TYPE_ADMIN) {
26432642
if (!(network.getGuestType() == Network.GuestType.Shared && network.getAclType() == ACLType.Domain)
26442643
&& !(network.getAclType() == ACLType.Account && network.getAccountId() == accountId)) {
26452644
throw new InvalidParameterValueException("only shared network or isolated network with the same account_id can be added to vm");

0 commit comments

Comments
 (0)