From 949580110f403ebf51b5c8af40c528bb0adeb276 Mon Sep 17 00:00:00 2001 From: oech3 <79379754+oech3@users.noreply.github.com> Date: Sun, 17 May 2026 11:24:29 +0900 Subject: [PATCH] remove 1 unsafe --- Cargo.lock | 2 +- Cargo.toml | 3 ++- tests/by-util/test_tar.rs | 5 +---- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5924501..851cb0a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1303,13 +1303,13 @@ dependencies = [ "clap_complete", "clap_mangen", "ctor 1.0.5", - "libc", "phf", "phf_codegen", "pretty_assertions", "rand", "regex", "rlimit", + "rustix", "tar", "tempfile", "textwrap", diff --git a/Cargo.toml b/Cargo.toml index 735edca..a36b0e2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -43,6 +43,7 @@ phf = "0.13.0" phf_codegen = "0.13.0" rand = { version = "0.10.0" } regex = "1.10.4" +rustix = "1.1.4" tar = "0.4" tempfile = "3.10.1" 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 [dev-dependencies] chrono = { workspace = true } -libc = { workspace = true } pretty_assertions = "1" rand = { workspace = true } regex = { workspace = true } +rustix = { workspace = true, features = ["process"] } tar-rs-crate = { version = "0.4", package = "tar" } tempfile = { workspace = true } uucore = { workspace = true, features = ["entries", "process", "signals"] } diff --git a/tests/by-util/test_tar.rs b/tests/by-util/test_tar.rs index 6b8e506..51395a3 100644 --- a/tests/by-util/test_tar.rs +++ b/tests/by-util/test_tar.rs @@ -347,10 +347,7 @@ fn test_roundtrip_empty_files() { #[test] #[cfg(unix)] fn test_create_permission_denied() { - // SAFETY: `libc::geteuid()` is a pure function that returns the effective - // user ID of the calling process. It has no side effects and cannot cause - // undefined behavior. - if unsafe { libc::geteuid() } == 0 { + if rustix::process::geteuid().is_root() { eprintln!("skipping: running as root"); return; }