From: Dave Reisner Date: Sun, 11 Mar 2012 04:54:14 +0000 (-0500) Subject: login: add USER to initial environment X-Git-Tag: v2.22-rc1~672 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fed52fd5ca5d42fcc0c60532e84f7159b22237ea;p=thirdparty%2Futil-linux.git login: add USER to initial environment Add this value from the passwd struct to the environment, as it is expected by shells, and generally useful to users. This also clarifies a poorly worded sentence in the vicinity of the manpage change. Signed-off-by: Dave Reisner --- diff --git a/login-utils/login.1 b/login-utils/login.1 index 26cd951acf..cb8024100d 100644 --- a/login-utils/login.1 +++ b/login-utils/login.1 @@ -40,10 +40,11 @@ for more information. The user and group ID will be set according to their values in the .I /etc/passwd file. There is one exception if the user ID is zero: in this case, -only the primary group ID of the account is set. This should prevent -that the system adminitrator cannot login in case of network problems. +only the primary group ID of the account is set. This should allow +the system adminitrator to login even in case of network problems. The value for .BR $HOME , +.BR $USER , .BR $SHELL , .BR $PATH , .BR $LOGNAME , diff --git a/login-utils/login.c b/login-utils/login.c index 4f448f8607..6c3b6f7091 100644 --- a/login-utils/login.c +++ b/login-utils/login.c @@ -1142,6 +1142,7 @@ static void init_environ(struct login_context *cxt) } setenv("HOME", pwd->pw_dir, 0); /* legal to override */ + setenv("USER", pwd->pw_name, 1); setenv("SHELL", pwd->pw_shell, 1); setenv("TERM", termenv, 1);