Skip to content

Commit d1a1e1c

Browse files
committed
add SAFETY block on usage of unsafe getuid
Signed-off-by: onur-ozkan <[email protected]>
1 parent 1e3c8f1 commit d1a1e1c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/bootstrap/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,10 @@ impl Build {
368368
// https://github.com/rust-lang/rust/blob/a8a33cf27166d3eabaffc58ed3799e054af3b0c6/src/bootstrap/bootstrap.py#L796-L797
369369
let is_sudo = match env::var_os("SUDO_USER") {
370370
Some(_sudo_user) => {
371+
// SAFETY: getuid() system calls are always successful, and no return value is reserved
372+
// to indicate an error.
373+
//
374+
// For more context, see https://man7.org/linux/man-pages/man2/geteuid.2.html
371375
let uid = unsafe { libc::getuid() };
372376
uid == 0
373377
}

0 commit comments

Comments
 (0)