aboutsummaryrefslogtreecommitdiff
path: root/libbb/setup_environment.c
diff options
context:
space:
mode:
Diffstat (limited to 'libbb/setup_environment.c')
-rw-r--r--libbb/setup_environment.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/libbb/setup_environment.c b/libbb/setup_environment.c
index df2983958..3549e2099 100644
--- a/libbb/setup_environment.c
+++ b/libbb/setup_environment.c
@@ -36,9 +36,8 @@ void FAST_FUNC setup_environment(const char *shell, int flags, const struct pass
36 36
37 /* Change the current working directory to be the home directory 37 /* Change the current working directory to be the home directory
38 * of the user */ 38 * of the user */
39 if (!(flags & SETUP_ENV_NO_CHDIR)) { 39 if (flags & SETUP_ENV_CHDIR) {
40 if (chdir(pw->pw_dir) != 0) { 40 if (chdir_or_warn(pw->pw_dir) != 0) {
41 bb_error_msg("can't change directory to '%s'", pw->pw_dir);
42 xchdir((flags & SETUP_ENV_TO_TMP) ? "/tmp" : "/"); 41 xchdir((flags & SETUP_ENV_TO_TMP) ? "/tmp" : "/");
43 } 42 }
44 } 43 }
@@ -59,7 +58,8 @@ void FAST_FUNC setup_environment(const char *shell, int flags, const struct pass
59 //xsetenv("LOGNAME", pw->pw_name); 58 //xsetenv("LOGNAME", pw->pw_name);
60 //xsetenv("HOME", pw->pw_dir); 59 //xsetenv("HOME", pw->pw_dir);
61 //xsetenv("SHELL", shell); 60 //xsetenv("SHELL", shell);
62 } else if (flags & SETUP_ENV_CHANGEENV) { 61 } else
62 if (flags & (SETUP_ENV_CHANGEENV|SETUP_ENV_CHANGEENV_LOGNAME)) {
63 /* Set HOME, SHELL, and if not becoming a super-user 63 /* Set HOME, SHELL, and if not becoming a super-user
64 * or if SETUP_ENV_CHANGEENV_LOGNAME, USER and LOGNAME. */ 64 * or if SETUP_ENV_CHANGEENV_LOGNAME, USER and LOGNAME. */
65 if ((flags & SETUP_ENV_CHANGEENV_LOGNAME) || pw->pw_uid != 0) { 65 if ((flags & SETUP_ENV_CHANGEENV_LOGNAME) || pw->pw_uid != 0) {