Make compatible interpretation of $USER.

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@6449 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Björn Groenvall
1999-07-12 10:25:22 +00:00
parent 67f97e9f4e
commit 20b62ed217

View File

@@ -2336,8 +2336,18 @@ tn(int argc, char **argv)
#endif
} while (connected == 0);
cmdrc(hostp, hostname);
if (autologin && user == NULL)
user = (char *)get_default_username ();
if (autologin && user == NULL) {
struct passwd *pw;
user = (char *)get_default_username();
if (user == NULL ||
((pw = k_getpwnam((char *)user)) && pw->pw_uid != getuid())) {
if ((pw = k_getpwuid(getuid())))
user = pw->pw_name;
else
user = NULL;
}
}
if (user) {
env_define((unsigned char *)"USER", (unsigned char *)user);
env_export((unsigned char *)"USER");