From nobody Thu Oct 9 20:41:22 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 4cjMGp39PMz6C5sk; Thu, 09 Oct 2025 20:41:22 +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 4cjMGp2T3yz3ZRW; Thu, 09 Oct 2025 20:41:22 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1760042482; 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=nF0u9Wka7KelqOdgNaEkRSJAYNTaCd7VqCkZkX0D/A4=; b=RObBtdIsjok9T226K6bK15oHbAE4myKt1rZcsHq0niGXP6sDaaUWh74fJ3bZWjXva2UAWa iUc2+/YRQ8KqY7ewsuHGIlIS0qfq2ObTq+/vcP5ws7Blpmk1n3IsOT07pYJT1apcGh8oL1 H6eh+rovVP3A5+MVbc29PpVPQ4UhXyahJppUQEvMdFsq23sZbPHCHHs3mK+z/aQak6A3xE /3e1HdsX/fhTiIZ9eeXTqVW/Abia3EZNoSFybUq4LCjuoKlzjLwI6x6DkeRNkWQZOEaoZ8 P/kUEa3VRHnB4V3eU3HK/stjRQ9W2xCQiyEEv7ZRtkeQ/YeUvc+guSHGGlRf1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1760042482; 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=nF0u9Wka7KelqOdgNaEkRSJAYNTaCd7VqCkZkX0D/A4=; b=oqKePVjRPfCBzxR6H4LTU5I1c8Gq+35gwmDp1MFvicGOF2wfVLQgWWwUjdNda/HIDECVNU QAfw10Hz70d7OKlbyOpBKsiM2QbDws5fS7ltegBr0QJ4yAm5rLrV2BZa/NUIczGm1RVEXm kKBPy/3jtdmIkLUO2Cd7sZOA/Ltb7UV8QYrMTKQT8tNk1hfsnH+WEKBhka3YWAubcho8Od ZTNv6ozlWZv+L8NuODooDoLpDN+Krohf2m6sO0lovOc/A4S+Oee0kEzu9miMXAEqlHXNNx K/Awr3IF0cOdUQAwjz1hefkoMfpEphJdnpaLvW2zVDHuyWeFk36MqCB6TJAX8w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1760042482; a=rsa-sha256; cv=none; b=gJnRXOFJf7KalhbQGmnW7VXkcmiozCUKlPwsPzN/Jm8bCERPirVvAbL74x5MXF88IYqygo S3XHBlhisF3xLAQ0W8c69ndQissLeYHNF6rRccoGKbZNRhjyWcV/XDeL464sjCp7yLgflw XjS4ii9FuwtW/uMeJjKiXN7PG3HNndQfJ29YhSNQdRhXnUjhHVo+ZxE+i5fsFPHpvHD8uc SOBuHb9qa/tSIxu7ccZakUhJUJnecaVyne2Kdm+KXLTbc/i27q1HJ8t20ccagoF1UzYBOx iDzQoGZFCQNtxLHU9Vg2I6QDGlIRfkDLO/vEhuvaM246v4qMOyBiL//FqAtERw== 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 4cjMGp206bzZJh; Thu, 09 Oct 2025 20:41:22 +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 599KfMaH089120; Thu, 9 Oct 2025 20:41:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 599KfMdO089103; Thu, 9 Oct 2025 20:41:22 GMT (envelope-from git) Date: Thu, 9 Oct 2025 20:41:22 GMT Message-Id: <202510092041.599KfMdO089103@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: 23494c4987b4 - stable/15 - 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/15 X-Git-Reftype: branch X-Git-Commit: 23494c4987b4ff7411e38ec0dd027014f337d4d7 Auto-Submitted: auto-generated The branch stable/15 has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=23494c4987b4ff7411e38ec0dd027014f337d4d7 commit 23494c4987b4ff7411e38ec0dd027014f337d4d7 Author: Olivier Certner AuthorDate: 2025-10-08 10:06:02 +0000 Commit: Olivier Certner CommitDate: 2025-10-09 20:40:37 +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 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