Set SHELL environment variable by default
If target user is not root also set USER and LOGNAME.
This commit is contained in:
parent
784c6a5acf
commit
7e59506b4b
5
su.c
5
su.c
@ -101,6 +101,11 @@ main(int argc, char **argv)
|
||||
} else {
|
||||
newargv = (char *const[]){pw->pw_shell, NULL};
|
||||
setenv("HOME", pw->pw_dir, 1);
|
||||
setenv("SHELL", pw->pw_dir, 1);
|
||||
if (strcmp(pw->pw_name, "root") != 0) {
|
||||
setenv("USER", pw->pw_name, 1);
|
||||
setenv("LOGNAME", pw->pw_name, 1);
|
||||
}
|
||||
execve(pw->pw_shell, newargv, environ);
|
||||
}
|
||||
return (errno == ENOENT) ? 127 : 126;
|
||||
|
Loading…
Reference in New Issue
Block a user