summaryrefslogtreecommitdiffstats
path: root/sys/kern/init_main.c
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2002-04-19 13:35:53 +0000
committerrwatson <rwatson@FreeBSD.org>2002-04-19 13:35:53 +0000
commit63ab78794ef71a08d97b6d4a56e5031a29e86e95 (patch)
tree25e3bd3e29d95f141b84d5272a6928cce51c5a10 /sys/kern/init_main.c
parenta40e88df53bce30957e55480d910a8445d4399ae (diff)
downloadFreeBSD-src-63ab78794ef71a08d97b6d4a56e5031a29e86e95.zip
FreeBSD-src-63ab78794ef71a08d97b6d4a56e5031a29e86e95.tar.gz
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
Diffstat (limited to 'sys/kern/init_main.c')
-rw-r--r--sys/kern/init_main.c7
1 files changed, 7 insertions, 0 deletions
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);
OpenPOWER on IntegriCloud