From 63ab78794ef71a08d97b6d4a56e5031a29e86e95 Mon Sep 17 00:00:00 2001 From: rwatson Date: Fri, 19 Apr 2002 13:35:53 +0000 Subject: Divorce proc0 and proc1 credentials earlier; while this isn't technically needed in the current code, in the MAC tree, create_init() relies on the ability to modify the credentials present for initproc, and should not perform that modification on a shared credential. Pro-active diff reduction against MAC changes that are in the queue; also facilitates other work, including the capabilities implementation. Submitted by: green Obtained from: TrustedBSD Project Sponsored by: DARPA, NAI Labs --- sys/kern/init_main.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'sys/kern/init_main.c') diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index 6904392..6e9793d 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -629,14 +629,21 @@ start_init(void *dummy) static void create_init(const void *udata __unused) { + struct ucred *newcred, *oldcred; int error; error = fork1(&thread0, RFFDG | RFPROC | RFSTOPPED, &initproc); if (error) panic("cannot fork init: %d\n", error); + /* divorce init's credentials from the kernel's */ + newcred = crget(); PROC_LOCK(initproc); initproc->p_flag |= P_SYSTEM; + oldcred = initproc->p_ucred; + crcopy(newcred, oldcred); + initproc->p_ucred = newcred; PROC_UNLOCK(initproc); + crfree(oldcred); mtx_lock_spin(&sched_lock); initproc->p_sflag |= PS_INMEM; mtx_unlock_spin(&sched_lock); -- cgit v1.1