Lines Matching refs:cr
91 static void crsetgroups_locked(struct ucred *cr, int ngrp,
1310 securelevel_gt(struct ucred *cr, int level) in securelevel_gt() argument
1313 return (cr->cr_prison->pr_securelevel > level ? EPERM : 0); in securelevel_gt()
1317 securelevel_ge(struct ucred *cr, int level) in securelevel_ge() argument
1320 return (cr->cr_prison->pr_securelevel >= level ? EPERM : 0); in securelevel_ge()
1806 register struct ucred *cr; in crget() local
1808 cr = malloc(sizeof(*cr), M_CRED, M_WAITOK | M_ZERO); in crget()
1809 refcount_init(&cr->cr_ref, 1); in crget()
1811 audit_cred_init(cr); in crget()
1814 mac_cred_init(cr); in crget()
1816 crextend(cr, XU_NGROUPS); in crget()
1817 return (cr); in crget()
1824 crhold(struct ucred *cr) in crhold() argument
1827 refcount_acquire(&cr->cr_ref); in crhold()
1828 return (cr); in crhold()
1835 crfree(struct ucred *cr) in crfree() argument
1838 KASSERT(cr->cr_ref > 0, ("bad ucred refcount: %d", cr->cr_ref)); in crfree()
1839 KASSERT(cr->cr_ref != 0xdeadc0de, ("dangling reference to ucred")); in crfree()
1840 if (refcount_release(&cr->cr_ref)) { in crfree()
1846 if (cr->cr_uidinfo != NULL) in crfree()
1847 uifree(cr->cr_uidinfo); in crfree()
1848 if (cr->cr_ruidinfo != NULL) in crfree()
1849 uifree(cr->cr_ruidinfo); in crfree()
1853 if (cr->cr_prison != NULL) in crfree()
1854 prison_free(cr->cr_prison); in crfree()
1855 if (cr->cr_loginclass != NULL) in crfree()
1856 loginclass_free(cr->cr_loginclass); in crfree()
1858 audit_cred_destroy(cr); in crfree()
1861 mac_cred_destroy(cr); in crfree()
1863 free(cr->cr_groups, M_CRED); in crfree()
1864 free(cr, M_CRED); in crfree()
1872 crshared(struct ucred *cr) in crshared() argument
1875 return (cr->cr_ref > 1); in crshared()
1906 crdup(struct ucred *cr) in crdup() argument
1911 crcopy(newcr, cr); in crdup()
1919 cru2x(struct ucred *cr, struct xucred *xcr) in cru2x() argument
1925 xcr->cr_uid = cr->cr_uid; in cru2x()
1927 ngroups = MIN(cr->cr_ngroups, XU_NGROUPS); in cru2x()
1929 bcopy(cr->cr_groups, xcr->cr_groups, in cru2x()
1930 ngroups * sizeof(*cr->cr_groups)); in cru2x()
1953 crcopysafe(struct proc *p, struct ucred *cr) in crcopysafe() argument
1961 while (cr->cr_agroups < oldcred->cr_agroups) { in crcopysafe()
1964 crextend(cr, groups); in crcopysafe()
1968 crcopy(cr, oldcred); in crcopysafe()
1977 crextend(struct ucred *cr, int n) in crextend() argument
1982 if (n <= cr->cr_agroups) in crextend()
1995 if (cr->cr_agroups == 0) in crextend()
1998 cnt = cr->cr_agroups * 2; in crextend()
2006 if (cr->cr_groups) in crextend()
2007 free(cr->cr_groups, M_CRED); in crextend()
2009 cr->cr_groups = malloc(cnt * sizeof(gid_t), M_CRED, M_WAITOK | M_ZERO); in crextend()
2010 cr->cr_agroups = cnt; in crextend()
2020 crsetgroups_locked(struct ucred *cr, int ngrp, gid_t *groups) in crsetgroups_locked() argument
2026 KASSERT(cr->cr_agroups >= ngrp, ("cr_ngroups is too small")); in crsetgroups_locked()
2028 bcopy(groups, cr->cr_groups, ngrp * sizeof(gid_t)); in crsetgroups_locked()
2029 cr->cr_ngroups = ngrp; in crsetgroups_locked()
2040 g = cr->cr_groups[i]; in crsetgroups_locked()
2041 for (j = i-1; j >= 1 && g < cr->cr_groups[j]; j--) in crsetgroups_locked()
2042 cr->cr_groups[j + 1] = cr->cr_groups[j]; in crsetgroups_locked()
2043 cr->cr_groups[j + 1] = g; in crsetgroups_locked()
2052 crsetgroups(struct ucred *cr, int ngrp, gid_t *groups) in crsetgroups() argument
2058 crextend(cr, ngrp); in crsetgroups()
2059 crsetgroups_locked(cr, ngrp, groups); in crsetgroups()