diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-02-26 09:52:45 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-02-26 09:52:45 +0100 |
commit | fd686a262fa34b71900b010b4b31d7e2e3f3385c (patch) | |
tree | 102c38699d6d732ed0f5bc2e478a824e59a59f75 | |
parent | 99709ab03387ca623e3fc1cac69d242ed44da45c (diff) | |
download | busybox-w32-fd686a262fa34b71900b010b4b31d7e2e3f3385c.tar.gz busybox-w32-fd686a262fa34b71900b010b4b31d7e2e3f3385c.tar.bz2 busybox-w32-fd686a262fa34b71900b010b4b31d7e2e3f3385c.zip |
setup_environment(): eliminate one parameter
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | include/libbb.h | 7 | ||||
-rw-r--r-- | libbb/setup_environment.c | 4 | ||||
-rw-r--r-- | loginutils/login.c | 5 | ||||
-rw-r--r-- | loginutils/su.c | 6 | ||||
-rw-r--r-- | miscutils/crontab.c | 5 |
5 files changed, 16 insertions, 11 deletions
diff --git a/include/libbb.h b/include/libbb.h index 9d99b0d1a..98080e841 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -1156,9 +1156,10 @@ extern int restricted_shell(const char *shell) FAST_FUNC; | |||
1156 | * SHELL=shell | 1156 | * SHELL=shell |
1157 | * else does nothing | 1157 | * else does nothing |
1158 | */ | 1158 | */ |
1159 | #define SETUP_ENV_CHANGEENV (1<<0) | 1159 | #define SETUP_ENV_CHANGEENV (1 << 0) |
1160 | #define SETUP_ENV_TO_TMP (1<<1) | 1160 | #define SETUP_ENV_CLEARENV (1 << 1) |
1161 | extern void setup_environment(const char *shell, int clear_env, int flags, const struct passwd *pw) FAST_FUNC; | 1161 | #define SETUP_ENV_TO_TMP (1 << 2) |
1162 | extern void setup_environment(const char *shell, int flags, const struct passwd *pw) FAST_FUNC; | ||
1162 | extern int correct_password(const struct passwd *pw) FAST_FUNC; | 1163 | extern int correct_password(const struct passwd *pw) FAST_FUNC; |
1163 | /* Returns a malloced string */ | 1164 | /* Returns a malloced string */ |
1164 | #if !ENABLE_USE_BB_CRYPT | 1165 | #if !ENABLE_USE_BB_CRYPT |
diff --git a/libbb/setup_environment.c b/libbb/setup_environment.c index f0802f0e5..13e60d8e4 100644 --- a/libbb/setup_environment.c +++ b/libbb/setup_environment.c | |||
@@ -30,7 +30,7 @@ | |||
30 | 30 | ||
31 | #include "libbb.h" | 31 | #include "libbb.h" |
32 | 32 | ||
33 | void FAST_FUNC setup_environment(const char *shell, int clear_env, int flags, const struct passwd *pw) | 33 | void FAST_FUNC setup_environment(const char *shell, int flags, const struct passwd *pw) |
34 | { | 34 | { |
35 | /* Change the current working directory to be the home directory | 35 | /* Change the current working directory to be the home directory |
36 | * of the user */ | 36 | * of the user */ |
@@ -39,7 +39,7 @@ void FAST_FUNC setup_environment(const char *shell, int clear_env, int flags, co | |||
39 | bb_error_msg("can't chdir to home directory '%s'", pw->pw_dir); | 39 | bb_error_msg("can't chdir to home directory '%s'", pw->pw_dir); |
40 | } | 40 | } |
41 | 41 | ||
42 | if (clear_env) { | 42 | if (flags & SETUP_ENV_CLEARENV) { |
43 | const char *term; | 43 | const char *term; |
44 | 44 | ||
45 | /* Leave TERM unchanged. Set HOME, SHELL, USER, LOGNAME, PATH. | 45 | /* Leave TERM unchanged. Set HOME, SHELL, USER, LOGNAME, PATH. |
diff --git a/loginutils/login.c b/loginutils/login.c index 974125d88..b5e348b66 100644 --- a/loginutils/login.c +++ b/loginutils/login.c | |||
@@ -477,8 +477,9 @@ int login_main(int argc UNUSED_PARAM, char **argv) | |||
477 | tmp = pw->pw_shell; | 477 | tmp = pw->pw_shell; |
478 | if (!tmp || !*tmp) | 478 | if (!tmp || !*tmp) |
479 | tmp = DEFAULT_SHELL; | 479 | tmp = DEFAULT_SHELL; |
480 | /* setup_environment params: shell, clear_env, change_env, pw */ | 480 | setup_environment(tmp, |
481 | setup_environment(tmp, !(opt & LOGIN_OPT_p), SETUP_ENV_CHANGEENV, pw); | 481 | (!(opt & LOGIN_OPT_p) * SETUP_ENV_CLEARENV) + SETUP_ENV_CHANGEENV, |
482 | pw); | ||
482 | 483 | ||
483 | motd(); | 484 | motd(); |
484 | 485 | ||
diff --git a/loginutils/su.c b/loginutils/su.c index a3f7ed8a0..6356631b8 100644 --- a/loginutils/su.c +++ b/loginutils/su.c | |||
@@ -102,8 +102,10 @@ int su_main(int argc UNUSED_PARAM, char **argv) | |||
102 | opt_shell = pw->pw_shell; | 102 | opt_shell = pw->pw_shell; |
103 | 103 | ||
104 | change_identity(pw); | 104 | change_identity(pw); |
105 | /* setup_environment params: shell, clear_env, change_env, pw */ | 105 | setup_environment(opt_shell, |
106 | setup_environment(opt_shell, flags & SU_OPT_l, !(flags & SU_OPT_mp), pw); | 106 | ((flags & SU_OPT_l) / SU_OPT_l * SETUP_ENV_CLEARENV) |
107 | + (!(flags & SU_OPT_mp) * SETUP_ENV_CHANGEENV), | ||
108 | pw); | ||
107 | IF_SELINUX(set_current_security_context(NULL);) | 109 | IF_SELINUX(set_current_security_context(NULL);) |
108 | 110 | ||
109 | /* Never returns */ | 111 | /* Never returns */ |
diff --git a/miscutils/crontab.c b/miscutils/crontab.c index 7d5709521..5557bc491 100644 --- a/miscutils/crontab.c +++ b/miscutils/crontab.c | |||
@@ -32,8 +32,9 @@ static void edit_file(const struct passwd *pas, const char *file) | |||
32 | /* CHILD - change user and run editor */ | 32 | /* CHILD - change user and run editor */ |
33 | /* initgroups, setgid, setuid */ | 33 | /* initgroups, setgid, setuid */ |
34 | change_identity(pas); | 34 | change_identity(pas); |
35 | setup_environment(DEFAULT_SHELL, 0, | 35 | setup_environment(DEFAULT_SHELL, |
36 | SETUP_ENV_CHANGEENV | SETUP_ENV_TO_TMP, pas); | 36 | SETUP_ENV_CHANGEENV | SETUP_ENV_TO_TMP, |
37 | pas); | ||
37 | ptr = getenv("VISUAL"); | 38 | ptr = getenv("VISUAL"); |
38 | if (!ptr) { | 39 | if (!ptr) { |
39 | ptr = getenv("EDITOR"); | 40 | ptr = getenv("EDITOR"); |