server: fix operator precedence in the updateResourceLimit own-domain guard - #14141
Open
nagaboinaramgopal wants to merge 1 commit into
Open
server: fix operator precedence in the updateResourceLimit own-domain guard#14141nagaboinaramgopal wants to merge 1 commit into
nagaboinaramgopal wants to merge 1 commit into
Conversation
… guard The domain branch guard parsed as (ownDomain && DOMAIN_ADMIN) || RESOURCE_DOMAIN_ADMIN because && binds tighter than ||, so a resource domain admin was denied updating the limits of every domain, including sub-domains it administers. Group the two admin types so only the caller's own domain is rejected, the same way the account branch of the method already does.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The domain branch guard in updateResourceLimit is
ownDomain && type == DOMAIN_ADMIN || type == RESOURCE_DOMAIN_ADMIN. Since&&binds tighter than||, a resource domain admin is denied updating the limits of every domain, including its own sub-domains ("Unable to update resource limit for domain X, permission denied"). The intent, like the account branch just above it, is only to block an admin on its own domain. This adds the missing parentheses.Resource domain admins exist only in domains that own a private zone, so this affects those setups. The own domain rule is unchanged, and so is the own account rule discussed in #10922. The same code is on 4.20, 4.22 and main, so this targets 4.20.
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
N/A
How Has This Been Tested?
Added two tests to ResourceLimitManagerImplTest: a resource domain admin updating a sub-domain (fails before with PermissionDeniedException, passes after) and the same admin on its own domain (denied before and after). The class passes (57 tests).
Also verified on a live 4.23 KVM environment with the same change: domain /rl-live with sub-domain /rl-live/rl-live-sub, and a Resource Admin account rladmin in /rl-live calling updateResourceLimit (user VMs, max 10).
Before:
After:
How did you try to break this feature and the system with this change?
Domain admins and root admins behave exactly as before, and both admin types are still denied on their own domain. A resource domain admin on another domain still has to pass checkAccess and the parent domain limit check, so it cannot reach domains outside its tree.