diff options
| author | David CARLIER <devnexen@gmail.com> | 2021-12-11 15:24:38 +0000 |
|---|---|---|
| committer | David Carlier <devnexen@gmail.com> | 2023-03-27 16:48:41 +0100 |
| commit | ed5c0f66ac18696c1b6388559b03ffc30b33e355 (patch) | |
| tree | eab55f2c6aabc171d955f86dd17692ae37611fe6 /library/std/src/sys/unix/net.rs | |
| parent | 553ecbe8bae12bc43a34ac0b8a63e17026ce1e8a (diff) | |
| download | rust-ed5c0f66ac18696c1b6388559b03ffc30b33e355.tar.gz rust-ed5c0f66ac18696c1b6388559b03ffc30b33e355.zip | |
socket ancillary data implementation for FreeBSD (from 13 and above).
introducing new build config as well.
Diffstat (limited to 'library/std/src/sys/unix/net.rs')
| -rw-r--r-- | library/std/src/sys/unix/net.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/library/std/src/sys/unix/net.rs b/library/std/src/sys/unix/net.rs index f84240d268f..573bfa6587e 100644 --- a/library/std/src/sys/unix/net.rs +++ b/library/std/src/sys/unix/net.rs @@ -443,6 +443,17 @@ impl Socket { Ok(passcred != 0) } + #[cfg(target_os = "freebsd")] + pub fn set_passcred(&self, passcred: bool) -> io::Result<()> { + setsockopt(self, libc::AF_LOCAL, libc::LOCAL_CREDS_PERSISTENT, passcred as libc::c_int) + } + + #[cfg(target_os = "freebsd")] + pub fn passcred(&self) -> io::Result<bool> { + let passcred: libc::c_int = getsockopt(self, libc::AF_LOCAL, libc::LOCAL_CREDS_PERSISTENT)?; + Ok(passcred != 0) + } + #[cfg(not(any(target_os = "solaris", target_os = "illumos")))] pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> { let mut nonblocking = nonblocking as libc::c_int; |
