Skip to content

Allow project admin to update template/ISO permissions in projects - #14510

Open
DaanHoogland wants to merge 1 commit into
apache:4.20from
shapeblue:ghi14174-projectAdminUpdateTemplatePerms
Open

DaanHoogland wants to merge 1 commit into
apache:4.20from
shapeblue:ghi14174-projectAdminUpdateTemplatePerms

Conversation

@DaanHoogland

Copy link
Copy Markdown
Contributor

Project-owned templates can only have their permissions (ispublic, isextractable, launch permissions) changed by a CloudStack admin or by an account whose id equals the template's owner account id. For a project-owned template the owner is the project's pseudo-account, which no human account id can ever equal, so every project member - including the Project Admin who originally registered the template - was rejected by updateTemplateOrIsoPermissions().

Fix: compute whether the caller is the Project Admin of the owning project via the existing ProjectManager.canModifyProjectAccount() check (the same check DomainChecker already uses for AccessType.ModifyProject) and let that satisfy both ownership checks in
TemplateManagerImpl.updateTemplateOrIsoPermissions(), alongside the existing owner/admin checks.

Added TemplateManagerImplTest#testUpdateTemplatePermissionsAllowsProjectAdminToActAsOwner, which fails with the old code (InvalidParameterValueException) and passes with the fix.

Fixes #14174

Description

This PR...

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

How did you try to break this feature and the system with this change?

…oject-owned templates

Project-owned templates can only have their permissions (ispublic,
isextractable, launch permissions) changed by a CloudStack admin or by
an account whose id equals the template's owner account id. For a
project-owned template the owner is the project's pseudo-account, which
no human account id can ever equal, so every project member -
including the Project Admin who originally registered the template -
was rejected by updateTemplateOrIsoPermissions().

Fix: compute whether the caller is the Project Admin of the owning
project via the existing ProjectManager.canModifyProjectAccount() check
(the same check DomainChecker already uses for AccessType.ModifyProject)
and let that satisfy both ownership checks in
TemplateManagerImpl.updateTemplateOrIsoPermissions(), alongside the
existing owner/admin checks.

Added TemplateManagerImplTest#testUpdateTemplatePermissionsAllowsProjectAdminToActAsOwner,
which fails with the old code (InvalidParameterValueException) and
passes with the fix.

Fixes CS-3498 / apache#14174
@codecov

codecov Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 16.43%. Comparing base (376c1b4) to head (b7d3a8c).
⚠️ Report is 2 commits behind head on 4.20.

Files with missing lines Patch % Lines
...n/java/com/cloud/template/TemplateManagerImpl.java 0.00% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               4.20   #14510      +/-   ##
============================================
+ Coverage     16.41%   16.43%   +0.01%     
- Complexity    13657    13677      +20     
============================================
  Files          5669     5669              
  Lines        501628   501632       +4     
  Branches      60942    60940       -2     
============================================
+ Hits          82336    82437     +101     
+ Misses       410064   409937     -127     
- Partials       9228     9258      +30     
Flag Coverage Δ
uitests 4.16% <ø> (ø)
unittests 17.29% <0.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@DaanHoogland DaanHoogland added this to the 4.20.4 milestone Oct 28, 2026
@DaanHoogland

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@DaanHoogland a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 19800

@DaanHoogland

Copy link
Copy Markdown
Contributor Author

@blueorangutan test keepEnv

@blueorangutan

Copy link
Copy Markdown

@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian Build Failed (tid-17313)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants