diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-09-10 17:15:28 +0400 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-09-10 17:15:28 +0400 |
commit | a2f61012b6f93473ed002e6609557cb1cd81b7dd (patch) | |
tree | 51ce422afbda2249a5de22e834ed04e200e0961f /libbb/setup_environment.c | |
parent | ac074b3f87cc22c2ddadb074d630156fea720744 (diff) |
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
Diffstat (limited to 'libbb/setup_environment.c')
-rw-r--r-- | libbb/setup_environment.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/libbb/setup_environment.c b/libbb/setup_environment.c index a6f44f7f0..19a2c6db5 100644 --- a/libbb/setup_environment.c +++ b/libbb/setup_environment.c @@ -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); } } |