summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--contrib/telnet/telnetd/sys_term.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/contrib/telnet/telnetd/sys_term.c b/contrib/telnet/telnetd/sys_term.c
index a7b0075..6d06b28 100644
--- a/contrib/telnet/telnetd/sys_term.c
+++ b/contrib/telnet/telnetd/sys_term.c
@@ -1,4 +1,4 @@
- /*
+/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
*
@@ -1026,6 +1026,10 @@ void
start_login(char *host undef1, int autologin undef1, char *name undef1)
{
char **argv;
+ char *user;
+
+ user = getenv("USER");
+ user = (user != NULL) ? strdup(user) : NULL;
scrub_env();
@@ -1160,9 +1164,9 @@ start_login(char *host undef1, int autologin undef1, char *name undef1)
# endif
} else
#endif
- if (getenv("USER")) {
+ if (user != NULL) {
argv = addarg(argv, "--");
- argv = addarg(argv, getenv("USER"));
+ argv = addarg(argv, user);
#if defined(LOGIN_ARGS) && defined(NO_LOGIN_P)
{
char **cpp;
@@ -1170,17 +1174,6 @@ start_login(char *host undef1, int autologin undef1, char *name undef1)
argv = addarg(argv, *cpp);
}
#endif
- /*
- * Assume that login will set the USER variable
- * correctly. For SysV systems, this means that
- * USER will no longer be set, just LOGNAME by
- * login. (The problem is that if the auto-login
- * fails, and the user then specifies a different
- * account name, he can get logged in with both
- * LOGNAME and USER in his environment, but the
- * USER value will be wrong.
- */
- unsetenv("USER");
}
#ifdef AUTHENTICATION
#if defined(NO_LOGIN_F) && defined(LOGIN_R)
@@ -1190,6 +1183,9 @@ start_login(char *host undef1, int autologin undef1, char *name undef1)
#endif /* AUTHENTICATION */
closelog();
+ if (user != NULL)
+ free(user);
+
if (altlogin == NULL) {
altlogin = _PATH_LOGIN;
}
OpenPOWER on IntegriCloud