1
Fork 0

Corpus: do not fix up the data

see the comment.
This commit is contained in:
Motiejus Jakštys 2022-07-20 05:37:19 +03:00
parent e34ee1d66b
commit 6c311b786f
1 changed files with 10 additions and 12 deletions

View File

@ -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,