about summary refs log tree commit diff
path: root/src/libstd/sys
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-02-19 11:21:09 +0000
committerbors <bors@rust-lang.org>2017-02-19 11:21:09 +0000
commit0128be9ad70970829420ed498d2f2943a72e1b62 (patch)
treec09e714ab539ac9d39fdbc67d16bef7410b5cb0d /src/libstd/sys
parentaff6161a9e54c767de403a61791df8cfe530009c (diff)
parent68a9d8bf217572ee32bce12e311d5849d149b6b4 (diff)
downloadrust-0128be9ad70970829420ed498d2f2943a72e1b62.tar.gz
rust-0128be9ad70970829420ed498d2f2943a72e1b62.zip
Auto merge of #39871 - binarycrusader:issue-39868, r=alexcrichton
libstd needs update for pending libc change

This  updates libstd to accommodate the fixes made in https://github.com/rust-lang/libc/pull/523

Fixes #39868
Diffstat (limited to 'src/libstd/sys')
-rw-r--r--src/libstd/sys/unix/os.rs38
1 files changed, 9 insertions, 29 deletions
diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs
index 6992a17832e..e78928c2667 100644
--- a/src/libstd/sys/unix/os.rs
+++ b/src/libstd/sys/unix/os.rs
@@ -483,41 +483,21 @@ pub fn home_dir() -> Option<PathBuf> {
                   target_os = "nacl",
                   target_os = "emscripten")))]
     unsafe fn fallback() -> Option<OsString> {
-        #[cfg(not(target_os = "solaris"))]
-        unsafe fn getpwduid_r(me: libc::uid_t, passwd: &mut libc::passwd,
-                              buf: &mut Vec<c_char>) -> Option<()> {
-            let mut result = ptr::null_mut();
-            match libc::getpwuid_r(me, passwd, buf.as_mut_ptr(),
-                                   buf.capacity(),
-                                   &mut result) {
-                0 if !result.is_null() => Some(()),
-                _ => None
-            }
-        }
-
-        #[cfg(target_os = "solaris")]
-        unsafe fn getpwduid_r(me: libc::uid_t, passwd: &mut libc::passwd,
-                              buf: &mut Vec<c_char>) -> Option<()> {
-            // getpwuid_r semantics is different on Illumos/Solaris:
-            // http://illumos.org/man/3c/getpwuid_r
-            let result = libc::getpwuid_r(me, passwd, buf.as_mut_ptr(),
-                                          buf.capacity());
-            if result.is_null() { None } else { Some(()) }
-        }
-
         let amt = match libc::sysconf(libc::_SC_GETPW_R_SIZE_MAX) {
             n if n < 0 => 512 as usize,
             n => n as usize,
         };
         let mut buf = Vec::with_capacity(amt);
         let mut passwd: libc::passwd = mem::zeroed();
-
-        if getpwduid_r(libc::getuid(), &mut passwd, &mut buf).is_some() {
-            let ptr = passwd.pw_dir as *const _;
-            let bytes = CStr::from_ptr(ptr).to_bytes().to_vec();
-            Some(OsStringExt::from_vec(bytes))
-        } else {
-            None
+        let mut result = ptr::null_mut();
+        match libc::getpwuid_r(libc::getuid(), &mut passwd, buf.as_mut_ptr(),
+                               buf.capacity(), &mut result) {
+            0 if !result.is_null() => {
+                let ptr = passwd.pw_dir as *const _;
+                let bytes = CStr::from_ptr(ptr).to_bytes().to_vec();
+                Some(OsStringExt::from_vec(bytes))
+            },
+            _ => None,
         }
     }
 }