Skip to content

Commit

Permalink
Fix SO_PASSCRED for macos
Browse files Browse the repository at this point in the history
  • Loading branch information
LinkTed committed Oct 10, 2020
1 parent b01ce2c commit 31e6e38
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions library/std/src/sys/unix/net.rs
Expand Up @@ -341,10 +341,12 @@ impl Socket {
Ok(raw != 0)
}

#[cfg(any(target_os = "android", target_os = "emscripten", target_os = "linux",))]
pub fn set_passcred(&self, passcred: bool) -> io::Result<()> {
setsockopt(self, libc::SOL_SOCKET, libc::SO_PASSCRED, passcred as libc::c_int)
}

#[cfg(any(target_os = "android", target_os = "emscripten", target_os = "linux",))]
pub fn passcred(&self) -> io::Result<bool> {
let passcred: libc::c_int = getsockopt(self, libc::SOL_SOCKET, libc::SO_PASSCRED)?;
Ok(passcred != 0)
Expand Down

0 comments on commit 31e6e38

Please sign in to comment.