Fix login(1) -p semantincs once and for all
This commit is contained in:
parent
d522589a11
commit
01fa8eec58
2
login.1
2
login.1
@ -5,7 +5,7 @@
|
||||
\fBlogin\fR [\fB-p\fR] \fIusername\fR
|
||||
.SH DESCRIPTION
|
||||
\fBlogin\fR logs the \fIusername\fR into the system. It sets \fBHOME\fR,
|
||||
\fBSHELL\fR, \fBUSER\fR, \fBLOGNAME\fR, \fBTERM\fR and the \fBPATH\fR environment
|
||||
\fBSHELL\fR, \fBUSER\fR, \fBLOGNAME\fR and the \fBPATH\fR environment
|
||||
variables and invokes the login shell as specified in \fI/etc/passwd\fR.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
|
11
login.c
11
login.c
@ -113,12 +113,11 @@ dologin(struct passwd *pw, int preserve)
|
||||
{
|
||||
if (preserve == 0)
|
||||
clearenv();
|
||||
setenv("HOME", pw->pw_dir, !preserve);
|
||||
setenv("SHELL", pw->pw_shell, !preserve);
|
||||
setenv("USER", pw->pw_name, !preserve);
|
||||
setenv("LOGNAME", pw->pw_name, !preserve);
|
||||
setenv("TERM", "linux", !preserve);
|
||||
setenv("PATH", ENV_PATH, !preserve);
|
||||
setenv("HOME", pw->pw_dir, 1);
|
||||
setenv("SHELL", pw->pw_shell, 1);
|
||||
setenv("USER", pw->pw_name, 1);
|
||||
setenv("LOGNAME", pw->pw_name, 1);
|
||||
setenv("PATH", ENV_PATH, 1);
|
||||
if (chdir(pw->pw_dir) < 0)
|
||||
eprintf("chdir %s:", pw->pw_dir);
|
||||
execlp(pw->pw_shell, pw->pw_shell, "-l", NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user