Skip to content

Commit

Permalink
Auto merge of #934 - ctrlcctrlv:master, r=alexcrichton
Browse files Browse the repository at this point in the history
Add passwd/group APIs needed for nix-rust/nix#864

Hope I did this right. I only added platforms I could personally test. . .

cc: @gnzlbg
  • Loading branch information
bors committed Mar 3, 2018
2 parents 68d4848 + d058e0c commit 936e16b
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 14 deletions.
26 changes: 13 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
@@ -1,7 +1,7 @@
[package]

name = "libc"
version = "0.2.37"
version = "0.2.38"
authors = ["The Rust Project Developers"]
license = "MIT/Apache-2.0"
readme = "README.md"
Expand Down
3 changes: 3 additions & 0 deletions libc-test/build.rs
Expand Up @@ -664,6 +664,9 @@ fn main() {
// the symbol.
"uname" if freebsd => true,

// FIXME: need to upgrade FreeBSD version; see https://github.com/rust-lang/libc/issues/938
"setgrent" if freebsd => true,

// aio_waitcomplete's return type changed between FreeBSD 10 and 11.
"aio_waitcomplete" if freebsd => true,

Expand Down
4 changes: 4 additions & 0 deletions src/unix/bsd/mod.rs
Expand Up @@ -388,6 +388,10 @@ extern {
pub fn getpwent() -> *mut passwd;
pub fn setpwent();
pub fn endpwent();
pub fn setgrent();
pub fn endgrent();
pub fn getgrent() -> *mut ::group;

pub fn getprogname() -> *const ::c_char;
pub fn setprogname(name: *const ::c_char);
pub fn getloadavg(loadavg: *mut ::c_double, nelem: ::c_int) -> ::c_int;
Expand Down
9 changes: 9 additions & 0 deletions src/unix/bsd/netbsdlike/mod.rs
Expand Up @@ -637,6 +637,15 @@ extern {
groups: *mut ::gid_t,
ngroups: *mut ::c_int) -> ::c_int;
pub fn initgroups(name: *const ::c_char, basegid: ::gid_t) -> ::c_int;
#[cfg_attr(target_os = "netbsd", link_name = "__getpwent_r50")]
pub fn getpwent_r(pwd: *mut ::passwd,
buf: *mut ::c_char,
buflen: ::size_t,
result: *mut *mut ::passwd) -> ::c_int;
pub fn getgrent_r(grp: *mut ::group,
buf: *mut ::c_char,
buflen: ::size_t,
result: *mut *mut ::group) -> ::c_int;
pub fn fexecve(fd: ::c_int, argv: *const *const ::c_char,
envp: *const *const ::c_char)
-> ::c_int;
Expand Down
4 changes: 4 additions & 0 deletions src/unix/notbsd/linux/mod.rs
Expand Up @@ -1468,9 +1468,13 @@ extern {
pub fn setpwent();
pub fn endpwent();
pub fn getpwent() -> *mut passwd;
pub fn setgrent();
pub fn endgrent();
pub fn getgrent() -> *mut ::group;
pub fn setspent();
pub fn endspent();
pub fn getspent() -> *mut spwd;

pub fn getspnam(__name: *const ::c_char) -> *mut spwd;

pub fn shm_open(name: *const c_char, oflag: ::c_int,
Expand Down
13 changes: 13 additions & 0 deletions src/unix/notbsd/linux/other/mod.rs
Expand Up @@ -867,6 +867,19 @@ extern {
pub fn mallinfo() -> ::mallinfo;
pub fn malloc_usable_size(ptr: *mut ::c_void) -> ::size_t;
pub fn getauxval(type_: ::c_ulong) -> ::c_ulong;
#[cfg_attr(target_os = "netbsd", link_name = "__getpwent_r50")]
#[cfg_attr(target_os = "solaris", link_name = "__posix_getpwent_r")]
pub fn getpwent_r(pwd: *mut ::unix::notbsd::linux::passwd,
buf: *mut ::c_char,
buflen: ::size_t,
result: *mut *mut ::unix::notbsd
::linux::passwd) -> ::c_int;
#[cfg_attr(target_os = "netbsd", link_name = "__getgrent_r50")]
#[cfg_attr(target_os = "solaris", link_name = "__posix_getgrent_r")]
pub fn getgrent_r(grp: *mut ::group,
buf: *mut ::c_char,
buflen: ::size_t,
result: *mut *mut ::group) -> ::c_int;
}

cfg_if! {
Expand Down
10 changes: 10 additions & 0 deletions src/unix/solaris/mod.rs
Expand Up @@ -1434,6 +1434,16 @@ extern {
buf: *mut ::c_char,
buflen: ::size_t,
result: *mut *mut passwd) -> ::c_int;
#[cfg_attr(target_os = "solaris", link_name = "__posix_getpwent_r")]
pub fn getpwent_r(pwd: *mut passwd,
buf: *mut ::c_char,
buflen: ::size_t,
result: *mut *mut passwd) -> ::c_int;
#[cfg_attr(target_os = "solaris", link_name = "__posix_getgrent_r")]
pub fn getgrent_r(grp: *mut ::group,
buf: *mut ::c_char,
buflen: ::size_t,
result: *mut *mut ::group) -> ::c_int;
#[cfg_attr(target_os = "solaris", link_name = "__posix_sigwait")]
pub fn sigwait(set: *const sigset_t,
sig: *mut ::c_int) -> ::c_int;
Expand Down

0 comments on commit 936e16b

Please sign in to comment.