summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTorbjørn Birch Moltu <t.b.moltu@lyse.net>2021-03-08 00:10:21 +0100
committerTorbjørn Birch Moltu <t.b.moltu@lyse.net>2021-03-08 19:37:01 +0100
commit3f62e51d24c1590b7773fa4cbcf256e2e1a9c109 (patch)
tree4756e9e15c7123f0c20fda6af4974d4713485fc8 /src
parentfe4be350a84a6b39902efa3cb42b329996fefa88 (diff)
downloadrust-libc-3f62e51d24c1590b7773fa4cbcf256e2e1a9c109.tar.gz
Add cr_pid to FreeBSD xucred - an unreleased addition in FreeBSD 13
definition: https://svnweb.freebsd.org/base/head/sys/sys/ucred.h?view=markup#l85 manpage: https://www.freebsd.org/cgi/man.cgi?query=unix&sektion=0&manpath=FreeBSD+13-current&format=html Continue comparing and hashing __cr_unused1 for backwards compatibility.
Diffstat (limited to 'src')
-rw-r--r--src/unix/bsd/freebsdlike/dragonfly/mod.rs9
-rw-r--r--src/unix/bsd/freebsdlike/freebsd/mod.rs84
-rw-r--r--src/unix/bsd/freebsdlike/mod.rs8
3 files changed, 92 insertions, 9 deletions
diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs
index 0330183d3f..7056cc5484 100644
--- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs
+++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs
@@ -171,6 +171,14 @@ s! {
pub sdl_route: [::c_ushort; 16],
}
+ pub struct xucred {
+ pub cr_version: ::c_uint,
+ pub cr_uid: ::uid_t,
+ pub cr_ngroups: ::c_short,
+ pub cr_groups: [::gid_t; 16],
+ __cr_unused1: *mut ::c_void,
+ }
+
pub struct stack_t {
pub ss_sp: *mut ::c_char,
pub ss_size: ::size_t,
@@ -238,7 +246,6 @@ s_no_extra_traits! {
pub sigev_value: ::sigval,
__unused3: *mut ::c_void //actually a function pointer
}
-
}
cfg_if! {
diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs
index 98b820b4bc..18a38bd533 100644
--- a/src/unix/bsd/freebsdlike/freebsd/mod.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs
@@ -135,6 +135,23 @@ s_no_extra_traits! {
pub __ut_spare: [::c_char; 64],
}
+ #[cfg(libc_union)]
+ pub union __c_anonymous_cr_pid {
+ __cr_unused: *mut ::c_void,
+ pub cr_pid: ::pid_t,
+ }
+
+ pub struct xucred {
+ pub cr_version: ::c_uint,
+ pub cr_uid: ::uid_t,
+ pub cr_ngroups: ::c_short,
+ pub cr_groups: [::gid_t; 16],
+ #[cfg(libc_union)]
+ pub cr_pid__c_anonymous_union: __c_anonymous_cr_pid,
+ #[cfg(not(libc_union))]
+ __cr_unused1: *mut ::c_void,
+ }
+
pub struct sockaddr_dl {
pub sdl_len: ::c_uchar,
pub sdl_family: ::c_uchar,
@@ -217,6 +234,73 @@ cfg_if! {
}
}
+ #[cfg(libc_union)]
+ impl PartialEq for __c_anonymous_cr_pid {
+ fn eq(&self, other: &__c_anonymous_cr_pid) -> bool {
+ unsafe { self.cr_pid == other.cr_pid}
+ }
+ }
+ #[cfg(libc_union)]
+ impl Eq for __c_anonymous_cr_pid {}
+ #[cfg(libc_union)]
+ impl ::fmt::Debug for __c_anonymous_cr_pid {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("cr_pid")
+ .field("cr_pid", unsafe { &self.cr_pid })
+ .finish()
+ }
+ }
+ #[cfg(libc_union)]
+ impl ::hash::Hash for __c_anonymous_cr_pid {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ unsafe { self.cr_pid.hash(state) };
+ }
+ }
+
+ impl PartialEq for xucred {
+ fn eq(&self, other: &xucred) -> bool {
+ #[cfg(libc_union)]
+ let equal_cr_pid = self.cr_pid__c_anonymous_union
+ == other.cr_pid__c_anonymous_union;
+ #[cfg(not(libc_union))]
+ let equal_cr_pid = self.__cr_unused1 == other.__cr_unused1;
+
+ self.cr_version == other.cr_version
+ && self.cr_uid == other.cr_uid
+ && self.cr_ngroups == other.cr_ngroups
+ && self.cr_groups == other.cr_groups
+ && equal_cr_pid
+ }
+ }
+ impl Eq for xucred {}
+ impl ::fmt::Debug for xucred {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ let mut struct_formatter = f.debug_struct("xucred");
+ struct_formatter.field("cr_version", &self.cr_version);
+ struct_formatter.field("cr_uid", &self.cr_uid);
+ struct_formatter.field("cr_ngroups", &self.cr_ngroups);
+ struct_formatter.field("cr_groups", &self.cr_groups);
+ #[cfg(libc_union)]
+ struct_formatter.field(
+ "cr_pid__c_anonymous_union",
+ &self.cr_pid__c_anonymous_union
+ );
+ struct_formatter.finish()
+ }
+ }
+ impl ::hash::Hash for xucred {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.cr_version.hash(state);
+ self.cr_uid.hash(state);
+ self.cr_ngroups.hash(state);
+ self.cr_groups.hash(state);
+ #[cfg(libc_union)]
+ self.cr_pid__c_anonymous_union.hash(state);
+ #[cfg(not(libc_union))]
+ self.__cr_unused1.hash(state);
+ }
+ }
+
impl PartialEq for sockaddr_dl {
fn eq(&self, other: &sockaddr_dl) -> bool {
self.sdl_len == other.sdl_len
diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs
index 5e1e9d2351..32bf7e7e7b 100644
--- a/src/unix/bsd/freebsdlike/mod.rs
+++ b/src/unix/bsd/freebsdlike/mod.rs
@@ -219,14 +219,6 @@ s! {
pub cmcred_groups: [::gid_t; CMGROUP_MAX],
}
- pub struct xucred {
- pub cr_version: ::c_uint,
- pub cr_uid: ::uid_t,
- pub cr_ngroups: ::c_short,
- pub cr_groups: [::gid_t; 16],
- __cr_unused1: *mut ::c_void,
- }
-
pub struct rtprio {
pub type_: ::c_ushort,
pub prio: ::c_ushort,