Skip to content

Commit 59d3dab

Browse files
authored
Merge pull request #1740 from myfreeweb/freebsd-creds
freebsdlike: add SCM_CREDS, struct sockcred
2 parents e0fc936 + d8764e8 commit 59d3dab

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/unix/bsd/freebsdlike/freebsd/mod.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,15 @@ s! {
107107
pub msg_hdr: ::msghdr,
108108
pub msg_len: ::ssize_t,
109109
}
110+
111+
pub struct sockcred {
112+
pub sc_uid: ::uid_t,
113+
pub sc_euid: ::uid_t,
114+
pub sc_gid: ::gid_t,
115+
pub sc_egid: ::gid_t,
116+
pub sc_ngroups: ::c_int,
117+
pub sc_groups: [::gid_t; 1],
118+
}
110119
}
111120

112121
s_no_extra_traits! {
@@ -1136,6 +1145,15 @@ f! {
11361145
as ::c_uint
11371146
}
11381147

1148+
pub fn SOCKCREDSIZE(ngrps: usize) -> usize {
1149+
let ngrps = if ngrps > 0 {
1150+
ngrps - 1
1151+
} else {
1152+
0
1153+
};
1154+
::mem::size_of::<sockcred>() + ::mem::size_of::<::gid_t>() * ngrps
1155+
}
1156+
11391157
pub fn uname(buf: *mut ::utsname) -> ::c_int {
11401158
__xuname(256, buf as *mut ::c_void)
11411159
}

src/unix/bsd/freebsdlike/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,7 @@ pub const MSG_DONTWAIT: ::c_int = 0x00000080;
738738
pub const MSG_EOF: ::c_int = 0x00000100;
739739

740740
pub const SCM_TIMESTAMP: ::c_int = 0x02;
741+
pub const SCM_CREDS: ::c_int = 0x03;
741742

742743
pub const SOCK_STREAM: ::c_int = 1;
743744
pub const SOCK_DGRAM: ::c_int = 2;

0 commit comments

Comments
 (0)