From df0ca4ce319954e9d03daf294647024993ccc37b Mon Sep 17 00:00:00 2001 From: John Doty Date: Mon, 12 Aug 2024 17:37:34 -0700 Subject: [PATCH] Remove "users" crate, call libc directly This is all I actually needed anyways --- Cargo.lock | 12 +----------- Cargo.toml | 2 +- src/reverse/unix.rs | 3 ++- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a924a4b..18e0d1f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -330,6 +330,7 @@ dependencies = [ "env_logger", "home", "indoc", + "libc", "log", "open", "pretty_assertions", @@ -341,7 +342,6 @@ dependencies = [ "tokio-stream", "toml", "tui", - "users", "xdg", ] @@ -1114,16 +1114,6 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" -[[package]] -name = "users" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24cc0f6d6f267b73e5a2cadf007ba8f9bc39c6a6f9666f8cf25ea809a153b032" -dependencies = [ - "libc", - "log", -] - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" diff --git a/Cargo.toml b/Cargo.toml index 43098c8..107266e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,4 +40,4 @@ tempdir = "0.3" procfs = "0.14.1" [target.'cfg(target_family="unix")'.dependencies] -users = "0.11" +libc = "0.2.155" diff --git a/src/reverse/unix.rs b/src/reverse/unix.rs index d3cc801..b85ed54 100644 --- a/src/reverse/unix.rs +++ b/src/reverse/unix.rs @@ -55,7 +55,8 @@ fn socket_directory() -> Result { Ok(path) => Ok(path), Err(_) => { let mut path = std::env::temp_dir(); - path.push(format!("fwd{}", users::get_current_uid())); + let uid = unsafe { libc::getuid() }; + path.push(format!("fwd{}", uid)); Ok(path) } }