diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-07-25 00:17:30 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-25 00:17:30 +0000 |
commit | 8519d9f8c8e3b1cdf211774d309f8f21cf450528 (patch) | |
tree | 032932ae700c6705739c765a5984d92dc5b25ea4 /test/test_unistd.rs | |
parent | e1351ab48bbf2ea1522388918e97dd2b861dabf7 (diff) | |
parent | 3f6151ebbe11c6c20735f6390be69461628f9857 (diff) | |
download | nix-8519d9f8c8e3b1cdf211774d309f8f21cf450528.zip |
Merge #1471
1471: unistd: Add conversion from User to libc::passwd r=asomers a=orvij
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
Exposes the `User::gecos` field to 64-bit Android builds, since `libc::passwd::pw_gecos` is supported on those builds
Co-authored-by: orvij <85481483+orvij@users.noreply.github.com>
Diffstat (limited to 'test/test_unistd.rs')
-rw-r--r-- | test/test_unistd.rs | 8 |
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] |