Skip to content

[backport 3.4] box: fix misleading errors on privilege revoke from admin#11707

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

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

Conversation

@TarantoolBot
Copy link
Collaborator

@TarantoolBot TarantoolBot commented Jul 23, 2025

(This PR is a backport of #11699 to release/3.4 to a future 3.4.1 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.4] box: fix misleading errors on privilege revoke from admin [backport 3.4] box: fix misleading errors on privilege revoke from admin Jul 23, 2025
@coveralls
Copy link

Coverage Status

coverage: 87.537% (-0.01%) from 87.548%
when pulling e149aea on backport/release/3.4/11699
into 18b534c
on release/3.4
.

@sergepetrenko sergepetrenko merged commit 9a8fe25 into release/3.4 Jul 24, 2025
25 checks passed
@sergepetrenko sergepetrenko deleted the backport/release/3.4/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