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

freebsd proposal to move sockcred2 usage in the root mod while ignori… #2589

Merged
merged 1 commit into from
Dec 12, 2021
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
6 changes: 6 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2196,6 +2196,9 @@ fn test_freebsd(target: &str) {
// `ptrace_coredump` introduced in FreeBSD 14.
"ptrace_coredump" if Some(14) > freebsd_ver => true,

// `sockcred2` is not available in FreeBSD 12.
"sockcred2" if Some(13) > freebsd_ver => true,

_ => false,
}
});
Expand Down Expand Up @@ -2233,6 +2236,9 @@ fn test_freebsd(target: &str) {
true
}

// This is not available in FreeBSD 12.
"SOCKCRED2SIZE" if Some(13) > freebsd_ver => true,

_ => false,
}
});
Expand Down
22 changes: 0 additions & 22 deletions src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,6 @@ s! {
pub ext: [u64; 4],
}

pub struct sockcred2 {
pub sc_version: ::c_int,
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 struct kvm_page {
pub kp_version: ::u_int,
pub kp_paddr: ::kpaddr_t,
Expand Down Expand Up @@ -479,17 +468,6 @@ pub const DOMAINSET_POLICY_INTERLEAVE: ::c_int = 4;

pub const MINCORE_SUPER: ::c_int = 0x20;

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

extern "C" {
pub fn aio_readv(aiocbp: *mut ::aiocb) -> ::c_int;
pub fn aio_writev(aiocbp: *mut ::aiocb) -> ::c_int;
Expand Down
22 changes: 0 additions & 22 deletions src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,6 @@ s! {
pub ext: [u64; 4],
}

pub struct sockcred2 {
pub sc_version: ::c_int,
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 struct kvm_page {
pub kp_version: ::u_int,
pub kp_paddr: ::kpaddr_t,
Expand Down Expand Up @@ -479,17 +468,6 @@ pub const DOMAINSET_POLICY_INTERLEAVE: ::c_int = 4;

pub const MINCORE_SUPER: ::c_int = 0x60;

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

extern "C" {
pub fn aio_readv(aiocbp: *mut ::aiocb) -> ::c_int;
pub fn aio_writev(aiocbp: *mut ::aiocb) -> ::c_int;
Expand Down
20 changes: 20 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -945,6 +945,17 @@ s! {
pub generation: ::c_long,
pub numdevs: ::c_int,
}

pub struct sockcred2 {
pub sc_version: ::c_int,
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],
}
}

s_no_extra_traits! {
Expand Down Expand Up @@ -3701,6 +3712,15 @@ f! {
let (idx, offset) = (cpu / bitset_bits, cpu % bitset_bits);
0 != cpuset.__bits[idx] & (1 << offset)
}

pub fn SOCKCRED2SIZE(ngrps: usize) -> usize {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't it be an issue on freebsd 11 to link to a non-existing function?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah no, nevermind me...

let ngrps = if ngrps > 0 {
ngrps - 1
} else {
0
};
::mem::size_of::<sockcred2>() + ::mem::size_of::<::gid_t>() * ngrps
}
}

safe_f! {
Expand Down