From 115ccd8372f03e3ee23054252e381ee934b53f73 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Fri, 8 Aug 2003 21:47:49 +0000 Subject: [PATCH] Add a few missing cratom() calls. In particular the code in kern_exec() was modifying the svuid of the parent process when a child exec()'d, which broke the 'man' program (and probably other things). Reported-by: Jeroen Ruigrok/asmodai --- sys/kern/kern_exec.c | 10 +++++++--- sys/kern/kern_prot.c | 5 ++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 6a60c7dfee..28f8b03c62 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/kern/kern_exec.c,v 1.107.2.15 2002/07/30 15:40:46 nectar Exp $ - * $DragonFly: src/sys/kern/kern_exec.c,v 1.8 2003/07/24 01:41:25 dillon Exp $ + * $DragonFly: src/sys/kern/kern_exec.c,v 1.9 2003/08/08 21:47:49 dillon Exp $ */ #include @@ -345,8 +345,12 @@ interpret: /* * Implement correct POSIX saved-id behavior. */ - p->p_ucred->cr_svuid = p->p_ucred->cr_uid; - p->p_ucred->cr_svgid = p->p_ucred->cr_gid; + if (p->p_ucred->cr_svuid != p->p_ucred->cr_uid || + p->p_ucred->cr_svgid != p->p_ucred->cr_gid) { + cratom(&p->p_ucred); + p->p_ucred->cr_svuid = p->p_ucred->cr_uid; + p->p_ucred->cr_svgid = p->p_ucred->cr_gid; + } /* * Store the vp for use in procfs diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c index ad947bef1e..8974d28557 100644 --- a/sys/kern/kern_prot.c +++ b/sys/kern/kern_prot.c @@ -37,7 +37,7 @@ * * @(#)kern_prot.c 8.6 (Berkeley) 1/21/94 * $FreeBSD: src/sys/kern/kern_prot.c,v 1.53.2.9 2002/03/09 05:20:26 dd Exp $ - * $DragonFly: src/sys/kern/kern_prot.c,v 1.9 2003/07/30 00:19:14 dillon Exp $ + * $DragonFly: src/sys/kern/kern_prot.c,v 1.10 2003/08/08 21:47:49 dillon Exp $ */ /* @@ -364,6 +364,7 @@ setuid(struct setuid_args *uap) * is important that we should do this. */ if (cr->cr_svuid != uid) { + cr = cratom(&p->p_ucred); cr->cr_svuid = uid; setsugid(); } @@ -460,6 +461,7 @@ setgid(struct setgid_args *uap) * Set real gid */ if (cr->cr_rgid != gid) { + cr = cratom(&p->p_ucred); cr->cr_rgid = gid; setsugid(); } @@ -471,6 +473,7 @@ setgid(struct setgid_args *uap) * is important that we should do this. */ if (cr->cr_svgid != gid) { + cr = cratom(&p->p_ucred); cr->cr_svgid = gid; setsugid(); } -- 2.41.0