MCPcopy Create free account
hub / github.com/F-Stack/f-stack / proc_set_cred

Function proc_set_cred

freebsd/kern/kern_prot.c:2179–2197  ·  view source on GitHub ↗

* Change process credentials. * Callers are responsible for providing the reference for passed credentials * and for freeing old ones. * * Process has to be locked except when it does not have credentials (as it * should not be visible just yet) or when newcred is NULL (as this can be * only used when the process is about to be freed, at which point it should * not be visible anymore). */

Source from the content-addressed store, hash-verified

2177 * not be visible anymore).
2178 */
2179void
2180proc_set_cred(struct proc *p, struct ucred *newcred)
2181{
2182 struct ucred *cr;
2183
2184 cr = p->p_ucred;
2185 MPASS(cr != NULL);
2186 PROC_LOCK_ASSERT(p, MA_OWNED);
2187 KASSERT(newcred->cr_users == 0, ("%s: users %d not 0 on cred %p",
2188 __func__, newcred->cr_users, newcred));
2189 mtx_lock(&cr->cr_mtx);
2190 KASSERT(cr->cr_users > 0, ("%s: users %d not > 0 on cred %p",
2191 __func__, cr->cr_users, cr));
2192 cr->cr_users--;
2193 mtx_unlock(&cr->cr_mtx);
2194 p->p_ucred = newcred;
2195 newcred->cr_users = 1;
2196 PROC_UPDATE_COW(p);
2197}
2198
2199void
2200proc_unset_cred(struct proc *p)

Callers 15

sys_auditonFunction · 0.85
sys_setauidFunction · 0.85
sys_setauditFunction · 0.85
sys_setaudit_addrFunction · 0.85
sys___mac_set_procFunction · 0.85
lomac_thread_userretFunction · 0.85
sys_cap_enterFunction · 0.85
do_jail_attachFunction · 0.85
sys_setloginclassFunction · 0.85
kern_prot.cFile · 0.85
sys_seteuidFunction · 0.85
sys_setegidFunction · 0.85

Calls 2

mtx_lockFunction · 0.70
mtx_unlockFunction · 0.70

Tested by

no test coverage detected