aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-10-30 23:58:19 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-10-30 23:58:19 +0000
commitf34cfff2f032ff8e475c97f69ea49a24f94b64f5 (patch)
tree1c30e984df9cb22a76bb467220667ad56c180d51
parent91f8f82bfb54a5e4a574112a86eb78cbd7b275cf (diff)
downloadbusybox-f34cfff2f032ff8e475c97f69ea49a24f94b64f5.tar.gz
setup_environment: cd $HOME regardless of clear_env value.
-rw-r--r--libbb/setup_environment.c14
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 @@
void FAST_FUNC setup_environment(const char *shell, int clear_env, int change_env, const struct passwd *pw)
{
+ /* Change the current working directory to be the home directory
+ * of the user */
+ if (chdir(pw->pw_dir)) {
+ xchdir("/");
+ bb_error_msg("can't chdir to home directory '%s'", pw->pw_dir);
+ }
+
if (clear_env) {
const char *term;
- /* Change the current working directory to be the home directory
- * of the user */
- if (chdir(pw->pw_dir)) {
- xchdir("/");
- bb_error_msg("can't chdir to home directory '%s'", pw->pw_dir);
- }
-
/* Leave TERM unchanged. Set HOME, SHELL, USER, LOGNAME, PATH.
Unset all other environment variables. */
term = getenv("TERM");