From 3f6151ebbe11c6c20735f6390be69461628f9857 Mon Sep 17 00:00:00 2001 From: orvij <85481483+orvij@users.noreply.github.com> Date: Sun, 18 Jul 2021 09:35:43 +0000 Subject: unistd: Add conversion from User to libc::passwd Add From 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 --- test/test_unistd.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test/test_unistd.rs') 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] -- cgit v1.2.3