Skip to content

Commit 84da91c

Browse files
committed
Auto merge of #809 - djg:freebsd_sol_local, r=alexcrichton
Local peer credential support for FreeBSD. FreeBSD uses SOL_SOCKET/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 5355286 + ebb59a2 commit 84da91c

File tree

1 file changed

+16
-0
lines changed
  • src/unix/bsd/freebsdlike/freebsd

1 file changed

+16
-0
lines changed

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

+16
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,14 @@ s! {
127127
pub shm_dtime: ::time_t,
128128
pub shm_ctime: ::time_t,
129129
}
130+
131+
pub struct xucred {
132+
pub cr_version: ::c_uint,
133+
pub cr_uid: ::uid_t,
134+
pub cr_ngroups: ::c_short,
135+
pub cr_groups: [::gid_t;16],
136+
__cr_unused1: *mut ::c_void,
137+
}
130138
}
131139

132140
pub const SIGEV_THREAD_ID: ::c_int = 4;
@@ -402,6 +410,11 @@ pub const SO_PROTOCOL: ::c_int = 0x1016;
402410
pub const SO_PROTOTYPE: ::c_int = SO_PROTOCOL;
403411
pub const SO_VENDOR: ::c_int = 0x80000000;
404412

413+
pub const LOCAL_PEERCRED: ::c_int = 1;
414+
pub const LOCAL_CREDS: ::c_int = 2;
415+
pub const LOCAL_CONNWAIT: ::c_int = 4;
416+
pub const LOCAL_VENDOR: ::c_int = SO_VENDOR;
417+
405418
pub const AF_SLOW: ::c_int = 33;
406419
pub const AF_SCLUSTER: ::c_int = 34;
407420
pub const AF_ARP: ::c_int = 35;
@@ -766,6 +779,9 @@ pub const _PC_ACL_NFS4: ::c_int = 64;
766779

767780
pub const _SC_CPUSET_SIZE: ::c_int = 122;
768781

782+
pub const XU_NGROUPS: ::c_int = 16;
783+
pub const XUCRED_VERSION: ::c_uint = 0;
784+
769785
extern {
770786
pub fn __error() -> *mut ::c_int;
771787

0 commit comments

Comments
 (0)