traceroute: fix help text to not show -6 when traceroute6 is off
[oweals/busybox.git] / libbb / setup_environment.c
index 19a2c6db5aeac6497647b34fa543a3e3778978c8..78318ce62f24da4187f0a29688b5255669188036 100644 (file)
 
 #include "libbb.h"
 
-void setup_environment(const char *shell, int loginshell, int changeenv, const struct passwd *pw)
+void FAST_FUNC setup_environment(const char *shell, int clear_env, int change_env, const struct passwd *pw)
 {
-       if (loginshell) {
-               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);
+       }
 
-               /* Change the current working directory to be the home directory
-                * of the user */
-               if (chdir(pw->pw_dir)) {
-                       xchdir("/");
-                       fputs("warning: cannot change to home directory\n", stderr);
-               }
+       if (clear_env) {
+               const char *term;
 
                /* Leave TERM unchanged. Set HOME, SHELL, USER, LOGNAME, PATH.
                   Unset all other environment variables.  */
@@ -56,7 +56,7 @@ void setup_environment(const char *shell, int loginshell, int changeenv, const s
                //xsetenv("HOME",    pw->pw_dir);
                //xsetenv("SHELL",   shell);
        }
-       else if (changeenv) {
+       else if (change_env) {
                /* Set HOME, SHELL, and if not becoming a super-user,
                   USER and LOGNAME.  */
                if (pw->pw_uid) {