summaryrefslogtreecommitdiffstats
path: root/sys/kern/init_main.c
diff options
context:
space:
mode:
authorbdrewery <bdrewery@FreeBSD.org>2016-06-27 21:25:01 +0000
committerbdrewery <bdrewery@FreeBSD.org>2016-06-27 21:25:01 +0000
commite4df531a7e31e0ec865980e73ba644c49118d60a (patch)
tree2a84d42f9efccf5db9c09d2ae46b772274b15ae2 /sys/kern/init_main.c
parent2e698c8a838e8cc1cd41156fde4b69b1c4b6a89b (diff)
downloadFreeBSD-src-e4df531a7e31e0ec865980e73ba644c49118d60a.zip
FreeBSD-src-e4df531a7e31e0ec865980e73ba644c49118d60a.tar.gz
MFC r280130:
cred: add proc_set_cred helper
Diffstat (limited to 'sys/kern/init_main.c')
-rw-r--r--sys/kern/init_main.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c
index ae6bd3a..03a3d9e 100644
--- a/sys/kern/init_main.c
+++ b/sys/kern/init_main.c
@@ -437,6 +437,7 @@ proc0_init(void *dummy __unused)
{
struct proc *p;
struct thread *td;
+ struct ucred *newcred;
vm_paddr_t pageablemem;
int i;
@@ -513,19 +514,20 @@ proc0_init(void *dummy __unused)
callout_init(&td->td_slpcallout, CALLOUT_MPSAFE);
/* Create credentials. */
- p->p_ucred = crget();
- p->p_ucred->cr_ngroups = 1; /* group 0 */
- p->p_ucred->cr_uidinfo = uifind(0);
- p->p_ucred->cr_ruidinfo = uifind(0);
- p->p_ucred->cr_prison = &prison0;
- p->p_ucred->cr_loginclass = loginclass_find("default");
+ newcred = crget();
+ newcred->cr_ngroups = 1; /* group 0 */
+ newcred->cr_uidinfo = uifind(0);
+ newcred->cr_ruidinfo = uifind(0);
+ newcred->cr_prison = &prison0;
+ newcred->cr_loginclass = loginclass_find("default");
+ proc_set_cred(p, newcred);
#ifdef AUDIT
- audit_cred_kproc0(p->p_ucred);
+ audit_cred_kproc0(newcred);
#endif
#ifdef MAC
- mac_cred_create_swapper(p->p_ucred);
+ mac_cred_create_swapper(newcred);
#endif
- td->td_ucred = crhold(p->p_ucred);
+ td->td_ucred = crhold(newcred);
/* Create sigacts. */
p->p_sigacts = sigacts_alloc();
@@ -844,7 +846,7 @@ create_init(const void *udata __unused)
#ifdef AUDIT
audit_cred_proc1(newcred);
#endif
- initproc->p_ucred = newcred;
+ proc_set_cred(initproc, newcred);
PROC_UNLOCK(initproc);
sx_xunlock(&proctree_lock);
crfree(oldcred);
OpenPOWER on IntegriCloud