diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c --- a/sys/kern/kern_prot.c +++ b/sys/kern/kern_prot.c @@ -1289,7 +1289,7 @@ /* * 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 --- a/sys/sys/ucred.h +++ b/sys/sys/ucred.h @@ -155,6 +155,17 @@ 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 */