1
Fork 0

Fix SO_PASSCRED for macos

This commit is contained in:
LinkTed 2020-09-22 13:18:06 +02:00
parent b01ce2cfd0
commit 31e6e3896d

View file

@ -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)