Ignore:
Timestamp:
Feb 25, 2011, 9:26:54 PM (13 years ago)
Author:
Bruno Cornec
Message:
  • Update mindi-busybox to 1.18.3 to avoid problems with the tar command which is now failing on recent versions with busybox 1.7.3
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.9/mindi-busybox/libbb/setup_environment.c

    r1765 r2725  
    3131#include "libbb.h"
    3232
    33 void setup_environment(const char *shell, int loginshell, int changeenv, const struct passwd *pw)
     33void FAST_FUNC setup_environment(const char *shell, int flags, const struct passwd *pw)
    3434{
    35     if (loginshell) {
     35    /* Change the current working directory to be the home directory
     36     * of the user */
     37    if (chdir(pw->pw_dir)) {
     38        xchdir((flags & SETUP_ENV_TO_TMP) ? "/tmp" : "/");
     39        bb_error_msg("can't chdir to home directory '%s'", pw->pw_dir);
     40    }
     41
     42    if (flags & SETUP_ENV_CLEARENV) {
    3643        const char *term;
    3744
    38         /* Change the current working directory to be the home directory
    39          * of the user.  It is a fatal error for this process to be unable
    40          * to change to that directory.  There is no "default" home
    41          * directory.
    42          * Some systems default to HOME=/
    43          */
    44         if (chdir(pw->pw_dir)) {
    45             xchdir("/");
    46             fputs("warning: cannot change to home directory\n", stderr);
    47         }
    48 
    49         /* Leave TERM unchanged.  Set HOME, SHELL, USER, LOGNAME, PATH.
    50            Unset all other environment variables.  */
     45        /* Leave TERM unchanged. Set HOME, SHELL, USER, LOGNAME, PATH.
     46         * Unset all other environment variables.  */
    5147        term = getenv("TERM");
    5248        clearenv();
    5349        if (term)
    5450            xsetenv("TERM", term);
    55         xsetenv("HOME",    pw->pw_dir);
    56         xsetenv("SHELL",   shell);
    57         xsetenv("USER",    pw->pw_name);
    58         xsetenv("LOGNAME", pw->pw_name);
    59         xsetenv("PATH",   (pw->pw_uid ? bb_default_path : bb_default_root_path));
    60     }
    61     else if (changeenv) {
     51        xsetenv("PATH", (pw->pw_uid ? bb_default_path : bb_default_root_path));
     52        goto shortcut;
     53        // No, gcc (4.2.1) is not clever enougn to do it itself.
     54        //xsetenv("USER",    pw->pw_name);
     55        //xsetenv("LOGNAME", pw->pw_name);
     56        //xsetenv("HOME",    pw->pw_dir);
     57        //xsetenv("SHELL",   shell);
     58    } else if (flags & SETUP_ENV_CHANGEENV) {
    6259        /* Set HOME, SHELL, and if not becoming a super-user,
    63            USER and LOGNAME.  */
    64         xsetenv("HOME",  pw->pw_dir);
    65         xsetenv("SHELL", shell);
     60         * USER and LOGNAME.  */
    6661        if (pw->pw_uid) {
     62 shortcut:
    6763            xsetenv("USER",    pw->pw_name);
    6864            xsetenv("LOGNAME", pw->pw_name);
    6965        }
     66        xsetenv("HOME",    pw->pw_dir);
     67        xsetenv("SHELL",   shell);
    7068    }
    7169}
Note: See TracChangeset for help on using the changeset viewer.