summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1996-10-26 03:19:32 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1996-10-26 03:19:32 +0000
commit17a1133a529364681473c9f213308d5e117e019b (patch)
tree85b6edb09dc963a7ef72b8ce13d6b29118d9d566 /usr.bin
parentfc3490aa75dc59984a6e296723cb456489b677d9 (diff)
Now sets $LOGNAME as per POSIX.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/su/su.117
-rw-r--r--usr.bin/su/su.c8
2 files changed, 18 insertions, 7 deletions
diff --git a/usr.bin/su/su.1 b/usr.bin/su/su.1
index 293c981bc06..926303f0cb4 100644
--- a/usr.bin/su/su.1
+++ b/usr.bin/su/su.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: su.1,v 1.4 1996/10/12 20:40:38 millert Exp $
+.\" $OpenBSD: su.1,v 1.5 1996/10/26 03:19:30 millert Exp $
.\" Copyright (c) 1988, 1990 The Regents of the University of California.
.\" All rights reserved.
.\"
@@ -70,6 +70,7 @@ authenticated using the S/Key one-time password system as described in
S/Key is a Trademark of Bellcore.
.Pp
By default, the environment is unmodified with the exception of
+.Ev LOGNAME ,
.Ev USER ,
.Ev HOME ,
and
@@ -78,8 +79,10 @@ and
and
.Ev SHELL
are set to the target login's default values.
+.Ev LOGNAME
+and
.Ev USER
-is set to the target login, unless the target login has a user ID of 0,
+are set to the target login, unless the target login has a user ID of 0,
in which case it is unmodified.
The invoked shell is the target login's.
This is the traditional behavior of
@@ -102,14 +105,17 @@ The environment is discarded except for
.Ev SHELL ,
.Ev PATH ,
.Ev TERM ,
+.Ev LOGNAME ,
and
.Ev USER .
.Ev HOME
and
.Ev SHELL
are modified as above.
+.Ev LOGNAME
+and
.Ev USER
-is set to the target login.
+are set to the target login.
.Ev PATH
is set to
.Dq Pa /usr/bin:/bin .
@@ -202,10 +208,13 @@ Default search path of real user ID unless modified as specified above.
.It Ev TERM
Provides terminal type which may be retained for the substituted
user ID.
-.It Ev USER
+.It Ev LOGNAME
The user ID is always the effective ID (the target user ID) after an
.Nm su
unless the user ID is 0 (root).
+.It Ev USER
+Same as
+.Ev LOGNAME .
.El
.Sh HISTORY
A
diff --git a/usr.bin/su/su.c b/usr.bin/su/su.c
index 286c61a46e7..5dfa6a37e21 100644
--- a/usr.bin/su/su.c
+++ b/usr.bin/su/su.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: su.c,v 1.14 1996/10/23 01:28:57 millert Exp $ */
+/* $OpenBSD: su.c,v 1.15 1996/10/26 03:19:31 millert 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.14 1996/10/23 01:28:57 millert Exp $";
+static char rcsid[] = "$OpenBSD: su.c,v 1.15 1996/10/26 03:19:31 millert Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -241,8 +241,10 @@ badlogin:
seteuid(0);
setegid(0); /* XXX use a saved gid instead? */
}
- if (asthem || pwd->pw_uid)
+ if (asthem || pwd->pw_uid) {
+ (void)setenv("LOGNAME", pwd->pw_name, 1);
(void)setenv("USER", pwd->pw_name, 1);
+ }
(void)setenv("HOME", pwd->pw_dir, 1);
(void)setenv("SHELL", shell, 1);
}