]> git.ipfire.org Git - thirdparty/shadow.git/commit
lib/, src/: Simplify allocation of buffer
authorAlejandro Colomar <alx@kernel.org>
Thu, 14 Nov 2024 13:39:23 +0000 (14:39 +0100)
committerSerge Hallyn <serge@hallyn.com>
Fri, 24 Jan 2025 13:58:13 +0000 (07:58 -0600)
commitde941a7601f8410a1b918c61eec02ab07263eee5
treeb135f769b1c9732ba8d60e5e5606c3953ece48b0
parente048ba4d803a49ff24d0d8d59d8991117dc18408
lib/, src/: Simplify allocation of buffer

getgroups(0, NULL) returns the number of groups, so that we can allocate
at once.  This might fail if there's a race and the number of users
grows while we're allocating, but if that happens, failing is probably a
good thing to do.

There was some comment saying it doesn't work on some systems, but
according to gnulib, that's only NeXTstep 3.2, which we don't support.

Link: <https://www.gnu.org/software/gnulib/manual/html_node/getgroups.html>
Reviewed-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/addgrps.c
src/newgrp.c