diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/kern_prot.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c index 814d06c8adeb..200d73195fbf 100644 --- a/sys/kern/kern_prot.c +++ b/sys/kern/kern_prot.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)kern_prot.c 8.6 (Berkeley) 1/21/94 - * $Id: kern_prot.c,v 1.9 1995/04/28 17:00:27 ache Exp $ + * $Id: kern_prot.c,v 1.10 1995/04/28 18:17:29 ache Exp $ */ /* @@ -261,24 +261,24 @@ setuid(p, uap, retval) int error; uid = uap->uid; - error = suser(pc->pc_ucred, &p->p_acflag); - if (uid != pc->p_ruid && uid != pc->p_svuid && error) + if (uid != pc->p_ruid && uid != pc->p_svuid && + (error = suser(pc->pc_ucred, &p->p_acflag))) return (error); /* * Everything's okay, do it. * Transfer proc count to new user. * Copy credentials so other references do not see our changes. */ - if (!error && uid != pc->p_ruid) { + if (pc->pc_ucred->cr_uid == 0 && uid != pc->p_ruid) { (void)chgproccnt(pc->p_ruid, -1); (void)chgproccnt(uid, 1); } pc->pc_ucred = crcopy(pc->pc_ucred); - pc->pc_ucred->cr_uid = uid; - if (!error) { + if (pc->pc_ucred->cr_uid == 0) { pc->p_ruid = uid; pc->p_svuid = uid; } + pc->pc_ucred->cr_uid = uid; p->p_flag |= P_SUGID; return (0); } @@ -326,12 +326,12 @@ setgid(p, uap, retval) int error; gid = uap->gid; - error = suser(pc->pc_ucred, &p->p_acflag); - if (gid != pc->p_rgid && gid != pc->p_svgid && error) + if (gid != pc->p_rgid && gid != pc->p_svgid && + (error = suser(pc->pc_ucred, &p->p_acflag))) return (error); pc->pc_ucred = crcopy(pc->pc_ucred); pc->pc_ucred->cr_groups[0] = gid; - if (!error) { + if (pc->pc_ucred->cr_uid == 0) { pc->p_rgid = gid; pc->p_svgid = gid; } |