1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-27 19:17:43 +00:00

id: The --real flag should only affect -u, -g, and -G (#7796)

* id: The `--real` flag should only affect `-u`, `-g`, and `-U`

* id: Test output with different UID and EUID

* id: Simplify testing different UID and EUID

* id: Compile preload file for test using cc instead of gcc

* id: Remove test for different UID and EUID

The test is incompatible with some CI/CD targets.

This reverts the following commits:
- 8efcbf9adae59b7074d29b2ac8ff8a4083df7d95
- 208fa8e7f88f29214ef99984bf47c6a9ebc2ed0d
- a498a2722d7ab56ce96e7cab4766343930ea85ac
This commit is contained in:
Teemu Pätsi 2025-05-04 10:38:34 +03:00 committed by GitHub
parent 5909315d1c
commit d3a2db415c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -238,10 +238,14 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
return Ok(());
}
let (uid, gid) = possible_pw.as_ref().map(|p| (p.uid, p.gid)).unwrap_or((
if state.rflag { getuid() } else { geteuid() },
if state.rflag { getgid() } else { getegid() },
));
let (uid, gid) = possible_pw.as_ref().map(|p| (p.uid, p.gid)).unwrap_or({
let use_effective = !state.rflag && (state.uflag || state.gflag || state.gsflag);
if use_effective {
(geteuid(), getegid())
} else {
(getuid(), getgid())
}
});
state.ids = Some(Ids {
uid,
gid,