Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix group passwd #55

Merged
merged 2 commits into from
Oct 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,12 @@ fn serialize_group(group: Option<Group>) -> Result<Vec<u8>> {
if let Some(data) = group {
let name = CString::new(data.name)?;
let name_bytes = name.to_bytes_with_nul();
// The nix crate doesn't give us the password: https://github.com/nix-rust/nix/pull/1338
let passwd = CString::new("x")?;
let passwd_bytes = passwd.to_bytes_with_nul();
let mem_cnt = data.mem.len();
let passwd_bytes = data.passwd.to_bytes_with_nul();
let members: Vec<CString> = data
.mem
.iter()
.map(|member| CString::new((*member).as_bytes()))
.into_iter()
.map(CString::new)
.collect::<Result<Vec<CString>, _>>()?;
let members_bytes: Vec<&[u8]> = members
.iter()
Expand All @@ -226,7 +225,7 @@ fn serialize_group(group: Option<Group>) -> Result<Vec<u8>> {
gr_name_len: name_bytes.len().try_into()?,
gr_passwd_len: passwd_bytes.len().try_into()?,
gr_gid: data.gid.as_raw(),
gr_mem_cnt: data.mem.len().try_into()?,
gr_mem_cnt: mem_cnt.try_into()?,
};
result.extend_from_slice(header.as_slice());
for member_bytes in members_bytes.iter() {
Expand Down
Loading