From nobody Fri Nov 15 13:00:45 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 4XqcZk1Ml0z5d6gN; Fri, 15 Nov 2024 13:00:46 +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 4XqcZj6DHcz4pPS; Fri, 15 Nov 2024 13:00:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731675645; 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=7TwaaDC8XGUpgbUpeCBS2sgzfII1NFb/bBh2bQHFMxc=; b=GlW+8cuXcRf1Yv2UxfrdIphDZ9camDHwzKii6J8PaUISb2cHoC6U5Gq4X84oDYs3QqXBzQ dIow14NfeaywufloKHl+NqzYyB9VnphWd/jsjq9SzcW8G7U56X56zkc45e83OIdIXUJQzB 1Xi3YX22ediOW4rNOCSyI9u22awe9oUmU4dXFmg18PR873xC9Y9khjHaaeHwGcyJRJUFd+ lBs3O5svLolwN8rBHix8MBdsxb6pxj9WibNstJVOwVde2CmJ9ZwfxIkL+gYKOmnZiQ+0tS +oFJJ/EMN3MKF7Aurzx9JcDVyBI+KYTZdRnSTZMKiKOP14Nnl11yQapdGJTI5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731675645; 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=7TwaaDC8XGUpgbUpeCBS2sgzfII1NFb/bBh2bQHFMxc=; b=wQxihQ/czNN35lYGwe5hfzdaBWdwf8zCNQnUyUksu5HEjbFbuROf0XhloiAYqPZ0XPGYCL QHn7v60dt8OZjylr3tv+spsMR+u8ELrZRRiYAfdKiULbqQbgPINHjuiee82mlEtd/9AxCj ORXgVpOEkmGVX/JD82LmBRS3AnNKaf/5CfTh2nPbeDHO5af3Cm1OtTMHf/fHSWDvM65B8N T+mRx9Ac1s5bSaMHOBqcaO8U/ZGrGEgu4YtQUDgGJlUUaaMEgcclCgsHFXPGKstqwKoF5G 3sBSRnp0UZBEcKyHPWIEifS/JdDIGDsJUHZQSfH6RREf5PWPhusYBB3dYaIN9w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1731675645; a=rsa-sha256; cv=none; b=egklYFVPhhyDXEI03YSV05VULP7romhIY3XiV5KqxidsthVInuI1sRXo8edzb3VJ47FfPf eoDONxqiriWut3sJghfNsifK6fPAnaX7sKp9zt25qQSM30mWMN+06hc7c5BcOtZnAszb/R AQvwx/j3mRJpLJuryXQ3T2ui3QB3Z8dT2XHwOAbMdE5byAVqZrV8k7Xf09ddN+8rUlg+3P H88mt6F69LP9Mt+q0YFtN+4PRFB7v6mpqrZnFjxCIGaQz7uXdkTx+FZw4NPCoB2QPK9uVo DnfQVa3R9uZS08A5MzoAQ5UzS+XrkjYzkwzupROpI9NRIxtE8CC53+fv2O417g== 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 4XqcZj5THbzP5w; Fri, 15 Nov 2024 13:00:45 +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 4AFD0j73069882; Fri, 15 Nov 2024 13:00:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4AFD0jWZ069879; Fri, 15 Nov 2024 13:00:45 GMT (envelope-from git) Date: Fri, 15 Nov 2024 13:00:45 GMT Message-Id: <202411151300.4AFD0jWZ069879@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: d43f0394c57e - stable/13 - 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/13 X-Git-Reftype: branch X-Git-Commit: d43f0394c57e9119248039b04f063ed6b839e1cd Auto-Submitted: auto-generated The branch stable/13 has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=d43f0394c57e9119248039b04f063ed6b839e1cd commit d43f0394c57e9119248039b04f063ed6b839e1cd Author: Olivier Certner AuthorDate: 2024-07-19 09:54:35 +0000 Commit: Olivier Certner CommitDate: 2024-11-15 12:59:08 +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 eb4910e1591a..5fdb0a40a425 100644 --- a/sys/kern/kern_prot.c +++ b/sys/kern/kern_prot.c @@ -1285,7 +1285,7 @@ sys___setugid(struct thread *td, struct __setugid_args *uap) /* * Returns whether gid designates a supplementary group in cred. */ -static int +int 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 74e2d59c57ea..da0568e9648f 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 int +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); +} +int group_is_supplementary(const gid_t gid, const struct ucred *const cred); int groupmember(gid_t gid, const struct ucred *cred); int realgroupmember(gid_t gid, const struct ucred *cred); #endif /* _KERNEL */