Skip to content

Commit 9f176dd

Browse files
Merge pull request #11 from LuoZijun/patch-1
Update kmesg_buffer.rs - instead of using environment variable "USER", just get the user (numeric) id using getuid() and compare to zero.
2 parents 3893882 + 4e0ab20 commit 9f176dd

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

src/libproc/kmesg_buffer.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,7 @@ pub fn kmsgbuf() -> Result<String, String> {
149149
}
150150

151151
pub fn am_root() -> bool {
152-
match env::var("USER") {
153-
Ok(val) => val == "root",
154-
Err(_) => false,
155-
}
152+
libc::getuid() == 0
156153
}
157154

158155
// If you want this test to actually test something, then you need to run as root 'sudo cargo test'

0 commit comments

Comments
 (0)