git: 923a50140b2b - stable/14 - cred: Make group_is_supplementary() public; New group_is_primary()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 15 Nov 2024 10:48:54 UTC
The branch stable/14 has been updated by olce:
URL: https://cgit.FreeBSD.org/src/commit/?id=923a50140b2b7e39a51606f27b6fc44e8673aee1
commit 923a50140b2b7e39a51606f27b6fc44e8673aee1
Author: Olivier Certner <olce@FreeBSD.org>
AuthorDate: 2024-07-19 09:54:35 +0000
Commit: Olivier Certner <olce@FreeBSD.org>
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 */