diff options
author | Bernardo Meurer <bernardo@meurer.org> | 2022-06-08 13:45:39 -0400 |
---|---|---|
committer | Bernardo Meurer <bernardo@meurer.org> | 2022-06-08 13:45:41 -0400 |
commit | 931930feb139e6db0d7c01097003f8e45862f68f (patch) | |
tree | d6995540c4d352ca5c1fe7afcc19229c13655aff /src/nix | |
parent | 12e86c0735987cbcc90b86122e9588fef4aa9ba5 (diff) |
fix(libstore/lock): support users that belong to more than 10 groups
The manpage for `getgrouplist` says:
> If the number of groups of which user is a member is less than or
> equal to *ngroups, then the value *ngroups is returned.
>
> If the user is a member of more than *ngroups groups, then
> getgrouplist() returns -1. In this case, the value returned in
> *ngroups can be used to resize the buffer passed to a further
> call getgrouplist().
In our original code, however, we allocated a list of size `10` and, if
`getgrouplist` returned `-1` threw an exception. In practice, this
caused the code to fail for any user belonging to more than 10 groups.
While unusual for single-user systems, large companies commonly have a
huge number of POSIX groups users belong to, causing this issue to crop
up and make multi-user Nix unusable in such settings.
The fix is relatively simple, when `getgrouplist` fails, it stores the
real number of GIDs in `ngroups`, so we must resize our list and retry.
Only then, if it errors once more, we can raise an exception.
This should be backported to, at least, 2.9.x.
Diffstat (limited to 'src/nix')
0 files changed, 0 insertions, 0 deletions