From nobody Thu Oct 09 11:35:12 2025 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4cj78c3xgwz6Blss; Thu, 09 Oct 2025 11:35:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cj78c3L2jz3KmQ; Thu, 09 Oct 2025 11:35:12 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1760009712; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=rkfKorAAW4Rph1b7HTqd0k+fgtnSYXh0EOUcjcTzuAQ=; b=FlVcm9L7Z70ZqJAtP+9NjM+dGJUYcW3IlRPIZ4bwsZ6kAk7RCZV/mmUp64HItfMX4MZpNp s3o8WKBgXf6Pb14ycdeDw7x7WukV2lBvnd1b+niUSxzfR3V7+M7eV0D/FvOLK37KBaCsWP F+qP1oOmRqhsn6BSe/fmSA6wh8R11HqpuTnCIGWHkFjkYLjOuNETLSB39aHY5ium1rA26+ c4ZoBHMAjE05RnstuIdXj5kCwL2lMbHAd6fmFYvhBQvdNiSPEYzm1JhKj2RPO8aeXQnTfU MoQzWQC2/F1K62F4TkztPchEuKkuXNKwuvahTvbBJTa9Sr4C8mOUROqPsf86Gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1760009712; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=rkfKorAAW4Rph1b7HTqd0k+fgtnSYXh0EOUcjcTzuAQ=; b=aaQNY1esB/Idi+5X/DA7b3vJEMQdxdJwKN8Ah9r6H/27UDtiCf8HX1h9Ykq1aghTwc32lB y8ACX3Zd26KwGmvHfm1/YQO8jQGMinPw96R5nSTk3prfEYvll4UQlGstZaCpM5JuiKiA49 vXKDjmSkYefwp5BQ6cG3P0HbL4KXmuBTUOZGC+Z0SkkQy5WPj4/D+Qn86F3yHzuxqsNXTK /ccEUIkDzQf9WJeQ5QIBZNjr1hf6bWkx0P8k9DC34QTDFoBvLxNkALPQ/qxYZP5DlDPoHo G+NuHAd3sxgI5gbMObI+XQCG9GzVJY+k7iyNhsGkRFKCYD/G55aGnqyzl/ExIg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1760009712; a=rsa-sha256; cv=none; b=OMRL3NqZ665d2UzW+ttQeFlBEb43/YYIEPGB9Co+VZBvvgxF5DFs3JBh00jnWHzQMiUnRr pjeGKuzN5JHF/gZbvmyQeDNpBmGv+pRhSYD1oBnTS7/h2WwH0geYLN1ZOcPYtupGptYiHs H3r6FfwLdF47ZHyorp/ApuQTKFbnImV7IY/OCznqZ2TrIQbraXYnVcYPGcw6LqfSvVlP3/ J/5cMYkcMIXbD25eAmCedsy7rEpJ9djhhEmUGHO8IbA0icVOG4ZFDzM1qx5R3cbbjg/zcG 6s28I9K+pqsNbVQ1FOyyge0Hg0f9WTpiBrKaXr/0Vx4st2cKfSx1HopIXbE/6Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4cj78c2xMHz1KB; Thu, 09 Oct 2025 11:35:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 599BZChc057424; Thu, 9 Oct 2025 11:35:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 599BZCi2057421; Thu, 9 Oct 2025 11:35:12 GMT (envelope-from git) Date: Thu, 9 Oct 2025 11:35:12 GMT Message-Id: <202510091135.599BZCi2057421@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Olivier Certner Subject: git: f5544556754e - main - getgrouplist.3: Insist on the value returned in 'ngroups'; Minor changes List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: olce X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f5544556754ec6b33c1d13c7648a354fef645b2f Auto-Submitted: auto-generated The branch main has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=f5544556754ec6b33c1d13c7648a354fef645b2f commit f5544556754ec6b33c1d13c7648a354fef645b2f Author: Olivier Certner AuthorDate: 2025-10-08 10:06:02 +0000 Commit: Olivier Certner 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