1
Fork 0

Corpus: do not fix up the data

see the comment.
main
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| { for (groupmembers) |member_name| {
if (name2user.get(member_name)) |user_idx| { if (name2user.get(member_name)) |user_idx| {
// If user is in a group of their primary gid, // If user is in a group of their primary gid, the right thing
// skip the membersip. This is what classical tools do // to do is to skip the membersip. This is what classical tools
// (look at your etc/passwd), but not what Ours Truly // do (look at your etc/passwd), but not what Ours Truly nss
// nss implementation does. // implementation does. However, since there is at least one
// - Uncomment this code to behave how Classics behave. // known implementation that does not do this, push the
// - Leave commented to be compatible with Ours Truly NSS. // responsibility to the validator (and keep the code
if (users.items(.gid)[user_idx] == groups.items(.gid)[i]) // commented).
continue; // if (users.items(.gid)[user_idx] == groups.items(.gid)[i])
// continue;
members.len += 1; members.len += 1;
members[members.len - 1] = user_idx; members[members.len - 1] = user_idx;
try user2groups[user_idx].append(allocator, @intCast(u32, i)); try user2groups[user_idx].append(allocator, @intCast(u32, i));
@ -266,10 +267,7 @@ pub fn testCorpus(allocator: Allocator) !Corpus {
.shell = "/usr/sbin/nologin", .shell = "/usr/sbin/nologin",
} }; } };
// the "root" membership should be removed, because root's gid is this var group0 = try Group.init(allocator, 0, "root", &[_][]const u8{});
// 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 group1 = try Group.init(allocator, 128, "vidmantas", &[_][]const u8{}); var group1 = try Group.init(allocator, 128, "vidmantas", &[_][]const u8{});
var group2 = try Group.init( var group2 = try Group.init(
allocator, allocator,