From 6c311b786f4a4ce0ca9c54fc19061138581d35c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Wed, 20 Jul 2022 05:37:19 +0300 Subject: [PATCH] Corpus: do not fix up the data see the comment. --- src/Corpus.zig | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/Corpus.zig b/src/Corpus.zig index 1266627..12b4f89 100644 --- a/src/Corpus.zig +++ b/src/Corpus.zig @@ -167,14 +167,15 @@ pub fn init( for (groupmembers) |member_name| { if (name2user.get(member_name)) |user_idx| { - // If user is in a group of their primary gid, - // skip the membersip. This is what classical tools do - // (look at your etc/passwd), but not what Ours Truly - // nss implementation does. - // - Uncomment this code to behave how Classics behave. - // - Leave commented to be compatible with Ours Truly NSS. - if (users.items(.gid)[user_idx] == groups.items(.gid)[i]) - continue; + // If user is in a group of their primary gid, the right thing + // to do is to skip the membersip. This is what classical tools + // do (look at your etc/passwd), but not what Ours Truly nss + // implementation does. However, since there is at least one + // known implementation that does not do this, push the + // responsibility to the validator (and keep the code + // commented). + // if (users.items(.gid)[user_idx] == groups.items(.gid)[i]) + // continue; members.len += 1; members[members.len - 1] = user_idx; try user2groups[user_idx].append(allocator, @intCast(u32, i)); @@ -266,10 +267,7 @@ pub fn testCorpus(allocator: Allocator) !Corpus { .shell = "/usr/sbin/nologin", } }; - // the "root" membership should be removed, because root's gid is this - // group's id. All the exported functions that return memberships (getgr*, - // initgroups_dyn) expect these users will not be returned. - var group0 = try Group.init(allocator, 0, "root", &[_][]const u8{"root"}); + var group0 = try Group.init(allocator, 0, "root", &[_][]const u8{}); var group1 = try Group.init(allocator, 128, "vidmantas", &[_][]const u8{}); var group2 = try Group.init( allocator,