diff options
author | Jiyong Park <jiyong@google.com> | 2023-02-20 10:16:45 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-02-20 10:16:45 +0000 |
commit | caa9e948f0701a7e0c0a6c6fd650dbb4f630ac47 (patch) | |
tree | d577785b48e5f7919dde49ec979bde78fa7f3bd8 | |
parent | a5fff1e89a0578290835f7ae5311ced2c29de7ec (diff) | |
parent | 68cee273d434ae01e93efbc34d8b7fa581a6c834 (diff) | |
download | nix-caa9e948f0701a7e0c0a6c6fd650dbb4f630ac47.tar.gz |
Re-apply unistd.diff after the update to 0.26.2 am: 20fa8cf97f am: 8cd1c16403 am: 68cee273d4
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/nix/+/2445822
Change-Id: I6c0ffc1a5270b800dc32546ccbe23355ff845bd1
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | src/unistd.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/unistd.rs b/src/unistd.rs index d746757..ca07b34 100644 --- a/src/unistd.rs +++ b/src/unistd.rs @@ -3015,12 +3015,12 @@ impl From<&libc::passwd> for User { fn from(pw: &libc::passwd) -> User { unsafe { User { - name: CStr::from_ptr(pw.pw_name).to_string_lossy().into_owned(), - passwd: CString::new(CStr::from_ptr(pw.pw_passwd).to_bytes()).unwrap(), + name: if pw.pw_name.is_null() { Default::default() } else { CStr::from_ptr(pw.pw_name).to_string_lossy().into_owned() }, + passwd: if pw.pw_passwd.is_null() { Default::default() } else { CString::new(CStr::from_ptr(pw.pw_passwd).to_bytes()).unwrap() }, #[cfg(not(all(target_os = "android", target_pointer_width = "32")))] - gecos: CString::new(CStr::from_ptr(pw.pw_gecos).to_bytes()).unwrap(), - dir: PathBuf::from(OsStr::from_bytes(CStr::from_ptr(pw.pw_dir).to_bytes())), - shell: PathBuf::from(OsStr::from_bytes(CStr::from_ptr(pw.pw_shell).to_bytes())), + gecos: if pw.pw_gecos.is_null() { Default::default() } else { CString::new(CStr::from_ptr(pw.pw_gecos).to_bytes()).unwrap() }, + dir: if pw.pw_dir.is_null() { Default::default() } else { PathBuf::from(OsStr::from_bytes(CStr::from_ptr(pw.pw_dir).to_bytes())) }, + shell: if pw.pw_shell.is_null() { Default::default() } else { PathBuf::from(OsStr::from_bytes(CStr::from_ptr(pw.pw_shell).to_bytes())) }, uid: Uid::from_raw(pw.pw_uid), gid: Gid::from_raw(pw.pw_gid), #[cfg(not(any(target_os = "android", |