Crates.io | unix-cred |
lib.rs | unix-cred |
version | 0.1.1 |
source | src |
created_at | 2020-11-08 20:29:29.126412 |
updated_at | 2021-01-03 16:29:45.698853 |
description | A library that simplifies reading peer credentials from Unix sockets. |
homepage | |
repository | https://github.com/cptpcrd/unix-cred-rs |
max_upload_size | |
id | 310040 |
size | 30,578 |
A Rust library that simplifies reading peer credentials from Unix sockets.
Example:
use std::os::unix::net::UnixStream;
fn main() {
let (sock, _peer) = UnixStream::pair().unwrap();
// This will print the UID/GID of the current process
// (since it's in possession of the other end)
let (uid, gid) = unix_cred::get_peer_ids(&sock).unwrap();
println!("{} {}", uid, gid);
// Retrieving the PID is not supported on all platforms
// (and on some versions of some platforms None will be returned)
// See the documentation for more details
let (pid, uid, gid) = unix_cred::get_peer_pid_ids(&sock).unwrap();
println!("{:?} {} {}", pid, uid, gid);
}
The following platforms have first-class support (tests are run in CI, and everything should work):
The following platforms have second-class support (built, but not tested, in CI):
The following platforms have third-class support (not even built in CI):