Skip to contentSkip to conversation

login: add USER to initial environment

PATCH Applied Dave Reisner 2 participants 2 messages Mar 11, 2012 – Mar 13, 2012 Util-Linux package

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 login-utils/login.1 |    5 +++--
 login-utils/login.c |    1 +
 2 files changed, 4 insertions(+), 2 deletions(-)
login-utils/login.1 +3 -2
index 26cd951..cb80241 100644
@@ -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 ,
login-utils/login.c +1 -0
index 4f448f8..6c3b6f7 100644
@@ -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);
 
Signature · 1 line
1.7.9.3
maintainer Applied
#1 lore raw
Quoted 3 lines · Dave Reisner
 login-utils/login.1 |    5 +++--
 login-utils/login.c |    1 +
 2 files changed, 4 insertions(+), 2 deletions(-)

Applied, thanks.

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com