From nobody Fri Oct 10 17:16:38 2025 X-Original-To: dev-commits-src-all@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 4cjth735kzz6Bcy5; Fri, 10 Oct 2025 17:16:39 +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 4cjth65bclz3gvX; Fri, 10 Oct 2025 17:16:38 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1760116598; 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=r3KJLsh+ENUXFr6XoksK7OH6vXarVubUW/xQ34yiCxo=; b=kHVi2bgKWP0uVXcP61rd1AKBKNVUbHTXC1imWyCpdcENVKhjIhWcsK6Vk2xrd1bpvktq79 WzpAkymKbCLRcNLe24yp1XFlAHRuA0QRVA9kv7QW1HHZrTTdCVRQl6ZrCSndsaABF/ZBC/ qcJ2FYVk4eA7+n2jNUHOCSkr+8EgGVxleHYqJ+i9H4JckpyHm1SaqTzyoYJzjoHcgOxE3U /hbF4Tp8mrWp987jZQdy5TbjPdpDhs6L5PaueedW4/Txat0U8BMNxi1CWfxlmnwgpz9RiA vpxH5clybo32G7Gr/AwaQ28w+qYPNuj9F+1DhX83fkDq9CCp5n+k7ir3CNb/gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1760116598; 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=r3KJLsh+ENUXFr6XoksK7OH6vXarVubUW/xQ34yiCxo=; b=i4a0Ers7Q0tTlmM/7zCKI/J33v0p+MEA2GeCar2FGLm6mRJUTcF8rUyvS8b4lmcn+CuHzy Jdo5eU0dvwhKO8aPvMMdH4SuUzzVhcy4S8L4HcEtDAOFTeRlD7H4ir8F5fuffSlK+M7am2 OE9sbAjxJ+FRrraRrMHBfp927vXK4i8o34H8/4bm4n70YVOm412GS6JpudZjGVMAeiICv2 x+Uxurj1t3cgw6m3lvqB4mSIwFN1qdruANNEvnbOo7TTk3Za5M3sjLsvOlTkiPJBCSDa4C cwnNZUcyrxfm1d2Vf8aUA9b+kv+XOmba4AAaI4/1w8LmMQwhDSflDDfmlW8zwg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1760116598; a=rsa-sha256; cv=none; b=Mh9c3M9QulX7BlbTVtSrwmeLts0idBFRAKSsh0AZMGWYKVdgqNg4VcP7NdXYtegOsmn29G sVigqEo5ETARg5N9T2vCel2FB2BmPOki1fQyN4xgepJojVKOdiCvDDQJ7esAD9VnxHRudy AkuPQ5ZOOCfWIbSDqjDpjGWSo+PqCAUkDshTvZ7jZdJK58ZXQqmHjkcoaYzHsZFXyiA1sw dPTmYIcPd/1wiL6a7UdWM0pi+Q7liFxcw9cAQ15zEpyp237X7wnDFLtbCynLPfZ/AxiEAt yOI3sSaZ453d+oDM9R+Y75pwK/mztZzWpn09pn1STVFxzIDnb8oCrl78zi4Wvw== 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 4cjth63dZwz1Bls; Fri, 10 Oct 2025 17:16:38 +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 59AHGcZW009781; Fri, 10 Oct 2025 17:16:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 59AHGcnX009778; Fri, 10 Oct 2025 17:16:38 GMT (envelope-from git) Date: Fri, 10 Oct 2025 17:16:38 GMT Message-Id: <202510101716.59AHGcnX009778@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Olivier Certner Subject: git: dbfdd93a188b - stable/14 - getgrouplist.3: Insist on the value returned in 'ngroups'; Minor changes List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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/stable/14 X-Git-Reftype: branch X-Git-Commit: dbfdd93a188b089b35bee251ad3b60b50fc00117 Auto-Submitted: auto-generated The branch stable/14 has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=dbfdd93a188b089b35bee251ad3b60b50fc00117 commit dbfdd93a188b089b35bee251ad3b60b50fc00117 Author: Olivier Certner AuthorDate: 2025-10-08 10:06:02 +0000 Commit: Olivier Certner CommitDate: 2025-10-10 17:16:02 +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 (cherry picked from commit f5544556754ec6b33c1d13c7648a354fef645b2f) --- 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 09f01e4fc852..bc7de7678385 100644 --- a/lib/libc/gen/getgrouplist.3 +++ b/lib/libc/gen/getgrouplist.3 @@ -35,7 +35,7 @@ .\" .\" @(#)getgrouplist.3 8.1 (Berkeley) 6/9/93 .\" -.Dd August 29, 2025 +.Dd October 9, 2025 .Dt GETGROUPLIST 3 .Os .Sh NAME @@ -50,30 +50,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