Skip to content

Commit 936e16b

Browse files
committed
Auto merge of #934 - ctrlcctrlv:master, r=alexcrichton
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
2 parents 68d4848 + d058e0c commit 936e16b

File tree

8 files changed

+57
-14
lines changed

8 files changed

+57
-14
lines changed

Cargo.lock

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22

33
name = "libc"
4-
version = "0.2.37"
4+
version = "0.2.38"
55
authors = ["The Rust Project Developers"]
66
license = "MIT/Apache-2.0"
77
readme = "README.md"

libc-test/build.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,9 @@ fn main() {
664664
// the symbol.
665665
"uname" if freebsd => true,
666666

667+
// FIXME: need to upgrade FreeBSD version; see https://github.com/rust-lang/libc/issues/938
668+
"setgrent" if freebsd => true,
669+
667670
// aio_waitcomplete's return type changed between FreeBSD 10 and 11.
668671
"aio_waitcomplete" if freebsd => true,
669672

src/unix/bsd/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,10 @@ extern {
388388
pub fn getpwent() -> *mut passwd;
389389
pub fn setpwent();
390390
pub fn endpwent();
391+
pub fn setgrent();
392+
pub fn endgrent();
393+
pub fn getgrent() -> *mut ::group;
394+
391395
pub fn getprogname() -> *const ::c_char;
392396
pub fn setprogname(name: *const ::c_char);
393397
pub fn getloadavg(loadavg: *mut ::c_double, nelem: ::c_int) -> ::c_int;

src/unix/bsd/netbsdlike/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,15 @@ extern {
637637
groups: *mut ::gid_t,
638638
ngroups: *mut ::c_int) -> ::c_int;
639639
pub fn initgroups(name: *const ::c_char, basegid: ::gid_t) -> ::c_int;
640+
#[cfg_attr(target_os = "netbsd", link_name = "__getpwent_r50")]
641+
pub fn getpwent_r(pwd: *mut ::passwd,
642+
buf: *mut ::c_char,
643+
buflen: ::size_t,
644+
result: *mut *mut ::passwd) -> ::c_int;
645+
pub fn getgrent_r(grp: *mut ::group,
646+
buf: *mut ::c_char,
647+
buflen: ::size_t,
648+
result: *mut *mut ::group) -> ::c_int;
640649
pub fn fexecve(fd: ::c_int, argv: *const *const ::c_char,
641650
envp: *const *const ::c_char)
642651
-> ::c_int;

src/unix/notbsd/linux/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,9 +1468,13 @@ extern {
14681468
pub fn setpwent();
14691469
pub fn endpwent();
14701470
pub fn getpwent() -> *mut passwd;
1471+
pub fn setgrent();
1472+
pub fn endgrent();
1473+
pub fn getgrent() -> *mut ::group;
14711474
pub fn setspent();
14721475
pub fn endspent();
14731476
pub fn getspent() -> *mut spwd;
1477+
14741478
pub fn getspnam(__name: *const ::c_char) -> *mut spwd;
14751479

14761480
pub fn shm_open(name: *const c_char, oflag: ::c_int,

src/unix/notbsd/linux/other/mod.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,19 @@ extern {
867867
pub fn mallinfo() -> ::mallinfo;
868868
pub fn malloc_usable_size(ptr: *mut ::c_void) -> ::size_t;
869869
pub fn getauxval(type_: ::c_ulong) -> ::c_ulong;
870+
#[cfg_attr(target_os = "netbsd", link_name = "__getpwent_r50")]
871+
#[cfg_attr(target_os = "solaris", link_name = "__posix_getpwent_r")]
872+
pub fn getpwent_r(pwd: *mut ::unix::notbsd::linux::passwd,
873+
buf: *mut ::c_char,
874+
buflen: ::size_t,
875+
result: *mut *mut ::unix::notbsd
876+
::linux::passwd) -> ::c_int;
877+
#[cfg_attr(target_os = "netbsd", link_name = "__getgrent_r50")]
878+
#[cfg_attr(target_os = "solaris", link_name = "__posix_getgrent_r")]
879+
pub fn getgrent_r(grp: *mut ::group,
880+
buf: *mut ::c_char,
881+
buflen: ::size_t,
882+
result: *mut *mut ::group) -> ::c_int;
870883
}
871884

872885
cfg_if! {

src/unix/solaris/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,6 +1434,16 @@ extern {
14341434
buf: *mut ::c_char,
14351435
buflen: ::size_t,
14361436
result: *mut *mut passwd) -> ::c_int;
1437+
#[cfg_attr(target_os = "solaris", link_name = "__posix_getpwent_r")]
1438+
pub fn getpwent_r(pwd: *mut passwd,
1439+
buf: *mut ::c_char,
1440+
buflen: ::size_t,
1441+
result: *mut *mut passwd) -> ::c_int;
1442+
#[cfg_attr(target_os = "solaris", link_name = "__posix_getgrent_r")]
1443+
pub fn getgrent_r(grp: *mut ::group,
1444+
buf: *mut ::c_char,
1445+
buflen: ::size_t,
1446+
result: *mut *mut ::group) -> ::c_int;
14371447
#[cfg_attr(target_os = "solaris", link_name = "__posix_sigwait")]
14381448
pub fn sigwait(set: *const sigset_t,
14391449
sig: *mut ::c_int) -> ::c_int;

0 commit comments

Comments
 (0)