git: f5544556754e - main - getgrouplist.3: Insist on the value returned in 'ngroups'; Minor changes
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 09 Oct 2025 11:35:12 UTC
The branch main has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=f5544556754ec6b33c1d13c7648a354fef645b2f commit f5544556754ec6b33c1d13c7648a354fef645b2f Author: Olivier Certner <olce@FreeBSD.org> AuthorDate: 2025-10-08 10:06:02 +0000 Commit: Olivier Certner <olce@FreeBSD.org> CommitDate: 2025-10-09 11:34:18 +0000 getgrouplist.3: Insist on the value returned in 'ngroups'; Minor changes Emphasize the peculiar treatment of 'ngroups', through which the effective group list's size is returned, even if the passed allocated size is not big enough, in which case the output 'groups' array is completely filled with the effective group list's first elements. Use the precise POSIX term for the group associated to the user in the password database ("initial numerical group ID"), consistently with what was done in initgroups.3. Use "length" instead of "size" to refer to the number of elements of an array (in contrast with its actual size in bytes). Perform some minor simplifications on top of the last rework. MFC after: 1 hour Sponsored by: The FreeBSD Foundation --- lib/libc/gen/getgrouplist.3 | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/lib/libc/gen/getgrouplist.3 b/lib/libc/gen/getgrouplist.3 index e3939fc2481a..9e05ff7e7a29 100644 --- a/lib/libc/gen/getgrouplist.3 +++ b/lib/libc/gen/getgrouplist.3 @@ -33,7 +33,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd August 29, 2025 +.Dd October 9, 2025 .Dt GETGROUPLIST 3 .Os .Sh NAME @@ -48,30 +48,37 @@ .Sh DESCRIPTION The .Fn getgrouplist -function reads through the group database to retrieve the supplementary groups -for the user specified in -.Fa name , +function retrieves from the group database the supplementary groups for the user +specified in +.Fa name and returns the effective group list, whose first group is the value of .Fa basegid -and the others are the retrieved supplementary groups. +and the others are the supplementary groups. .Fa basegid -typically is the user's group number from the password database. +typically is the user's initial numerical group ID from the password database. .Pp The effective group list is returned in the array pointed to by .Fa groups . -The caller specifies the size of the +The caller specifies the length of the .Fa groups array in the integer pointed to by -.Fa ngroups ; -the actual number of groups found is returned in +.Fa ngroups . +The number of groups of the effective group list, which may be greater than the +.Fa groups +array's length, is returned through .Fa ngroups . .Sh RETURN VALUES The .Fn getgrouplist -function -returns 0 on success and \-1 if the size of the group list is too small to -hold all the user's groups. -Here, the group array will be filled with as many groups as will fit. +function returns 0 on success and \-1 if the length of the group list is too +small to hold all the user's groups. +In the latter case, the +.Fa groups +array is filled with as many groups as possible from the start of the effective +group list, and the length pointed to by +.Fa ngroups +is set to the full length of the latter, thus to a value strictly greater than +before the call. .Sh FILES .Bl -tag -width /etc/group -compact .It Pa /etc/group