mirror of
https://github.com/NixOS/nix
synced 2025-06-29 02:11:15 +02:00
Merge remote-tracking branch 'origin/master' into auto-uid-allocation
This commit is contained in:
commit
b95faccf03
401 changed files with 14006 additions and 5711 deletions
|
@ -80,13 +80,30 @@ struct SimpleUserLock : UserLock
|
|||
/* Get the list of supplementary groups of this build
|
||||
user. This is usually either empty or contains a
|
||||
group such as "kvm". */
|
||||
lock->supplementaryGIDs.resize(10);
|
||||
int ngroups = lock->supplementaryGIDs.size();
|
||||
int err = getgrouplist(pw->pw_name, pw->pw_gid,
|
||||
lock->supplementaryGIDs.data(), &ngroups);
|
||||
int ngroups = 32; // arbitrary initial guess
|
||||
lock->supplementaryGIDs.resize(ngroups);
|
||||
|
||||
int err = getgrouplist(
|
||||
pw->pw_name, pw->pw_gid,
|
||||
lock->supplementaryGIDs.data(),
|
||||
&ngroups);
|
||||
|
||||
/* Our initial size of 32 wasn't sufficient, the
|
||||
correct size has been stored in ngroups, so we try
|
||||
again. */
|
||||
if (err == -1) {
|
||||
lock->supplementaryGIDs.resize(ngroups);
|
||||
err = getgrouplist(
|
||||
pw->pw_name, pw->pw_gid,
|
||||
lock->supplementaryGIDs.data(),
|
||||
&ngroups);
|
||||
}
|
||||
|
||||
// If it failed once more, then something must be broken.
|
||||
if (err == -1)
|
||||
throw Error("failed to get list of supplementary groups for '%s'", pw->pw_name);
|
||||
|
||||
// Finally, trim back the GID list to its real size.
|
||||
lock->supplementaryGIDs.resize(ngroups);
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue