Merge branch 'grp-impl' into 'master'

Fix grp.h implementation

See merge request redox-os/relibc!711
This commit is contained in:
Jeremy Soller
2025-09-15 15:38:17 -06:00
2 changed files with 4 additions and 8 deletions
+3 -7
View File
@@ -169,11 +169,7 @@ fn parse_grp(line: String, destbuf: Option<DestBuffer>) -> Result<OwnedGrp, Erro
let mut vec: Vec<u8> = Vec::new();
let gr_name = buffer.next().ok_or(Error::EOF)?.to_vec();
let gr_passwd = if cfg!(target_os = "redox") {
Vec::new()
} else {
buffer.next().ok_or(Error::EOF)?.to_vec()
};
let gr_passwd = buffer.next().ok_or(Error::EOF)?.to_vec();
gr_gid = String::from_utf8(buffer.next().ok_or(Error::EOF)?.to_vec())
.map_err(|err| Error::FromUtf8Error(err))?
.parse::<gid_t>()
@@ -295,7 +291,7 @@ pub unsafe extern "C" fn getgrnam(name: *const c_char) -> *mut group {
grp.reference.gr_name,
name,
strlen(grp.reference.gr_name).min(strlen(name)),
) > 0
) == 0
} {
return grp.into_global();
}
@@ -519,7 +515,7 @@ pub unsafe extern "C" fn getgrouplist(
if groups_found as usize > grps.len() {
-1
} else {
grps.len() as c_int
groups_found
}
}
+1 -1
View File
@@ -8,7 +8,7 @@ void test_getgrnam(const char *gr_name) {
struct group* out = getgrnam(gr_name);
if (out == NULL) {
printf("Did not find a group '%s'", gr_name);
printf("Did not find a group '%s'\n", gr_name);
return;
}