From nobody Fri Nov 15 10:48:54 2024 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 4XqYfb3kRVz5cykc; Fri, 15 Nov 2024 10:48:55 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XqYfZ50mfz4Wkg; Fri, 15 Nov 2024 10:48:54 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731667734; 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=vAlciRPseOjYlVMASBB3jOG3bCEgCq5bxJKMx9OTNM4=; b=xy4c+15nt1CUI6NhAzVBd0WBOLggyZhLro34AN6f1nR2UGJSHyTgj3p0MsHOm1QK/wfln6 WdqQQ+mOvZBRizj4P3klnYZqaouNGh9O3xkl3xtnC4atTI1XRg3yquKJPLV3I04jYgG9Uv Z074NVndyYDRZ0wzPHAzLEe7bOTzNa2dwMQ8r9kvLs0rBJ1bP6ifQTdU6FqRqwrZYuqmEL SybZZR8X4o+q+8qNWZ0rcM0x0uJye3o+DLGO/bwD1OUsU110aUt42qs9dYuzfIRbrK17Sm ISgqAzLD/SqOT1c7zGWuMjyTq/DHykzHDWf/Kp0950OBHIMti4HdukTwNoEEeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731667734; 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=vAlciRPseOjYlVMASBB3jOG3bCEgCq5bxJKMx9OTNM4=; b=X2xpUaorFJkLCksK7lOnYcw9oINk5D+QtGnSl5g1Kkd7Jr549BKk3M4bNnV1NpjoWUIyJV z2UaTv9FjZ+weGhDYZrEeDen4RR6ZawfsT+yplh1gihM5+KaM+GNYTKOy4aeyTtL071GD2 esELAGDKnF2rSmEWN5kngyX4z8Q7dQJUJD8psVldd9Uv15jNx5Ye6PIzt139mgD0QyzUpF /0LsMI4njMoIqoZ026NMNsC1E7G1m8/6PiyfLK3Qlr6LFU+upi6iZtCSEdj/lo8PVIpsL1 6OwLvSwzz5gRlnaf4dj2tXGoiI45Pie4s/blBuzuMuxe9Y2B2n+QSIKiyUIODg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1731667734; a=rsa-sha256; cv=none; b=rMMzXPH5SqOfbvqrxzNzVlKzqL4Gh4qqTM6DdZpj+hXmUhmKZAjRxtcdMYEfNmJUWplgyI Wb6FSC/VWC4GwLFbQtl3o+feGRmVLO3FOqHUEEIwcDkwp0Y/lguD7GMbhMcMRUub1QlFRZ D9DnCkpvqhGurqW3m2DQk1tKuVQvJzyQvhfjOu23ATm5nStoGK2jsTaziot7atod+AhDl0 2w7x8HMfagNK242bvio2J+q+jgTbX/JOvafbkmVXnon69A20IESjyldOkSUDh5t85N9A9J esUl+PANfCaUyj7q+x+3+bi1CR4Q03CaEgoF9gpd047s9tBYLy3K8unwhFxUrQ== 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 4XqYfZ3jxqzKlG; Fri, 15 Nov 2024 10:48:54 +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 4AFAmsBW017777; Fri, 15 Nov 2024 10:48:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4AFAmsoH017774; Fri, 15 Nov 2024 10:48:54 GMT (envelope-from git) Date: Fri, 15 Nov 2024 10:48:54 GMT Message-Id: <202411151048.4AFAmsoH017774@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: 923a50140b2b - stable/14 - cred: Make group_is_supplementary() public; New group_is_primary() 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: 923a50140b2b7e39a51606f27b6fc44e8673aee1 Auto-Submitted: auto-generated The branch stable/14 has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=923a50140b2b7e39a51606f27b6fc44e8673aee1 commit 923a50140b2b7e39a51606f27b6fc44e8673aee1 Author: Olivier Certner AuthorDate: 2024-07-19 09:54:35 +0000 Commit: Olivier Certner CommitDate: 2024-11-15 10:47:41 +0000 cred: Make group_is_supplementary() public; New group_is_primary() Reviewed by: mhorne Approved by: markj (mentor) MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D46908 (cherry picked from commit 6369544278b2e4fb5203b10dab466ff7c72c0a25) Approved by: markj (mentor) --- sys/kern/kern_prot.c | 2 +- sys/sys/ucred.h | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c index ab2adbffa23b..0430464f6899 100644 --- a/sys/kern/kern_prot.c +++ b/sys/kern/kern_prot.c @@ -1289,7 +1289,7 @@ sys___setugid(struct thread *td, struct __setugid_args *uap) /* * Returns whether gid designates a supplementary group in cred. */ -static bool +bool group_is_supplementary(const gid_t gid, const struct ucred *const cred) { diff --git a/sys/sys/ucred.h b/sys/sys/ucred.h index db38cd99e5bc..21804eb6aa8c 100644 --- a/sys/sys/ucred.h +++ b/sys/sys/ucred.h @@ -158,6 +158,17 @@ void crcowfree(struct thread *td); void cru2x(struct ucred *cr, struct xucred *xcr); void cru2xt(struct thread *td, struct xucred *xcr); void crsetgroups(struct ucred *cr, int n, gid_t *groups); + +/* + * Returns whether gid designates a primary group in cred. + */ +static inline bool +group_is_primary(const gid_t gid, const struct ucred *const cred) +{ + return (gid == cred->cr_groups[0] || gid == cred->cr_rgid || + gid == cred->cr_svgid); +} +bool group_is_supplementary(const gid_t gid, const struct ucred *const cred); bool groupmember(gid_t gid, const struct ucred *cred); bool realgroupmember(gid_t gid, const struct ucred *cred); #endif /* _KERNEL */