aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
Diffstat (limited to 'libbb')
-rw-r--r--libbb/setup_environment.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/libbb/setup_environment.c b/libbb/setup_environment.c
index 78318ce62..f0802f0e5 100644
--- a/libbb/setup_environment.c
+++ b/libbb/setup_environment.c
@@ -30,12 +30,12 @@
30 30
31#include "libbb.h" 31#include "libbb.h"
32 32
33void FAST_FUNC setup_environment(const char *shell, int clear_env, int change_env, const struct passwd *pw) 33void FAST_FUNC setup_environment(const char *shell, int clear_env, int flags, const struct passwd *pw)
34{ 34{
35 /* Change the current working directory to be the home directory 35 /* Change the current working directory to be the home directory
36 * of the user */ 36 * of the user */
37 if (chdir(pw->pw_dir)) { 37 if (chdir(pw->pw_dir)) {
38 xchdir("/"); 38 xchdir((flags & SETUP_ENV_TO_TMP) ? "/tmp" : "/");
39 bb_error_msg("can't chdir to home directory '%s'", pw->pw_dir); 39 bb_error_msg("can't chdir to home directory '%s'", pw->pw_dir);
40 } 40 }
41 41
@@ -55,8 +55,7 @@ void FAST_FUNC setup_environment(const char *shell, int clear_env, int change_en
55 //xsetenv("LOGNAME", pw->pw_name); 55 //xsetenv("LOGNAME", pw->pw_name);
56 //xsetenv("HOME", pw->pw_dir); 56 //xsetenv("HOME", pw->pw_dir);
57 //xsetenv("SHELL", shell); 57 //xsetenv("SHELL", shell);
58 } 58 } else if (flags & SETUP_ENV_CHANGEENV) {
59 else if (change_env) {
60 /* Set HOME, SHELL, and if not becoming a super-user, 59 /* Set HOME, SHELL, and if not becoming a super-user,
61 USER and LOGNAME. */ 60 USER and LOGNAME. */
62 if (pw->pw_uid) { 61 if (pw->pw_uid) {