Skip to content

Commit decbadf

Browse files
committed
Replace users with nix for UID/GID
1 parent 4d9bd48 commit decbadf

File tree

4 files changed

+26
-18
lines changed

4 files changed

+26
-18
lines changed

Cargo.lock

Lines changed: 21 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ which = "8.0.0"
2424
yansi = "1.0.1"
2525

2626
[target.'cfg(unix)'.dependencies]
27-
users = "0.11.0"
27+
nix = { version ="0.31.1",default-features = false, features = ["user"] }
2828

2929
[dev-dependencies]
3030
assert_cmd = { version = "2.1.1", features = ["color"] }

src/executor/docker.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ impl Executor {
2626

2727
#[cfg(unix)]
2828
{
29-
let uid = users::get_current_uid();
30-
let gid = users::get_current_gid();
29+
let uid = nix::unistd::getuid().as_raw();
30+
let gid = nix::unistd::getgid().as_raw();
3131
options.push_str(&format!(" --user {uid}:{gid}"));
3232
}
3333

tests/docker.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ fn mock_docker_rosetta_score() {
4040
#[cfg(unix)]
4141
command_line_parts.push(format!(
4242
"--user {}:{}",
43-
users::get_current_uid(),
44-
users::get_current_gid()
43+
nix::unistd::getuid().as_raw(),
44+
nix::unistd::getgid().as_raw()
4545
));
4646

4747
command_line_parts.push("--workdir /w".into());

0 commit comments

Comments
 (0)