Skip to content

Commit f001b8a

Browse files
committed
Auto merge of #807 - djg:macos_sol_local, r=alexcrichton
Local peer credential support for Darwin. Darwin uses SOL_LOCAL/LOCAL_PEERCRED instead of SOL_SOCKET/SO_PEERCRED parameters to getsocktopt to retrieve the credentials of a socket's peer. (Documented in man 4 unix)
2 parents b1ec886 + 49c97ba commit f001b8a

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/unix/bsd/apple/mod.rs

+18
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,13 @@ s! {
411411
pub xsu_pagesize: u32,
412412
pub xsu_encrypted: ::boolean_t,
413413
}
414+
415+
pub struct xucred {
416+
pub cr_version: ::c_uint,
417+
pub cr_uid: ::uid_t,
418+
pub cr_ngroups: ::c_short,
419+
pub cr_groups: [::gid_t;16]
420+
}
414421
}
415422

416423
pub const _UTX_USERSIZE: usize = 256;
@@ -1371,6 +1378,15 @@ pub const IPV6_LEAVE_GROUP: ::c_int = 13;
13711378

13721379
pub const TCP_NODELAY: ::c_int = 0x01;
13731380
pub const TCP_KEEPALIVE: ::c_int = 0x10;
1381+
1382+
pub const SOL_LOCAL: ::c_int = 0;
1383+
1384+
pub const LOCAL_PEERCRED: ::c_int = 0x001;
1385+
pub const LOCAL_PEERPID: ::c_int = 0x002;
1386+
pub const LOCAL_PEEREPID: ::c_int = 0x003;
1387+
pub const LOCAL_PEERUUID: ::c_int = 0x004;
1388+
pub const LOCAL_PEEREUUID: ::c_int = 0x005;
1389+
13741390
pub const SOL_SOCKET: ::c_int = 0xffff;
13751391

13761392
pub const SO_DEBUG: ::c_int = 0x01;
@@ -1949,6 +1965,8 @@ pub const PROC_PIDTHREADINFO: ::c_int = 5;
19491965
pub const MAXCOMLEN: usize = 16;
19501966
pub const MAXTHREADNAMESIZE: usize = 64;
19511967

1968+
pub const XUCRED_VERSION: ::c_uint = 0;
1969+
19521970
f! {
19531971
pub fn WSTOPSIG(status: ::c_int) -> ::c_int {
19541972
status >> 8

0 commit comments

Comments
 (0)