summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1997-03-31 13:47:00 +0000
committerpeter <peter@FreeBSD.org>1997-03-31 13:47:00 +0000
commit77c35764071b794e0214cb7864df6894af5afdc4 (patch)
treed48923a6a6d6373cd441f69f487076dae924ab19 /sys/kern
parentf11bf14d6e9e593ba9595e75fdfe6e792d308eb8 (diff)
downloadFreeBSD-src-77c35764071b794e0214cb7864df6894af5afdc4.zip
FreeBSD-src-77c35764071b794e0214cb7864df6894af5afdc4.tar.gz
Do not set the P_SUGID flag in seteuid()/setegid() if nothing has changed.
(for supporting issetugid()) Reviewed by: ache (as was the previous commit, rev 1.29)
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_prot.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c
index becc3f6..b408029 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.28 1997/03/31 13:36:46 peter Exp $
+ * $Id: kern_prot.c,v 1.29 1997/03/31 13:41:49 peter Exp $
*/
/*
@@ -616,17 +616,21 @@ setreuid(p, uap, retval)
(error = suser(pc->pc_ucred, &p->p_acflag)))
return (error);
- pc->pc_ucred = crcopy(pc->pc_ucred);
- if (euid != (uid_t)-1)
+ if (euid != (uid_t)-1 && pc->pc_ucred->cr_uid != euid) {
+ pc->pc_ucred = crcopy(pc->pc_ucred);
pc->pc_ucred->cr_uid = euid;
- if (ruid != (uid_t)-1 && ruid != pc->p_ruid) {
+ p->p_flag |= P_SUGID;
+ }
+ if (ruid != (uid_t)-1 && pc->p_ruid != ruid) {
(void)chgproccnt(pc->p_ruid, -1);
(void)chgproccnt(ruid, 1);
pc->p_ruid = ruid;
+ p->p_flag |= P_SUGID;
}
- if (ruid != (uid_t)-1 || pc->pc_ucred->cr_uid != pc->p_ruid)
+ if (ruid != (uid_t)-1 || pc->pc_ucred->cr_uid != pc->p_ruid) {
pc->p_svuid = pc->pc_ucred->cr_uid;
- p->p_flag |= P_SUGID;
+ p->p_flag |= P_SUGID;
+ }
return (0);
}
@@ -654,14 +658,19 @@ setregid(p, uap, retval)
(error = suser(pc->pc_ucred, &p->p_acflag)))
return (error);
- pc->pc_ucred = crcopy(pc->pc_ucred);
- if (egid != (gid_t)-1)
+ if (egid != (gid_t)-1 && pc->pc_ucred->cr_groups[0] != egid) {
+ pc->pc_ucred = crcopy(pc->pc_ucred);
pc->pc_ucred->cr_groups[0] = egid;
- if (rgid != (gid_t)-1)
+ p->p_flag |= P_SUGID;
+ }
+ if (rgid != (gid_t)-1 && pc->p_rgid != rgid) {
pc->p_rgid = rgid;
- if (rgid != (gid_t)-1 || pc->pc_ucred->cr_groups[0] != pc->p_rgid)
+ p->p_flag |= P_SUGID;
+ }
+ if (rgid != (gid_t)-1 || pc->pc_ucred->cr_groups[0] != pc->p_rgid) {
pc->p_svgid = pc->pc_ucred->cr_groups[0];
- p->p_flag |= P_SUGID;
+ p->p_flag |= P_SUGID;
+ }
return (0);
}
OpenPOWER on IntegriCloud