Skip to content

Commit 011ba6d

Browse files
author
Bryant Mairs
committed
Add ucred-like structs for FreeBSDs and NetBSD
1 parent 6cf652e commit 011ba6d

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

src/dox.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,5 +146,6 @@ mod imp {
146146

147147
pub mod mem {
148148
pub fn size_of_val<T>(_: &T) -> usize { 4 }
149+
pub fn size_of<T>(_: &T) -> usize { 4 }
149150
}
150151
}

src/unix/bsd/freebsdlike/mod.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,15 @@ s! {
159159
pub int_p_sign_posn: ::c_char,
160160
pub int_n_sign_posn: ::c_char,
161161
}
162+
163+
pub struct cmsgcred {
164+
pub cmcred_pid: ::pid_t,
165+
pub cmcred_uid: ::uid_t,
166+
pub cmcred_euid: ::uid_t,
167+
pub cmcred_gid: ::gid_t,
168+
pub cmcred_ngroups: ::c_short,
169+
pub cmcred_groups: [::gid_t; CMGROUP_MAX],
170+
}
162171
}
163172

164173
pub const AIO_LISTIO_MAX: ::c_int = 16;
@@ -934,6 +943,8 @@ pub const OCRNL: ::tcflag_t = 0x10;
934943
pub const ONOCR: ::tcflag_t = 0x20;
935944
pub const ONLRET: ::tcflag_t = 0x40;
936945

946+
pub const CMGROUP_MAX: usize = 16;
947+
937948
f! {
938949
pub fn WIFCONTINUED(status: ::c_int) -> bool {
939950
status == 0x13

src/unix/bsd/netbsdlike/netbsd/mod.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use dox::mem;
2+
13
pub type clock_t = ::c_uint;
24
pub type suseconds_t = ::c_int;
35
pub type dev_t = u64;
@@ -281,6 +283,16 @@ s! {
281283
pub ifm_index: ::c_ushort,
282284
pub ifm_data: if_data,
283285
}
286+
287+
pub struct sockcred {
288+
pub sc_pid: ::pid_t,
289+
pub sc_uid: ::uid_t,
290+
pub sc_euid: ::uid_t,
291+
pub sc_gid: ::gid_t,
292+
pub sc_egid: ::gid_t,
293+
pub sc_ngroups: ::c_int,
294+
pub sc_groups: [::gid_t; 1],
295+
}
284296
}
285297

286298
pub const AT_FDCWD: ::c_int = -100;
@@ -916,6 +928,15 @@ f! {
916928
pub fn WIFCONTINUED(status: ::c_int) -> bool {
917929
status == 0xffff
918930
}
931+
932+
pub fn SOCKCREDSIZE(ngrps: usize) -> usize {
933+
let ngrps = if ngrps > 0 {
934+
ngrps - 1
935+
} else {
936+
0
937+
};
938+
mem::size_of::<sockcred>() + mem::size_of::<::gid_t>() * ngrps
939+
}
919940
}
920941

921942
extern {

0 commit comments

Comments
 (0)