Repository navigation
Conversation
…es (apache#14174) updateTemplateOrIsoPermissions() only treated the caller as owner when the caller's account id matched the template owner. For project owned templates/ISOs the owner is the project account, so project admins were rejected even though they can set the same flags at registration. Treat callers that can modify the project account (project admins) as owners. Fixes: apache#14174
|
@HawkForge , can you see how this relates to my attempt at it? #14510 I think I beat you by a day ;) |
Check the Project Admin role of the owning project only for callers that are neither a CloudStack admin nor the template owner, and fold the result into a single isOwner flag. Add tests that the owner and admin paths do not consult the project role, and update the isextractable parameter description, which still said root admin only. Tests ported from apache#14529 by HawkForge. Co-authored-by: HawkForge <75696486+HawkForge@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@HawkForge thanks for this, and for the clear write-up on #14428. Both PRs fix #14174 the same way, so we should only merge one. I'm going ahead with #14510: it looks up the caller's role in the project that owns the template, with the user-level project role taking precedence over the account-level one, instead of going through I took two things from your PR into #14510: evaluating the project check only for callers who are neither admin nor owner, and your tests that the owner and admin paths don't consult the project role. You're credited as co-author on that commit. I'm closing this one as a duplicate; a review on #14510 would be very welcome. |
Description
This PR fixes project admins being unable to change
ispublic,isextractableorisfeaturedon a template or ISO owned by their project throughupdateTemplatePermissions/updateIsoPermissions. Thanks to @prashanthr2 for the report and analysis.Root cause:
TemplateManagerImpl.updateTemplateOrIsoPermissions()only allows the change ifcaller.getId() == ownerIdor the caller is an admin. For a project owned template the owner is the project account, so no user account ever matches and the call fails with "Unable to grant permission to Account X as it is neither admin nor owner or the Template", while the same flags can be set when registering the template into the project.This is an authorization change, limited to members with the project
Adminrole. The caller is treated as the owner only when the template is owned by a project account andProjectManager.canModifyProjectAccount(caller, ownerId)returns true. That is the helperDomainCheckeralready uses forModifyProjectaccess; for regular users it only returns true for accounts/users with theAdminrole in the project. Plain project members are still refused. The same owner flag is used for the existingisextractableowner check. Behaviour for template owners, root/domain admins and non-project templates is unchanged; the project check is only evaluated for non-admin, non-owner callers of project owned templates.Sent against 4.20 so it can be merged forward; the same code is present on 4.22 and main.
Fixes: #14174
Types of changes
Feature/Enhancement Scale or Bug Severity
Bug Severity
How Has This Been Tested?
Added unit tests to
TemplateManagerImplTestforupdateTemplateOrIsoPermissions():Ran:
mvn -pl server test -Dtest=TemplateManagerImplTest: 42 tests (37 existing + 5 new), 0 failures. With the fix reverted,updateTemplateOrIsoPermissionsTestProjectAdminCanUpdateProjectTemplatefails with theInvalidParameterValueExceptionfrom the issue.mvn -pl server test -Dtest='com.cloud.template.*Test,com.cloud.projects.*Test'with checkstyle enabled:TemplateManagerImplTest42,HypervisorTemplateAdapterTest17,ProjectManagerImplTest6; 65 tests in total, 0 failures, checkstyle passed.The full server test suite and integration/Marvin tests were not run.
How did you try to break this feature and the system with this change?
Checked that project members without the Admin role and unrelated users are still rejected, and that the existing owner and admin paths do not call the project check.
Replaces #14428, which got closed when my fork was accidentally detached.