Skip to content

Commit 0d36f2e

Browse files
minchen07yadvr
authored andcommitted
Error message exposes domain Id when deployVirtualMachine() is attempted on a shared network to which the user doesnot have access to.
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
1 parent bfcdbec commit 0d36f2e

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

‎server/src/com/cloud/acl/AffinityGroupAccessChecker.java‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@
2828
import org.apache.cloudstack.affinity.AffinityGroupService;
2929
import org.apache.cloudstack.affinity.dao.AffinityGroupDomainMapDao;
3030

31+
import com.cloud.domain.DomainVO;
3132
import com.cloud.exception.PermissionDeniedException;
3233
import com.cloud.user.Account;
3334
import com.cloud.user.AccountManager;
35+
import com.cloud.utils.exception.CloudRuntimeException;
3436

3537
@Component
3638
@Local(value = SecurityChecker.class)
@@ -58,7 +60,12 @@ public boolean checkAccess(Account caller, ControlledEntity entity, AccessType a
5860

5961
if (group.getAclType() == ACLType.Domain) {
6062
if (!_affinityGroupService.isAffinityGroupAvailableInDomain(group.getId(), caller.getDomainId())) {
61-
throw new PermissionDeniedException("Affinity group is not available in domain id=" + caller.getDomainId());
63+
DomainVO callerDomain = _domainDao.findById(caller.getDomainId());
64+
if (callerDomain == null) {
65+
throw new CloudRuntimeException("cannot check permission on account " + caller.getAccountName() + " whose domain does not exist");
66+
}
67+
68+
throw new PermissionDeniedException("Affinity group is not available in domain id=" + callerDomain.getUuid());
6269
} else {
6370
return true;
6471
}

‎server/src/com/cloud/network/NetworkModelImpl.java‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1592,8 +1592,12 @@ public void checkNetworkPermissions(Account owner, Network network) {
15921592

15931593
} else {
15941594
if (!isNetworkAvailableInDomain(network.getId(), owner.getDomainId())) {
1595+
DomainVO ownerDomain = _domainDao.findById(owner.getDomainId());
1596+
if (ownerDomain == null) {
1597+
throw new CloudRuntimeException("cannot check permission on account " + owner.getAccountName() + " whose domain does not exist");
1598+
}
15951599
throw new PermissionDeniedException("Shared network id=" + ((NetworkVO)network).getUuid() + " is not available in domain id=" +
1596-
owner.getDomainId());
1600+
ownerDomain.getUuid());
15971601
}
15981602
}
15991603
}

0 commit comments

Comments
 (0)