Skip to content

pwd/grp: Add reentrant getgr functions and consolidate getpw functions #724

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

Merged
merged 3 commits into from
Aug 11, 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
13 changes: 1 addition & 12 deletions src/unix/bsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,21 +371,10 @@ extern {
pub fn kqueue() -> ::c_int;
pub fn unmount(target: *const ::c_char, arg: ::c_int) -> ::c_int;
pub fn syscall(num: ::c_int, ...) -> ::c_int;
#[cfg_attr(target_os = "netbsd", link_name = "__getpwnam_r50")]
pub fn getpwnam_r(name: *const ::c_char,
pwd: *mut passwd,
buf: *mut ::c_char,
buflen: ::size_t,
result: *mut *mut passwd) -> ::c_int;
#[cfg_attr(target_os = "netbsd", link_name = "__getpwuid_r50")]
pub fn getpwuid_r(uid: ::uid_t,
pwd: *mut passwd,
buf: *mut ::c_char,
buflen: ::size_t,
result: *mut *mut passwd) -> ::c_int;
#[cfg_attr(target_os = "netbsd", link_name = "__getpwent50")]
pub fn getpwent() -> *mut passwd;
pub fn setpwent();
pub fn endpwent();
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
5 changes: 0 additions & 5 deletions src/unix/haiku/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -791,11 +791,6 @@ extern {
pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void;
pub fn setgroups(ngroups: ::size_t,
ptr: *const ::gid_t) -> ::c_int;
pub fn getpwuid_r(uid: ::uid_t,
pwd: *mut passwd,
buffer: *mut ::c_char,
bufferSize: ::size_t,
result: *mut *mut passwd) -> ::c_int;
pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int;
pub fn mprotect(addr: *const ::c_void, len: ::size_t, prot: ::c_int)
-> ::c_int;
Expand Down
27 changes: 26 additions & 1 deletion src/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,12 +280,37 @@ cfg_if! {
extern {
pub fn getgrnam(name: *const ::c_char) -> *mut group;
pub fn getgrgid(gid: ::gid_t) -> *mut group;
#[cfg_attr(target_os = "solaris", link_name = "__posix_getgrnam_r")]
pub fn getgrnam_r(name: *const ::c_char,
grp: *mut group,
buf: *mut ::c_char,
buflen: ::size_t,
result: *mut *mut group) -> ::c_int;
#[cfg_attr(target_os = "solaris", link_name = "__posix_getgrgid_r")]
pub fn getgrgid_r(uid: ::uid_t,
grp: *mut group,
buf: *mut ::c_char,
buflen: ::size_t,
result: *mut *mut group) -> ::c_int;

pub fn endpwent();
#[cfg_attr(target_os = "netbsd", link_name = "__getpwnam50")]
pub fn getpwnam(name: *const ::c_char) -> *mut passwd;
#[cfg_attr(target_os = "netbsd", link_name = "__getpwuid50")]
pub fn getpwuid(uid: ::uid_t) -> *mut passwd;
#[cfg_attr(target_os = "netbsd", link_name = "__getpwnam_r50")]
#[cfg_attr(target_os = "solaris", link_name = "__posix_getpwnam_r")]
pub fn getpwnam_r(name: *const ::c_char,
pwd: *mut passwd,
buf: *mut ::c_char,
buflen: ::size_t,
result: *mut *mut passwd) -> ::c_int;
#[cfg_attr(target_os = "netbsd", link_name = "__getpwuid_r50")]
#[cfg_attr(target_os = "solaris", link_name = "__posix_getpwuid_r")]
pub fn getpwuid_r(uid: ::uid_t,
pwd: *mut passwd,
buf: *mut ::c_char,
buflen: ::size_t,
result: *mut *mut passwd) -> ::c_int;

pub fn fprintf(stream: *mut ::FILE,
format: *const ::c_char, ...) -> ::c_int;
Expand Down
1 change: 1 addition & 0 deletions src/unix/notbsd/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,7 @@ extern {
pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int;

pub fn setpwent();
pub fn endpwent();
pub fn getpwent() -> *mut passwd;
pub fn setspent();
pub fn endspent();
Expand Down
10 changes: 0 additions & 10 deletions src/unix/notbsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -850,16 +850,6 @@ f! {
}

extern {
pub fn getpwnam_r(name: *const ::c_char,
pwd: *mut passwd,
buf: *mut ::c_char,
buflen: ::size_t,
result: *mut *mut passwd) -> ::c_int;
pub fn getpwuid_r(uid: ::uid_t,
pwd: *mut passwd,
buf: *mut ::c_char,
buflen: ::size_t,
result: *mut *mut passwd) -> ::c_int;
pub fn fdatasync(fd: ::c_int) -> ::c_int;
pub fn mincore(addr: *mut ::c_void, len: ::size_t,
vec: *mut ::c_uchar) -> ::c_int;
Expand Down
14 changes: 1 addition & 13 deletions src/unix/solaris/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1187,20 +1187,8 @@ extern {
serv: *mut ::c_char,
sevlen: ::socklen_t,
flags: ::c_int) -> ::c_int;
#[link_name = "__posix_getpwnam_r"]
pub fn getpwnam_r(name: *const ::c_char,
pwd: *mut passwd,
buf: *mut ::c_char,
buflen: ::size_t,
result: *mut *mut passwd) -> ::c_int;

#[link_name = "__posix_getpwuid_r"]
pub fn getpwuid_r(uid: ::uid_t,
pwd: *mut passwd,
buf: *mut ::c_char,
buflen: ::size_t,
result: *mut *mut passwd) -> ::c_int;
pub fn setpwent();
pub fn endpwent();
pub fn getpwent() -> *mut passwd;
pub fn fdatasync(fd: ::c_int) -> ::c_int;
pub fn nl_langinfo_l(item: ::nl_item, locale: ::locale_t) -> *mut ::c_char;
Expand Down
11 changes: 1 addition & 10 deletions src/unix/uclibc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1422,16 +1422,6 @@ f! {
}

extern {
pub fn getpwnam_r(name: *const ::c_char,
pwd: *mut passwd,
buf: *mut ::c_char,
buflen: ::size_t,
result: *mut *mut passwd) -> ::c_int;
pub fn getpwuid_r(uid: ::uid_t,
pwd: *mut passwd,
buf: *mut ::c_char,
buflen: ::size_t,
result: *mut *mut passwd) -> ::c_int;
pub fn fdatasync(fd: ::c_int) -> ::c_int;
pub fn mincore(addr: *mut ::c_void, len: ::size_t,
vec: *mut ::c_uchar) -> ::c_int;
Expand Down Expand Up @@ -1598,6 +1588,7 @@ extern {
pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int;

pub fn setpwent();
pub fn endpwent();
pub fn getpwent() -> *mut passwd;
pub fn setspent();
pub fn endspent();
Expand Down