Set SHELL environment variable by default

If target user is not root also set USER and LOGNAME.
This commit is contained in:
sin 2013-10-18 11:20:59 +01:00
parent 784c6a5acf
commit 7e59506b4b

5
su.c
View File

@ -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;