commit 7e59506b4b6c479cabc857bd79d89ec2b7dfe1e3
parent 784c6a5acffa7a0cba0b875b26e1c20db4a5613e
Author: sin <sin@2f30.org>
Date: Fri, 18 Oct 2013 11:20:59 +0100
Set SHELL environment variable by default
If target user is not root also set USER and LOGNAME.
Diffstat:
1 file changed, 5 insertions(+), 0 deletions(-)
diff --git a/su.c b/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;