Skip to content

Commit

Permalink
Merge pull request #1740 from myfreeweb/freebsd-creds
Browse files Browse the repository at this point in the history
freebsdlike: add SCM_CREDS, struct sockcred
  • Loading branch information
JohnTitor authored Apr 15, 2020
2 parents e0fc936 + d8764e8 commit 59d3dab
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,15 @@ s! {
pub msg_hdr: ::msghdr,
pub msg_len: ::ssize_t,
}

pub struct sockcred {
pub sc_uid: ::uid_t,
pub sc_euid: ::uid_t,
pub sc_gid: ::gid_t,
pub sc_egid: ::gid_t,
pub sc_ngroups: ::c_int,
pub sc_groups: [::gid_t; 1],
}
}

s_no_extra_traits! {
Expand Down Expand Up @@ -1136,6 +1145,15 @@ f! {
as ::c_uint
}

pub fn SOCKCREDSIZE(ngrps: usize) -> usize {
let ngrps = if ngrps > 0 {
ngrps - 1
} else {
0
};
::mem::size_of::<sockcred>() + ::mem::size_of::<::gid_t>() * ngrps
}

pub fn uname(buf: *mut ::utsname) -> ::c_int {
__xuname(256, buf as *mut ::c_void)
}
Expand Down
1 change: 1 addition & 0 deletions src/unix/bsd/freebsdlike/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,7 @@ pub const MSG_DONTWAIT: ::c_int = 0x00000080;
pub const MSG_EOF: ::c_int = 0x00000100;

pub const SCM_TIMESTAMP: ::c_int = 0x02;
pub const SCM_CREDS: ::c_int = 0x03;

pub const SOCK_STREAM: ::c_int = 1;
pub const SOCK_DGRAM: ::c_int = 2;
Expand Down

0 comments on commit 59d3dab

Please sign in to comment.