summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libexec/rexecd/rexecd.c7
-rw-r--r--libexec/rshd/rshd.c7
-rw-r--r--usr.bin/su/su.c9
3 files changed, 19 insertions, 4 deletions
diff --git a/libexec/rexecd/rexecd.c b/libexec/rexecd/rexecd.c
index e7062fed397..32caa98687b 100644
--- a/libexec/rexecd/rexecd.c
+++ b/libexec/rexecd/rexecd.c
@@ -39,7 +39,7 @@ char copyright[] =
#ifndef lint
/*static char sccsid[] = "from: @(#)rexecd.c 5.12 (Berkeley) 2/25/91";*/
-static char rcsid[] = "$Id: rexecd.c,v 1.2 1996/05/26 08:34:56 deraadt Exp $";
+static char rcsid[] = "$Id: rexecd.c,v 1.3 1996/07/22 01:59:20 deraadt Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -161,10 +161,15 @@ doit(f, fromp)
exit(1);
}
}
+ setegid(pwd->pw_gid);
+ seteuid(pwd->pw_uid);
if (chdir(pwd->pw_dir) < 0) {
error("No remote directory.\n");
exit(1);
}
+ seteuid(0);
+ setegid(0); /* XXX use a saved gid instead? */
+
(void) write(2, "\0", 1);
if (port) {
(void) pipe(pv);
diff --git a/libexec/rshd/rshd.c b/libexec/rshd/rshd.c
index dd9f251ca79..ce9a3288c8b 100644
--- a/libexec/rshd/rshd.c
+++ b/libexec/rshd/rshd.c
@@ -39,7 +39,7 @@ static char copyright[] =
#ifndef lint
/* from: static char sccsid[] = "@(#)rshd.c 8.2 (Berkeley) 4/6/94"; */
-static char *rcsid = "$Id: rshd.c,v 1.4 1996/04/17 07:20:01 tholo Exp $";
+static char *rcsid = "$Id: rshd.c,v 1.5 1996/07/22 01:59:10 deraadt Exp $";
#endif /* not lint */
/*
@@ -426,6 +426,9 @@ doit(fromp)
errorstr = "Login incorrect.\n";
goto fail;
}
+
+ setegid(pwd->pw_gid);
+ seteuid(pwd->pw_uid);
if (chdir(pwd->pw_dir) < 0) {
(void) chdir("/");
#ifdef notdef
@@ -436,6 +439,8 @@ doit(fromp)
exit(1);
#endif
}
+ seteuid(0);
+ setegid(0); /* XXX use a saved gid instead? */
#ifdef KERBEROS
if (use_kerberos) {
diff --git a/usr.bin/su/su.c b/usr.bin/su/su.c
index 56b3b30d7b9..59321be1cce 100644
--- a/usr.bin/su/su.c
+++ b/usr.bin/su/su.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: su.c,v 1.4 1996/06/26 05:39:34 deraadt Exp $ */
+/* $OpenBSD: su.c,v 1.5 1996/07/22 01:58:55 deraadt Exp $ */
/*
* Copyright (c) 1988 The Regents of the University of California.
@@ -41,7 +41,7 @@ char copyright[] =
#ifndef lint
/*static char sccsid[] = "from: @(#)su.c 5.26 (Berkeley) 7/6/91";*/
-static char rcsid[] = "$OpenBSD: su.c,v 1.4 1996/06/26 05:39:34 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: su.c,v 1.5 1996/07/22 01:58:55 deraadt Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -242,10 +242,15 @@ badlogin:
environ = cleanenv;
(void)setenv("PATH", _PATH_DEFPATH, 1);
(void)setenv("TERM", p, 1);
+
+ seteuid(pwd->pw_uid);
+ setegid(pwd->pw_gid);
if (chdir(pwd->pw_dir) < 0) {
fprintf(stderr, "su: no directory\n");
exit(1);
}
+ seteuid(0);
+ setegid(0); /* XXX use a saved gid instead? */
}
if (asthem || pwd->pw_uid)
(void)setenv("USER", pwd->pw_name, 1);