Skip to content

[backport 3.2] box: fix misleading errors on privilege revoke from admin#11705

Merged
sergepetrenko merged 1 commit intorelease/3.2from
backport/release/3.2/11699
Jul 24, 2025
Merged

[backport 3.2] box: fix misleading errors on privilege revoke from admin#11705
sergepetrenko merged 1 commit intorelease/3.2from
backport/release/3.2/11699

Conversation

@TarantoolBot
Copy link
Collaborator

@TarantoolBot TarantoolBot commented Jul 23, 2025

(This PR is a backport of #11699 to release/3.2 to a future 3.2.2 release.)


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:

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 #11526

NO_DOC=bugfix

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 #11526

NO_DOC=bugfix

(cherry picked from commit 8de5bae)
@TarantoolBot TarantoolBot requested a review from a team as a code owner July 23, 2025 11:22
@TarantoolBot TarantoolBot changed the title [Backport release/3.2] box: fix misleading errors on privilege revoke from admin [backport 3.2] box: fix misleading errors on privilege revoke from admin Jul 23, 2025
@coveralls
Copy link

Coverage Status

coverage: 87.421% (+0.01%) from 87.408%
when pulling 47ac323 on backport/release/3.2/11699
into 28b85e4
on release/3.2
.

@sergepetrenko sergepetrenko merged commit a14a5a9 into release/3.2 Jul 24, 2025
24 checks passed
@sergepetrenko sergepetrenko deleted the backport/release/3.2/11699 branch July 24, 2025 08:36
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.

3 participants