From 639c7c6285a3c86bd1d16599ed81d0477ff85d21 Mon Sep 17 00:00:00 2001 From: Chiffa <49232762+Chiffario@users.noreply.github.com> Date: Sat, 9 Nov 2024 16:06:58 +0300 Subject: [PATCH] test(username): Default to `false` for `is_root_user()` regardless of the OS (#6358) Default to false for tests regardless of the OS Checking for username along with cfg!(test) seems redundant, especially because of one edge case - root user can be renamed --- src/modules/username.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/username.rs b/src/modules/username.rs index 8ba3509e..ff38cf69 100644 --- a/src/modules/username.rs +++ b/src/modules/username.rs @@ -109,12 +109,12 @@ fn is_root_user() -> bool { ) } -#[cfg(all(target_os = "windows", test))] +#[cfg(test)] fn is_root_user() -> bool { false } -#[cfg(not(target_os = "windows"))] +#[cfg(all(not(target_os = "windows"), not(test)))] fn is_root_user() -> bool { nix::unistd::geteuid() == nix::unistd::ROOT }