Skip to content

Commit

Permalink
Add passwd/group APIs needed for nix-rust/nix#864
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrlcctrlv committed Mar 3, 2018
1 parent 2bfacc8 commit 5f9538d
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 11 deletions.
20 changes: 10 additions & 10 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
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions src/unix/bsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ s! {
pub pw_fields: ::c_int,
}

pub struct group {
pub gr_name: *mut ::c_char,
pub gr_passwd: *mut ::c_char,
pub gr_gid: ::gid_t,
pub gr_mem: *mut *mut ::c_char
}

pub struct ifaddrs {
pub ifa_next: *mut ifaddrs,
pub ifa_name: *mut ::c_char,
Expand Down Expand Up @@ -388,6 +395,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 Expand Up @@ -513,6 +524,18 @@ extern {
buf: *mut ::c_char,
buflen: ::size_t,
result: *mut *mut passwd) -> ::c_int;
#[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 passwd,
buf: *mut ::c_char,
buflen: ::size_t,
result: *mut *mut 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_attr(all(target_os = "macos", target_arch ="x86"),
link_name = "sigwait$UNIX2003")]
#[cfg_attr(target_os = "solaris", link_name = "__posix_sigwait")]
Expand Down
24 changes: 24 additions & 0 deletions src/unix/notbsd/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@ s! {
pub pw_shell: *mut ::c_char,
}

pub struct group {
pub gr_name: *mut ::c_char,
pub gr_passwd: *mut ::c_char,
pub gr_gid: ::gid_t,
pub gr_mem: *mut *mut ::c_char
}

pub struct spwd {
pub sp_namp: *mut ::c_char,
pub sp_pwdp: *mut ::c_char,
Expand Down Expand Up @@ -1468,9 +1475,14 @@ 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 Expand Up @@ -1826,6 +1838,18 @@ extern {
buf: *mut ::c_char,
buflen: ::size_t,
result: *mut *mut passwd) -> ::c_int;
#[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 passwd,
buf: *mut ::c_char,
buflen: ::size_t,
result: *mut *mut 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_attr(all(target_os = "macos", target_arch ="x86"),
link_name = "sigwait$UNIX2003")]
#[cfg_attr(target_os = "solaris", link_name = "__posix_sigwait")]
Expand Down

0 comments on commit 5f9538d

Please sign in to comment.