Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -991,14 +991,14 @@ private Object getObjectPossibleMethodValue(Object obj, String methodName) {

private Pair<List<UserVmJoinVO>, Integer> searchForUserVMsInternal(ListVMsCmd cmd) {
Account caller = CallContext.current().getCallingAccount();
List<Long> permittedAccounts = new ArrayList<Long>();
List<Long> permittedAccounts = new ArrayList<>();

boolean listAll = cmd.listAll();
Long id = cmd.getId();
Long userId = cmd.getUserId();
Map<String, String> tags = cmd.getTags();
Boolean display = cmd.getDisplay();
Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean, ListProjectResourcesCriteria>(cmd.getDomainId(), cmd.isRecursive(), null);
Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<>(cmd.getDomainId(), cmd.isRecursive(), null);
_accountMgr.buildACLSearchParameters(caller, id, cmd.getAccountName(), cmd.getProjectId(), permittedAccounts, domainIdRecursiveListProject, listAll, false);
Long domainId = domainIdRecursiveListProject.first();
Boolean isRecursive = domainIdRecursiveListProject.second();
Expand All @@ -1011,7 +1011,7 @@ private Pair<List<UserVmJoinVO>, Integer> searchForUserVMsInternal(ListVMsCmd cm
if (cmd.getIds() != null && !cmd.getIds().isEmpty()) {
throw new InvalidParameterValueException("Specify either id or ids but not both parameters");
}
ids = new ArrayList<Long>();
ids = new ArrayList<>();
ids.add(cmd.getId());
} else {
ids = cmd.getIds();
Expand Down
13 changes: 6 additions & 7 deletions server/src/main/java/com/cloud/user/AccountManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -2955,18 +2955,17 @@ public void buildACLSearchParameters(Account caller, Long id, String accountName
if (projectId != null) {
if (!forProjectInvitation) {
if (projectId == -1L) {
if (caller.getType() == Account.Type.ADMIN) {
domainIdRecursiveListProject.third(Project.ListProjectResourcesCriteria.ListProjectResourcesOnly);
if (listAll) {
domainIdRecursiveListProject.third(ListProjectResourcesCriteria.ListAllIncludingProjectResources);
}
} else {
domainIdRecursiveListProject.third(Project.ListProjectResourcesCriteria.ListProjectResourcesOnly);
if (caller.getType() != Account.Type.ADMIN) {
permittedAccounts.addAll(_projectMgr.listPermittedProjectAccounts(caller.getId()));
// permittedAccounts can be empty when the caller is not a part of any project (a domain account)
if (permittedAccounts.isEmpty()) {
if (permittedAccounts.isEmpty() || listAll) {
permittedAccounts.add(caller.getId());
}
}
if (listAll) {
domainIdRecursiveListProject.third(ListProjectResourcesCriteria.ListAllIncludingProjectResources);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, should we worry if there could be negative consequences? (I'm asking to understand why this case was previously suported for admin only).

}
} else {
Project project = _projectMgr.getProject(projectId);
if (project == null) {
Expand Down