diff options
author | Alan Somers <asomers@gmail.com> | 2019-12-01 16:08:54 -0700 |
---|---|---|
committer | Alan Somers <asomers@gmail.com> | 2019-12-01 17:26:23 -0700 |
commit | 6cc90b31e23b0b98bd9fa194fed041f4c413077d (patch) | |
tree | 3dafb4db2e7d6aeb10f5c598e5818276e57d3c50 /src | |
parent | 0f7be3e1e52c104218b0b61ff34f0554924ec99d (diff) | |
download | nix-6cc90b31e23b0b98bd9fa194fed041f4c413077d.zip |
ScmCredentials now wraps UnixCredentials instead of libc::ucred
Diffstat (limited to 'src')
-rw-r--r-- | src/sys/socket/mod.rs | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs index 5ecf088a..aa280747 100644 --- a/src/sys/socket/mod.rs +++ b/src/sys/socket/mod.rs @@ -190,7 +190,7 @@ cfg_if! { /// Unix credentials of the sending process. /// /// This struct is used with the `SO_PEERCRED` ancillary message for UNIX sockets. - #[repr(C)] + #[repr(transparent)] #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub struct UnixCredentials(libc::ucred); @@ -368,7 +368,7 @@ pub enum ControlMessageOwned { /// Received version of /// [`ControlMessage::ScmCredentials`][#enum.ControlMessage.html#variant.ScmCredentials] #[cfg(any(target_os = "android", target_os = "linux"))] - ScmCredentials(libc::ucred), + ScmCredentials(UnixCredentials), /// A message of type `SCM_TIMESTAMP`, containing the time the /// packet was received by the kernel. /// @@ -496,7 +496,7 @@ impl ControlMessageOwned { #[cfg(any(target_os = "android", target_os = "linux"))] (libc::SOL_SOCKET, libc::SCM_CREDENTIALS) => { let cred: libc::ucred = ptr::read_unaligned(p as *const _); - ControlMessageOwned::ScmCredentials(cred) + ControlMessageOwned::ScmCredentials(cred.into()) } (libc::SOL_SOCKET, libc::SCM_TIMESTAMP) => { let tv: libc::timeval = ptr::read_unaligned(p as *const _); @@ -584,10 +584,8 @@ pub enum ControlMessage<'a> { /// /// For further information, please refer to the /// [`unix(7)`](http://man7.org/linux/man-pages/man7/unix.7.html) man page. - // FIXME: When `#[repr(transparent)]` is stable, use it on `UnixCredentials` - // and put that in here instead of a raw ucred. #[cfg(any(target_os = "android", target_os = "linux"))] - ScmCredentials(&'a libc::ucred), + ScmCredentials(&'a UnixCredentials), /// Set IV for `AF_ALG` crypto API. /// @@ -655,7 +653,7 @@ impl<'a> ControlMessage<'a> { }, #[cfg(any(target_os = "android", target_os = "linux"))] ControlMessage::ScmCredentials(creds) => { - creds as *const libc::ucred as *const u8 + &creds.0 as *const libc::ucred as *const u8 } #[cfg(any(target_os = "android", target_os = "linux"))] ControlMessage::AlgSetIv(iv) => { |