From d3a2db415caaf2a2fbe43d9d4a9e4cab470657bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Teemu=20P=C3=A4tsi?= <44954973+frendsick@users.noreply.github.com> Date: Sun, 4 May 2025 10:38:34 +0300 Subject: [PATCH] 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 --- src/uu/id/src/id.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/uu/id/src/id.rs b/src/uu/id/src/id.rs index 4a91c8483..473bc3fec 100644 --- a/src/uu/id/src/id.rs +++ b/src/uu/id/src/id.rs @@ -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,