summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey A. Chernov <ache@FreeBSD.org>1996-09-01 22:15:54 +0000
committerAndrey A. Chernov <ache@FreeBSD.org>1996-09-01 22:15:54 +0000
commit3f246666490cbfb6b7cb3307a19c5200e20f304c (patch)
treeab712124a769b457d92ecce67ff5fca1e089d9c3
parent3b1a310b4ba82d34bddf2e06b4b306e8f20fcb38 (diff)
Notes
-rw-r--r--sys/kern/kern_prot.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c
index e779a097e77e8..96cfc6db58233 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.16 1995/11/12 06:42:58 bde Exp $
+ * $Id: kern_prot.c,v 1.17 1996/05/30 01:21:50 davidg Exp $
*/
/*
@@ -311,7 +311,10 @@ setuid(p, uap, retval)
int error;
uid = uap->uid;
- if (uid != pc->p_ruid && uid != pc->p_svuid &&
+ if (uid != pc->p_ruid &&
+#ifdef _POSIX_SAVED_IDS
+ uid != pc->p_svuid &&
+#endif
(error = suser(pc->pc_ucred, &p->p_acflag)))
return (error);
/*
@@ -319,15 +322,23 @@ setuid(p, uap, retval)
* Transfer proc count to new user.
* Copy credentials so other references do not see our changes.
*/
- if (pc->pc_ucred->cr_uid == 0 && uid != pc->p_ruid) {
+ if (
+#ifdef _POSIX_SAVED_IDS
+ pc->pc_ucred->cr_uid == 0 &&
+#endif
+ uid != pc->p_ruid) {
(void)chgproccnt(pc->p_ruid, -1);
(void)chgproccnt(uid, 1);
}
pc->pc_ucred = crcopy(pc->pc_ucred);
+#ifdef _POSIX_SAVED_IDS
if (pc->pc_ucred->cr_uid == 0) {
+#endif
pc->p_ruid = uid;
pc->p_svuid = uid;
+#ifdef _POSIX_SAVED_IDS
}
+#endif
pc->pc_ucred->cr_uid = uid;
p->p_flag |= P_SUGID;
return (0);
@@ -380,15 +391,22 @@ setgid(p, uap, retval)
int error;
gid = uap->gid;
- if (gid != pc->p_rgid && gid != pc->p_svgid &&
+ if (gid != pc->p_rgid &&
+#ifdef _POSIX_SAVED_IDS
+ gid != pc->p_svgid &&
+#endif
(error = suser(pc->pc_ucred, &p->p_acflag)))
return (error);
pc->pc_ucred = crcopy(pc->pc_ucred);
pc->pc_ucred->cr_groups[0] = gid;
+#ifdef _POSIX_SAVED_IDS
if (pc->pc_ucred->cr_uid == 0) {
+#endif
pc->p_rgid = gid;
pc->p_svgid = gid;
+#ifdef _POSIX_SAVED_IDS
}
+#endif
p->p_flag |= P_SUGID;
return (0);
}