Skip to content

Commit 42f9d37

Browse files
oech3kaladron
andauthored
remove 1 unsafe (#284)
Co-authored-by: Jeff Bailey <jbailey@raspberryginger.com>
1 parent 74abcb3 commit 42f9d37

3 files changed

Lines changed: 4 additions & 6 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ phf = "0.13.0"
4343
phf_codegen = "0.13.0"
4444
rand = { version = "0.10.0" }
4545
regex = "1.10.4"
46+
rustix = "1.1.4"
4647
tar = "0.4"
4748
tempfile = "3.10.1"
4849
textwrap = { version = "0.16.1", features = ["terminal_size"] }
@@ -67,10 +68,10 @@ tar = { optional = true, version = "0.0.1", package = "uu_tar", path = "src/uu/t
6768

6869
[dev-dependencies]
6970
chrono = { workspace = true }
70-
libc = { workspace = true }
7171
pretty_assertions = "1"
7272
rand = { workspace = true }
7373
regex = { workspace = true }
74+
rustix = { workspace = true, features = ["process"] }
7475
tar-rs-crate = { version = "0.4", package = "tar" }
7576
tempfile = { workspace = true }
7677
uucore = { workspace = true, features = ["entries", "process", "signals"] }

tests/by-util/test_tar.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,10 +347,7 @@ fn test_roundtrip_empty_files() {
347347
#[test]
348348
#[cfg(unix)]
349349
fn test_create_permission_denied() {
350-
// SAFETY: `libc::geteuid()` is a pure function that returns the effective
351-
// user ID of the calling process. It has no side effects and cannot cause
352-
// undefined behavior.
353-
if unsafe { libc::geteuid() } == 0 {
350+
if rustix::process::geteuid().is_root() {
354351
eprintln!("skipping: running as root");
355352
return;
356353
}

0 commit comments

Comments
 (0)