setup_environment: cd $HOME regardless of clear_env value.

This commit is contained in:
Denis Vlasenko 2008-10-30 23:58:19 +00:00
parent 91f8f82bfb
commit f34cfff2f0

View File

@ -32,9 +32,6 @@
void FAST_FUNC setup_environment(const char *shell, int clear_env, int change_env, const struct passwd *pw) void FAST_FUNC setup_environment(const char *shell, int clear_env, int change_env, const struct passwd *pw)
{ {
if (clear_env) {
const char *term;
/* Change the current working directory to be the home directory /* Change the current working directory to be the home directory
* of the user */ * of the user */
if (chdir(pw->pw_dir)) { if (chdir(pw->pw_dir)) {
@ -42,6 +39,9 @@ void FAST_FUNC setup_environment(const char *shell, int clear_env, int change_en
bb_error_msg("can't chdir to home directory '%s'", pw->pw_dir); bb_error_msg("can't chdir to home directory '%s'", pw->pw_dir);
} }
if (clear_env) {
const char *term;
/* Leave TERM unchanged. Set HOME, SHELL, USER, LOGNAME, PATH. /* Leave TERM unchanged. Set HOME, SHELL, USER, LOGNAME, PATH.
Unset all other environment variables. */ Unset all other environment variables. */
term = getenv("TERM"); term = getenv("TERM");