summaryrefslogtreecommitdiff
path: root/test/test_unistd.rs
diff options
context:
space:
mode:
authororvij <85481483+orvij@users.noreply.github.com>2021-07-18 09:35:43 +0000
committerorvij <85481483+orvij@users.noreply.github.com>2021-07-24 23:52:56 +0000
commit3f6151ebbe11c6c20735f6390be69461628f9857 (patch)
tree032932ae700c6705739c765a5984d92dc5b25ea4 /test/test_unistd.rs
parente1351ab48bbf2ea1522388918e97dd2b861dabf7 (diff)
downloadnix-3f6151ebbe11c6c20735f6390be69461628f9857.zip
unistd: Add conversion from User to libc::passwd
Add From<User> for libc::passwd trait implementation to convert a User into a libc::passwd Implementation consumes the User struct, giving ownership over the internal members to the libc::passwd struct Add the User::gecos field to 64-bit Android builds, since it is supported by libc::passwd for those builds
Diffstat (limited to 'test/test_unistd.rs')
-rw-r--r--test/test_unistd.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/test_unistd.rs b/test/test_unistd.rs
index b95f1549..984dd2c9 100644
--- a/test/test_unistd.rs
+++ b/test/test_unistd.rs
@@ -1025,6 +1025,14 @@ fn test_access_file_exists() {
assert!(access(&path, AccessFlags::R_OK | AccessFlags::W_OK).is_ok());
}
+#[test]
+fn test_user_into_passwd() {
+ // get the UID of the "nobody" user
+ let nobody = User::from_name("nobody").unwrap().unwrap();
+ let pwd: libc::passwd = nobody.into();
+ let _: User = (&pwd).into();
+}
+
/// Tests setting the filesystem UID with `setfsuid`.
#[cfg(any(target_os = "linux", target_os = "android"))]
#[test]