From 31e6e3896d45c82cf1c80aadc87cebe387340ad4 Mon Sep 17 00:00:00 2001 From: LinkTed Date: Tue, 22 Sep 2020 13:18:06 +0200 Subject: [PATCH] Fix `SO_PASSCRED` for macos --- library/std/src/sys/unix/net.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/std/src/sys/unix/net.rs b/library/std/src/sys/unix/net.rs index 8f28c75641f..f27786dbf79 100644 --- a/library/std/src/sys/unix/net.rs +++ b/library/std/src/sys/unix/net.rs @@ -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 { let passcred: libc::c_int = getsockopt(self, libc::SOL_SOCKET, libc::SO_PASSCRED)?; Ok(passcred != 0)