Skip to content

Commit 97efbc5

Browse files
author
Alena Prokharchyk
committed
CLOUDSTACK-7283: listUsers - for regular user, only return the caller info. If there are more users under the same account, their information should never be returned
1 parent 736ff5f commit 97efbc5

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

server/src/com/cloud/api/query/QueryManagerImpl.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626
import javax.ejb.Local;
2727
import javax.inject.Inject;
2828

29-
import org.apache.log4j.Logger;
30-
import org.springframework.stereotype.Component;
31-
3229
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
3330
import org.apache.cloudstack.affinity.AffinityGroupDomainMapVO;
3431
import org.apache.cloudstack.affinity.AffinityGroupResponse;
@@ -100,6 +97,8 @@
10097
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateState;
10198
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
10299
import org.apache.cloudstack.query.QueryService;
100+
import org.apache.log4j.Logger;
101+
import org.springframework.stereotype.Component;
103102

104103
import com.cloud.api.query.dao.AccountJoinDao;
105104
import com.cloud.api.query.dao.AffinityGroupJoinDao;
@@ -386,6 +385,13 @@ private Pair<List<UserAccountJoinVO>, Integer> searchForUsersInternal(ListUsersC
386385

387386
boolean listAll = cmd.listAll();
388387
Long id = cmd.getId();
388+
if (caller.getType() == Account.ACCOUNT_TYPE_NORMAL) {
389+
long currentId = CallContext.current().getCallingUser().getId();
390+
if (id != null && currentId != id.longValue()) {
391+
throw new PermissionDeniedException("Calling user is not authorized to see the user requested by id");
392+
}
393+
id = currentId;
394+
}
389395
Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean, ListProjectResourcesCriteria>(
390396
cmd.getDomainId(), cmd.isRecursive(), null);
391397
_accountMgr.buildACLSearchParameters(caller, id, cmd.getAccountName(), null, permittedAccounts,

0 commit comments

Comments
 (0)