box: fix misleading errors on privilege revoke from admin#11699
Merged
sergepetrenko merged 1 commit intotarantool:masterfrom Jul 23, 2025
Merged
Conversation
41d4245 to
52abba1
Compare
Totktonada
approved these changes
Jul 22, 2025
Contributor
|
I would also consider a more general solution (separately from the fix of this particular problem): |
xuniq
approved these changes
Jul 23, 2025
changelogs/unreleased/gh-11526-misleading-admin-priv-revoke-error.md
Outdated
Show resolved
Hide resolved
Trying to revoke privileges from an admin user or a super role results
in misleading errors:
```
error: 'Tuple field 5 (privilege) type does not match one required by operation:
expected unsigned, got integer'
```
The reason is that privileges use bit module for privilege grant/revoke,
and this module operates 32-bit **signed** integers (see
https://bitop.luajit.org/semantics.html#range for details). So any bit
operation on a privilege set greater than 2^31 (for example,
box.priv.ALL == 2^32 - 1) results in a negative number:
```lua
tarantool> bit.band(box.priv.ALL, bit.bnot(box.priv.W))
---
- -3
...
```
Fortunately, this can be fixed by casting one of the operands to a
uint64_t type, so let's cast all granted or revoked privileges prior to
calculating the resulting privilege set.
Closes tarantool#11526
NO_DOC=bugfix
52abba1 to
481bd5d
Compare
Collaborator
|
Successfully created backport PR for |
Collaborator
|
Successfully created backport PR for |
Collaborator
|
Successfully created backport PR for |
Collaborator
Backport summary
|
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.
Trying to revoke privileges from an admin user or a super role results in misleading errors:
The reason is that privileges use bit module for privilege grant/revoke, and this module operates 32-bit signed integers (see https://bitop.luajit.org/semantics.html#range for details). So any bit operation on a privilege set greater than 2^31 (for example, box.priv.ALL == 2^32 - 1) results in a negative number:
Fortunately, this can be fixed by casting one of the operands to a uint64_t type, so let's cast all granted or revoked privileges prior to calculating the resulting privilege set.
Closes #11526
NO_DOC=bugfix