setup_environment: code shrink
run_shell: mark as NORETURN setup_environment, run_shell: add usage comments login: add FIXME :( function old new delta UNSPEC_print 64 66 +2 sulogin_main 509 506 -3 mkfs_minix_main 3070 3067 -3 login_main 1615 1612 -3 su_main 461 448 -13 setup_environment 261 206 -55 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/5 up/down: 2/-77) Total: -75 bytes text data bss dec hex filename 772578 1051 10724 784353 bf7e1 busybox_old 772502 1051 10724 784277 bf795 busybox_unstripped
This commit is contained in:
@ -36,36 +36,35 @@ void setup_environment(const char *shell, int loginshell, int changeenv, const s
|
||||
const char *term;
|
||||
|
||||
/* Change the current working directory to be the home directory
|
||||
* of the user. It is a fatal error for this process to be unable
|
||||
* to change to that directory. There is no "default" home
|
||||
* directory.
|
||||
* Some systems default to HOME=/
|
||||
*/
|
||||
* of the user */
|
||||
if (chdir(pw->pw_dir)) {
|
||||
xchdir("/");
|
||||
fputs("warning: cannot change to home directory\n", stderr);
|
||||
}
|
||||
|
||||
/* Leave TERM unchanged. Set HOME, SHELL, USER, LOGNAME, PATH.
|
||||
/* Leave TERM unchanged. Set HOME, SHELL, USER, LOGNAME, PATH.
|
||||
Unset all other environment variables. */
|
||||
term = getenv("TERM");
|
||||
clearenv();
|
||||
if (term)
|
||||
xsetenv("TERM", term);
|
||||
xsetenv("HOME", pw->pw_dir);
|
||||
xsetenv("SHELL", shell);
|
||||
xsetenv("USER", pw->pw_name);
|
||||
xsetenv("LOGNAME", pw->pw_name);
|
||||
xsetenv("PATH", (pw->pw_uid ? bb_default_path : bb_default_root_path));
|
||||
xsetenv("PATH", (pw->pw_uid ? bb_default_path : bb_default_root_path));
|
||||
goto shortcut;
|
||||
// No, gcc (4.2.1) is not clever enougn to do it itself.
|
||||
//xsetenv("USER", pw->pw_name);
|
||||
//xsetenv("LOGNAME", pw->pw_name);
|
||||
//xsetenv("HOME", pw->pw_dir);
|
||||
//xsetenv("SHELL", shell);
|
||||
}
|
||||
else if (changeenv) {
|
||||
/* Set HOME, SHELL, and if not becoming a super-user,
|
||||
USER and LOGNAME. */
|
||||
xsetenv("HOME", pw->pw_dir);
|
||||
xsetenv("SHELL", shell);
|
||||
if (pw->pw_uid) {
|
||||
shortcut:
|
||||
xsetenv("USER", pw->pw_name);
|
||||
xsetenv("LOGNAME", pw->pw_name);
|
||||
}
|
||||
xsetenv("HOME", pw->pw_dir);
|
||||
xsetenv("SHELL", shell);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user