Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ucreds #867

Merged
merged 3 commits into from
Dec 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/dox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,5 +146,6 @@ mod imp {

pub mod mem {
pub fn size_of_val<T>(_: &T) -> usize { 4 }
pub fn size_of<T>(_: &T) -> usize { 4 }
}
}
11 changes: 11 additions & 0 deletions src/unix/bsd/freebsdlike/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,15 @@ s! {
pub int_p_sign_posn: ::c_char,
pub int_n_sign_posn: ::c_char,
}

pub struct cmsgcred {
pub cmcred_pid: ::pid_t,
pub cmcred_uid: ::uid_t,
pub cmcred_euid: ::uid_t,
pub cmcred_gid: ::gid_t,
pub cmcred_ngroups: ::c_short,
pub cmcred_groups: [::gid_t; CMGROUP_MAX],
}
}

pub const AIO_LISTIO_MAX: ::c_int = 16;
Expand Down Expand Up @@ -934,6 +943,8 @@ pub const OCRNL: ::tcflag_t = 0x10;
pub const ONOCR: ::tcflag_t = 0x20;
pub const ONLRET: ::tcflag_t = 0x40;

pub const CMGROUP_MAX: usize = 16;

f! {
pub fn WIFCONTINUED(status: ::c_int) -> bool {
status == 0x13
Expand Down
23 changes: 22 additions & 1 deletion src/unix/bsd/netbsdlike/netbsd/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use dox::mem;

pub type clock_t = ::c_uint;
pub type suseconds_t = ::c_int;
pub type dev_t = u64;
Expand Down Expand Up @@ -281,6 +283,16 @@ s! {
pub ifm_index: ::c_ushort,
pub ifm_data: if_data,
}

pub struct sockcred {
pub sc_pid: ::pid_t,
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],
}
}

pub const AT_FDCWD: ::c_int = -100;
Expand Down Expand Up @@ -910,12 +922,21 @@ pub const SOCK_NONBLOCK: ::c_int = 0x20000000;
// http://cvsweb.netbsd.org/bsdweb.cgi/src/include/dirent.h?rev=1.36
f! {
pub fn dirfd(dirp: *mut ::DIR) -> ::c_int {
unsafe { *(dirp as *const ::c_int) }
*(dirp as *const ::c_int)
}

pub fn WIFCONTINUED(status: ::c_int) -> bool {
status == 0xffff
}

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
}
}

extern {
Expand Down
6 changes: 6 additions & 0 deletions src/unix/notbsd/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,12 @@ s! {
pub p_memsz: Elf64_Xword,
pub p_align: Elf64_Xword,
}

pub struct ucred {
pub pid: ::pid_t,
pub uid: ::uid_t,
pub gid: ::gid_t,
}
}

pub const ABDAY_1: ::nl_item = 0x20000;
Expand Down
6 changes: 0 additions & 6 deletions src/unix/notbsd/linux/musl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,6 @@ s! {
pub mem_unit: ::c_uint,
pub __reserved: [::c_char; 256],
}

pub struct ucred {
pub pid: ::pid_t,
pub uid: ::uid_t,
pub gid: ::gid_t,
}
}

pub const SFD_CLOEXEC: ::c_int = 0x080000;
Expand Down
6 changes: 0 additions & 6 deletions src/unix/notbsd/linux/other/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,6 @@ s! {
__unused5: *mut ::c_void,
}

pub struct ucred {
pub pid: ::pid_t,
pub uid: ::uid_t,
pub gid: ::gid_t,
}

pub struct statfs {
pub f_type: __fsword_t,
pub f_bsize: __fsword_t,
Expand Down
6 changes: 0 additions & 6 deletions src/unix/notbsd/linux/s390x.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,6 @@ s! {
__unused5: *mut ::c_void,
}

pub struct ucred {
pub pid: ::pid_t,
pub uid: ::uid_t,
pub gid: ::gid_t,
}

pub struct flock {
pub l_type: ::c_short,
pub l_whence: ::c_short,
Expand Down