summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_prot.c
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1996-09-01 22:15:54 +0000
committerache <ache@FreeBSD.org>1996-09-01 22:15:54 +0000
commit25bbbe6b234fbc7bcf9f13758d4ec5e7243a6acf (patch)
treeab712124a769b457d92ecce67ff5fca1e089d9c3 /sys/kern/kern_prot.c
parent2baa7a7ec3b66a5bf7f6408818b815557cf30fdb (diff)
downloadFreeBSD-src-25bbbe6b234fbc7bcf9f13758d4ec5e7243a6acf.zip
FreeBSD-src-25bbbe6b234fbc7bcf9f13758d4ec5e7243a6acf.tar.gz
Conditionalize POSIX saved ids code on _POSIX_SAVED_IDS define
Diffstat (limited to 'sys/kern/kern_prot.c')
-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 e779a09..96cfc6d 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);
}
OpenPOWER on IntegriCloud