git: 6369544278b2 - main - cred: Make group_is_supplementary() public; New group_is_primary()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 02 Nov 2024 20:39:28 UTC
The branch main has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=6369544278b2e4fb5203b10dab466ff7c72c0a25 commit 6369544278b2e4fb5203b10dab466ff7c72c0a25 Author: Olivier Certner <olce@FreeBSD.org> AuthorDate: 2024-07-19 09:54:35 +0000 Commit: Olivier Certner <olce@FreeBSD.org> 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 */