Skip to content

Commit

Permalink
add pid to tokio::net::unix::UCred
Browse files Browse the repository at this point in the history
  • Loading branch information
Kloenk committed Jun 25, 2020
1 parent cf2c053 commit b0900f1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tokio/src/net/unix/ucred.rs
@@ -1,8 +1,10 @@
use libc::{gid_t, uid_t};
use libc::{pid_t, gid_t, uid_t};

/// Credentials of a process
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub struct UCred {
/// PID (process ID) of the process
pub pid: Option<pid_t>, // TODO: how to get it under macos?
/// UID (user ID) of the process
pub uid: uid_t,
/// GID (group ID) of the process
Expand Down Expand Up @@ -63,6 +65,7 @@ pub(crate) mod impl_linux {
);
if ret == 0 && ucred_size as usize == mem::size_of::<ucred>() {
Ok(super::UCred {
pid: Some(ucred.pid),
uid: ucred.uid,
gid: ucred.gid,
})
Expand Down Expand Up @@ -100,6 +103,7 @@ pub(crate) mod impl_macos {

if ret == 0 {
Ok(super::UCred {
pid: None,
uid: uid.assume_init(),
gid: gid.assume_init(),
})
Expand Down Expand Up @@ -142,7 +146,7 @@ pub(crate) mod impl_solaris {

ucred_free(cred);

Ok(super::UCred { uid, gid })
Ok(super::UCred { pid: None, uid, gid })
} else {
Err(io::Error::last_os_error())
}
Expand Down

0 comments on commit b0900f1

Please sign in to comment.