Skip to content

Commit c698af2

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> (cherry picked from commit 0d36f2e) Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
1 parent 2497a7a commit c698af2

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
@@ -1585,8 +1585,12 @@ public void checkNetworkPermissions(Account owner, Network network) {
15851585

15861586
} else {
15871587
if (!isNetworkAvailableInDomain(network.getId(), owner.getDomainId())) {
1588+
DomainVO ownerDomain = _domainDao.findById(owner.getDomainId());
1589+
if (ownerDomain == null) {
1590+
throw new CloudRuntimeException("cannot check permission on account " + owner.getAccountName() + " whose domain does not exist");
1591+
}
15881592
throw new PermissionDeniedException("Shared network id=" + ((NetworkVO)network).getUuid() + " is not available in domain id=" +
1589-
owner.getDomainId());
1593+
ownerDomain.getUuid());
15901594
}
15911595
}
15921596
}

0 commit comments

Comments
 (0)