diff options
| -rw-r--r-- | libbb/setup_environment.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/libbb/setup_environment.c b/libbb/setup_environment.c index 04e333fed..78318ce62 100644 --- a/libbb/setup_environment.c +++ b/libbb/setup_environment.c | |||
| @@ -32,16 +32,16 @@ | |||
| 32 | 32 | ||
| 33 | void FAST_FUNC setup_environment(const char *shell, int clear_env, int change_env, const struct passwd *pw) | 33 | void FAST_FUNC setup_environment(const char *shell, int clear_env, int change_env, const struct passwd *pw) |
| 34 | { | 34 | { |
| 35 | /* Change the current working directory to be the home directory | ||
| 36 | * of the user */ | ||
| 37 | if (chdir(pw->pw_dir)) { | ||
| 38 | xchdir("/"); | ||
| 39 | bb_error_msg("can't chdir to home directory '%s'", pw->pw_dir); | ||
| 40 | } | ||
| 41 | |||
| 35 | if (clear_env) { | 42 | if (clear_env) { |
| 36 | const char *term; | 43 | const char *term; |
| 37 | 44 | ||
| 38 | /* Change the current working directory to be the home directory | ||
| 39 | * of the user */ | ||
| 40 | if (chdir(pw->pw_dir)) { | ||
| 41 | xchdir("/"); | ||
| 42 | bb_error_msg("can't chdir to home directory '%s'", pw->pw_dir); | ||
| 43 | } | ||
| 44 | |||
| 45 | /* Leave TERM unchanged. Set HOME, SHELL, USER, LOGNAME, PATH. | 45 | /* Leave TERM unchanged. Set HOME, SHELL, USER, LOGNAME, PATH. |
| 46 | Unset all other environment variables. */ | 46 | Unset all other environment variables. */ |
| 47 | term = getenv("TERM"); | 47 | term = getenv("TERM"); |
