diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-09-01 21:37:08 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-01 21:37:08 +0200 |
| commit | b05f97d5941bed7d564933716a4f4af8db1c901c (patch) | |
| tree | 08fe1ba6bb03eee43c295005cfda706b4c081bfa | |
| parent | da1d7386014bd5dbe045d9f4f80921c3882719bc (diff) | |
| parent | b9c47f624e8baaccde5b8c022a9fd61d07bda106 (diff) | |
Rollup merge of #100852 - Samyak2:samyak/100459, r=Mark-Simulacrum
Use `getuid` to check instead of `USER` env var in rustbuild This makes it consistent with `x.py` as changed in #95671 Fixes #100459
| -rw-r--r-- | src/bootstrap/bootstrap.py | 2 | ||||
| -rw-r--r-- | src/bootstrap/lib.rs | 13 |
2 files changed, 11 insertions, 4 deletions
diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index fe1b00a90fc..cc08ae5f99f 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -793,6 +793,8 @@ class RustBuild(object): def check_vendored_status(self): """Check that vendoring is configured properly""" + # keep this consistent with the equivalent check in rustbuild: + # https://github.com/rust-lang/rust/blob/a8a33cf27166d3eabaffc58ed3799e054af3b0c6/src/bootstrap/lib.rs#L399-L405 if 'SUDO_USER' in os.environ and not self.use_vendored_sources: if os.getuid() == 0: self.use_vendored_sources = True diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index d111d945d6f..a2ca6e5ce7c 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -395,13 +395,18 @@ impl Build { let src = config.src.clone(); let out = config.out.clone(); + #[cfg(unix)] + // keep this consistent with the equivalent check in x.py: + // https://github.com/rust-lang/rust/blob/a8a33cf27166d3eabaffc58ed3799e054af3b0c6/src/bootstrap/bootstrap.py#L796-L797 let is_sudo = match env::var_os("SUDO_USER") { - Some(sudo_user) => match env::var_os("USER") { - Some(user) => user != sudo_user, - None => false, - }, + Some(_sudo_user) => { + let uid = unsafe { libc::getuid() }; + uid == 0 + } None => false, }; + #[cfg(not(unix))] + let is_sudo = false; let ignore_git = config.ignore_git; let rust_info = channel::GitInfo::new(ignore_git, &src); |
