diff options
Diffstat (limited to 'shell/ash.c')
-rw-r--r-- | shell/ash.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/shell/ash.c b/shell/ash.c index d78c6e828..1eddec4ea 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -15550,7 +15550,7 @@ exitshell(void) | |||
15550 | # undef getenv | 15550 | # undef getenv |
15551 | static void xsetenv_if_unset(const char *key, const char *value) | 15551 | static void xsetenv_if_unset(const char *key, const char *value) |
15552 | { | 15552 | { |
15553 | if (!getenv(key)) | 15553 | if (!getenv(key) || getuid() == 0) |
15554 | xsetenv(key, value); | 15554 | xsetenv(key, value); |
15555 | } | 15555 | } |
15556 | #endif | 15556 | #endif |
@@ -15641,12 +15641,13 @@ init(void) | |||
15641 | } | 15641 | } |
15642 | 15642 | ||
15643 | /* Initialise some variables normally set at login, but | 15643 | /* Initialise some variables normally set at login, but |
15644 | * only if someone hasn't already set them. */ | 15644 | * only if someone hasn't already set them or we're root. */ |
15645 | pw = getpwuid(getuid()); | 15645 | pw = getpwuid(getuid()); |
15646 | if (pw) { | 15646 | if (pw) { |
15647 | xsetenv_if_unset("USER", pw->pw_name); | 15647 | xsetenv_if_unset("USER", pw->pw_name); |
15648 | xsetenv_if_unset("LOGNAME", pw->pw_name); | 15648 | xsetenv_if_unset("USERNAME", pw->pw_name); |
15649 | xsetenv_if_unset("HOME", pw->pw_dir); | 15649 | xsetenv_if_unset("LOGNAME", pw->pw_name); |
15650 | xsetenv_if_unset("HOME", pw->pw_dir); | ||
15650 | } | 15651 | } |
15651 | xsetenv_if_unset("SHELL", DEFAULT_SHELL); | 15652 | xsetenv_if_unset("SHELL", DEFAULT_SHELL); |
15652 | } | 15653 | } |