Lines Matching refs:ngrp
99 groups_check_positive_len(int ngrp) in groups_check_positive_len() argument
101 MPASS2(ngrp >= 0, "negative number of groups"); in groups_check_positive_len()
102 MPASS2(ngrp != 0, "at least one group expected (effective GID)"); in groups_check_positive_len()
105 groups_check_max_len(int ngrp) in groups_check_max_len() argument
107 MPASS2(ngrp <= ngroups_max + 1, "too many groups"); in groups_check_max_len()
110 static void groups_normalize(int *ngrp, gid_t *groups);
111 static void crsetgroups_internal(struct ucred *cr, int ngrp,
324 int ngrp, error; in sys_getgroups() local
327 ngrp = cred->cr_ngroups; in sys_getgroups()
333 if (uap->gidsetsize < ngrp) in sys_getgroups()
336 error = copyout(cred->cr_groups, uap->gidset, ngrp * sizeof(gid_t)); in sys_getgroups()
338 td->td_retval[0] = ngrp; in sys_getgroups()
729 int ngrp = wcred->sc_supp_groups_nb; in kern_setcred() local
735 AUDIT_ARG_GROUPSET(groups + 1, ngrp); in kern_setcred()
736 ++ngrp; in kern_setcred()
737 groups_normalize(&ngrp, groups); in kern_setcred()
738 wcred->sc_supp_groups_nb = ngrp - 1; in kern_setcred()
1235 int ngrp, error; in kern_setgroups() local
1237 ngrp = *ngrpp; in kern_setgroups()
1239 if (ngrp < 0 || ngrp > ngroups_max + 1) in kern_setgroups()
1242 AUDIT_ARG_GROUPSET(groups, ngrp); in kern_setgroups()
1243 if (ngrp != 0) { in kern_setgroups()
1246 ngrp = *ngrpp; in kern_setgroups()
1249 if (ngrp != 0) in kern_setgroups()
1250 crextend(newcred, ngrp); in kern_setgroups()
1255 error = ngrp == 0 ? in kern_setgroups()
1258 mac_cred_check_setgroups(oldcred, ngrp, groups); in kern_setgroups()
1267 if (ngrp == 0) { in kern_setgroups()
1276 crsetgroups_internal(newcred, ngrp, groups); in kern_setgroups()
1689 groups_check_normalized(int ngrp, const gid_t *groups) in groups_check_normalized() argument
1693 groups_check_positive_len(ngrp); in groups_check_normalized()
1694 groups_check_max_len(ngrp); in groups_check_normalized()
1696 if (ngrp == 1) in groups_check_normalized()
1700 for (int i = 2; i < ngrp; ++i) { in groups_check_normalized()
2806 groups_normalize(int *ngrp, gid_t *groups) in groups_normalize() argument
2811 groups_check_positive_len(*ngrp); in groups_normalize()
2812 groups_check_max_len(*ngrp); in groups_normalize()
2814 if (*ngrp == 1) in groups_normalize()
2817 qsort(groups + 1, *ngrp - 1, sizeof(*groups), gidp_cmp); in groups_normalize()
2822 for (int i = 2; i < *ngrp; ++i) { in groups_normalize()
2832 *ngrp = ins_idx; in groups_normalize()
2834 groups_check_normalized(*ngrp, groups); in groups_normalize()
2850 crsetgroups_internal(struct ucred *cr, int ngrp, const gid_t *groups) in crsetgroups_internal() argument
2854 MPASS2(cr->cr_agroups >= ngrp, "'cr_agroups' too small"); in crsetgroups_internal()
2855 groups_check_positive_len(ngrp); in crsetgroups_internal()
2857 bcopy(groups, cr->cr_groups, ngrp * sizeof(gid_t)); in crsetgroups_internal()
2858 cr->cr_ngroups = ngrp; in crsetgroups_internal()
2870 crsetgroups(struct ucred *cr, int ngrp, const gid_t *groups) in crsetgroups() argument
2873 if (ngrp > ngroups_max + 1) in crsetgroups()
2874 ngrp = ngroups_max + 1; in crsetgroups()
2882 crextend(cr, ngrp); in crsetgroups()
2883 crsetgroups_internal(cr, ngrp, groups); in crsetgroups()
2895 crsetgroups_fallback(struct ucred *cr, int ngrp, const gid_t *groups, in crsetgroups_fallback() argument
2898 if (ngrp == 0) in crsetgroups_fallback()
2902 crsetgroups(cr, ngrp, groups); in crsetgroups_fallback()