From nobody Sat Nov 02 20:39:28 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 4XgqN03WX5z5chPw; Sat, 02 Nov 2024 20:39:28 +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 4XgqN02vpsz440n; Sat, 2 Nov 2024 20:39:28 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730579968; 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=rtuRyZLRXFXHYJ/8i7ebJ/RuNrZm9yNnrHz4RebBJOE=; b=eFYhDbt9V6jM0rjVhtFE9kj1wZLZCA8cjQE6MvcrcZxyreYg8E27nqmTv9fp6Z1jx7KsVs vZhwCL3aLJUI3Vw3xRSP9bkkKXzobD34Yg94ER4FWjG6i9SVkrTzoy/+0MqDpiLbVOBhc6 RQrdXVmdgaF3ui/g/eN3HhG9+EJgLFs7jVGl+Vjo8eUsWCCr4iUCaNRVX8dedEd8akSzbR F1ie44jijnkHPtWNZq+CEN7EsMpoLkWk9I723/iEtVQ2HB/CAGD8naNHlTMRcJ1FpRC5Dh kLWVzRRoPupxzshs5snJIq7fIaxMVBEC+dmupZQisWvd8wTGJYlOIX8gA/P/zA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730579968; 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=rtuRyZLRXFXHYJ/8i7ebJ/RuNrZm9yNnrHz4RebBJOE=; b=nOi2ZruXOYG3/wWrJ6KJ2HrZ0FY0bbOB6Rgb54H1MW7KKt06xC7ohr31WMIlzaMEOZQ7iZ xudi7n2fyPKpq9ezXuKxokSKlpFbKY+kJZwihQ8YjDthXDdP7qfTDhukzmHZVfyhQsXi+E dJU6LbjK5HREai1UxKZqhjP1+2viEAyD3dDs/52UBT6KJNPkjJbOCp1y7JwZ4TWkXskHH1 AmNMEQ3ampivI0O+R8ruc7EusoFWRhw+47ZogditSKwntu2kt38q0h11X85z1+ln/R6Okb UMqfxUpTPvHwdtJodqO60zP1vm8FVly8uLhBoxGbRchAzCF9rLtbhYvbcuazLg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1730579968; a=rsa-sha256; cv=none; b=DvR3i7QhV7h5MXhsCPcdWXxA3IVC8iCa7FNoYGQFKNHvZSvprWxuFXshpE4zLFzxxRvPMl Z1ksii7z2fodMMQCZvnfdJVSfyv9ghHRnjygyi5e7JV8hqE40nb2OQT8VprUQU1tMFXCWC kW+DWBwII94hDMcxCHOCKDJ7GYKt1EV93I/U4lQFVK1qlfgYiUDu8nIKoAW68iHze4oFWm Vf0rZItxGsrGcOY4nmWK5LHH/0CXul3sfgzt7LrbBaYoAilocxHZf+5/a16335g2EUaPpt fS4y6LNX8iqHd8fbxorhQnsd3znvUSDazqdegewMUgktbiOd4xoKANRKAL2Q0g== 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 4XgqN02WzSzKF9; Sat, 2 Nov 2024 20:39:28 +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 4A2KdSJ9046154; Sat, 2 Nov 2024 20:39:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4A2KdS64046151; Sat, 2 Nov 2024 20:39:28 GMT (envelope-from git) Date: Sat, 2 Nov 2024 20:39:28 GMT Message-Id: <202411022039.4A2KdS64046151@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: 6369544278b2 - main - 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/main X-Git-Reftype: branch X-Git-Commit: 6369544278b2e4fb5203b10dab466ff7c72c0a25 Auto-Submitted: auto-generated The branch main has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=6369544278b2e4fb5203b10dab466ff7c72c0a25 commit 6369544278b2e4fb5203b10dab466ff7c72c0a25 Author: Olivier Certner AuthorDate: 2024-07-19 09:54:35 +0000 Commit: Olivier Certner CommitDate: 2024-11-02 20:37:40 +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 --- 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 5ba5afc52915..ed20950b12e5 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 ee72af000a58..9fb3c63bbfdf 100644 --- a/sys/sys/ucred.h +++ b/sys/sys/ucred.h @@ -155,6 +155,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 */