From 7e59506b4b6c479cabc857bd79d89ec2b7dfe1e3 Mon Sep 17 00:00:00 2001 From: sin Date: Fri, 18 Oct 2013 11:20:59 +0100 Subject: [PATCH] Set SHELL environment variable by default If target user is not root also set USER and LOGNAME. --- su.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/su.c b/su.c index 1435b30..9d8f550 100644 --- 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;