-
Notifications
You must be signed in to change notification settings - Fork 207
Open
Description
Uid
in rustix has a strange history of not liking the value -1
. While it is nowadays sound (no unsafe
) to create one, it is still incorrect.
At the same time the set_thread_res_uid
takes three Uid
s that have a clear use of being -1
in this syscall interface.
It is possible to implement set_thread_euid
like
set_thread_res_uid(
Uid::from_raw_unchecked(-1_i32 as u32),
euid,
Uid::from_raw_unchecked(-1_i32 as u32),
)?;
this is
- ugly, complicated and long
- documented as being incorrect
So my suggestion is to change set_thread_res_uid
to take three Option<Uid>
in a semver compatible way.
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
sunfishcode commentedon Apr 30, 2025
Good catch; I agree we should change
set_thread_res_uid
to take threeOption<Uid>
s, in a semver-compatible way, by deprecating the current function and adding a new function with a different name.rusty-snake commentedon May 1, 2025
I would just go with
This way you can keep passing a Uid directly without writing
Some
or passingNone
.rusty-snake commentedon May 1, 2025
The think is how do we want to implement?
set_thread_res_uid
doesUid::from_raw_unchecked(-1_i32 as u32)
andbackend::setresuid_thread
is unchanged.set_thread_res_uid
converts toRawUid
andbackend::setresuid_thread
takes RawUid.set_thread_res_uid
converts toOption<Uid>
andbackend::setresuid_thread
takesOption<Uid>
and doesUid::from_raw_unchecked(-1_i32 as u32)
or converts toRawUid
.rusty-snake commentedon May 1, 2025
ArgReg
from_raw_unchecked(-1_i32 as u32)
So I would go with 3. and
impl<'a, Num: ArgNumber> From<Option<Uid>> for ArgReg<'a, Num>