Skip to content

Commit

Permalink
Merge #1338
Browse files Browse the repository at this point in the history
1338: Add a passwd field to Group r=asomers a=blinsay

Adds a `passwd` field to unistd::Group. The `gr_passwd` field exists on `libc::group` and wasn't exposed.

I didn't see tests for `from(libc:group)` for either `User` or `Password`. Let me know if there are other tests I should add!

Co-authored-by: Ben Linsay <blinsay@gmail.com>
  • Loading branch information
bors[bot] and blinsay committed Feb 7, 2021
2 parents e7c7021 + 8dc757b commit 3b8180c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -5,6 +5,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased] - ReleaseDate
### Added

- Added a `passwd` field to `Group` (#[1338](https://github.com/nix-rust/nix/pull/1338))
- Added `mremap` (#[1306](https://github.com/nix-rust/nix/pull/1306))
- Added `personality` (#[1331](https://github.com/nix-rust/nix/pull/1331))
- Added limited Fuchsia support (#[1285](https://github.com/nix-rust/nix/pull/1285))
Expand Down
3 changes: 3 additions & 0 deletions src/unistd.rs
Expand Up @@ -2671,6 +2671,8 @@ impl User {
pub struct Group {
/// Group name
pub name: String,
/// Group password
pub passwd: CString,
/// Group ID
pub gid: Gid,
/// List of Group members
Expand All @@ -2683,6 +2685,7 @@ impl From<&libc::group> for Group {
unsafe {
Group {
name: CStr::from_ptr((*gr).gr_name).to_string_lossy().into_owned(),
passwd: CString::new(CStr::from_ptr((*gr).gr_passwd).to_bytes()).unwrap(),
gid: Gid::from_raw((*gr).gr_gid),
mem: Group::members((*gr).gr_mem)
}
Expand Down

0 comments on commit 3b8180c

Please sign in to comment.