diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2022-01-13 12:50:48 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2022-01-13 12:50:48 +0100 |
commit | 931c55f9e2b41473132683488820c6fb7c47506b (patch) | |
tree | 56cbfd7e7b1d85998192e5b61c132b9d4a465b8b /loginutils | |
parent | b3eec1651fb02d70716caa355f49320719f74c75 (diff) | |
download | busybox-w32-931c55f9e2b41473132683488820c6fb7c47506b.tar.gz busybox-w32-931c55f9e2b41473132683488820c6fb7c47506b.tar.bz2 busybox-w32-931c55f9e2b41473132683488820c6fb7c47506b.zip |
libbb: invert the meaning of SETUP_ENV_NO_CHDIR -> SETUP_ENV_CHDIR
Double negatives are hard to grok.
function old new delta
login_main 986 988 +2
su_main 474 470 -4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 2/-4) Total: -2 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'loginutils')
-rw-r--r-- | loginutils/login.c | 4 | ||||
-rw-r--r-- | loginutils/su.c | 7 | ||||
-rw-r--r-- | loginutils/sulogin.c | 9 |
3 files changed, 12 insertions, 8 deletions
diff --git a/loginutils/login.c b/loginutils/login.c index cac4349b2..332238181 100644 --- a/loginutils/login.c +++ b/loginutils/login.c | |||
@@ -564,7 +564,9 @@ int login_main(int argc UNUSED_PARAM, char **argv) | |||
564 | 564 | ||
565 | change_identity(pw); | 565 | change_identity(pw); |
566 | setup_environment(pw->pw_shell, | 566 | setup_environment(pw->pw_shell, |
567 | (!(opt & LOGIN_OPT_p) * SETUP_ENV_CLEARENV) + SETUP_ENV_CHANGEENV, | 567 | (!(opt & LOGIN_OPT_p) * SETUP_ENV_CLEARENV) |
568 | + SETUP_ENV_CHANGEENV | ||
569 | + SETUP_ENV_CHDIR, | ||
568 | pw); | 570 | pw); |
569 | 571 | ||
570 | #if ENABLE_PAM | 572 | #if ENABLE_PAM |
diff --git a/loginutils/su.c b/loginutils/su.c index e1db7590f..6efe1981a 100644 --- a/loginutils/su.c +++ b/loginutils/su.c | |||
@@ -176,10 +176,9 @@ int su_main(int argc UNUSED_PARAM, char **argv) | |||
176 | 176 | ||
177 | change_identity(pw); | 177 | change_identity(pw); |
178 | setup_environment(opt_shell, | 178 | setup_environment(opt_shell, |
179 | ((flags & SU_OPT_l) / SU_OPT_l * SETUP_ENV_CLEARENV) | 179 | ((flags & SU_OPT_l) ? (SETUP_ENV_CLEARENV + SETUP_ENV_CHDIR) : 0) |
180 | + (!(flags & SU_OPT_mp) * SETUP_ENV_CHANGEENV) | 180 | + (!(flags & SU_OPT_mp) * SETUP_ENV_CHANGEENV), |
181 | + (!(flags & SU_OPT_l) * SETUP_ENV_NO_CHDIR), | 181 | pw); |
182 | pw); | ||
183 | IF_SELINUX(set_current_security_context(NULL);) | 182 | IF_SELINUX(set_current_security_context(NULL);) |
184 | 183 | ||
185 | if (opt_command) { | 184 | if (opt_command) { |
diff --git a/loginutils/sulogin.c b/loginutils/sulogin.c index c9817960c..681022acb 100644 --- a/loginutils/sulogin.c +++ b/loginutils/sulogin.c | |||
@@ -94,10 +94,13 @@ int sulogin_main(int argc UNUSED_PARAM, char **argv) | |||
94 | shell = pwd->pw_shell; | 94 | shell = pwd->pw_shell; |
95 | 95 | ||
96 | /* util-linux 2.36.1 compat: cd to root's HOME, set a few envvars */ | 96 | /* util-linux 2.36.1 compat: cd to root's HOME, set a few envvars */ |
97 | setup_environment(shell, SETUP_ENV_CHANGEENV | SETUP_ENV_CHANGEENV_LOGNAME, pwd); | 97 | setup_environment(shell, 0 |
98 | + SETUP_ENV_CHANGEENV_LOGNAME | ||
99 | + SETUP_ENV_CHDIR | ||
100 | , pwd); | ||
98 | // no SETUP_ENV_CLEARENV | 101 | // no SETUP_ENV_CLEARENV |
99 | // SETUP_ENV_CHANGEENV[+LOGNAME] - set HOME, SHELL, USER,and LOGNAME | 102 | // SETUP_ENV_CHANGEENV_LOGNAME - set HOME, SHELL, USER,and LOGNAME |
100 | // no SETUP_ENV_NO_CHDIR - IOW: cd to $HOME | 103 | // SETUP_ENV_CHDIR - cd to $HOME |
101 | 104 | ||
102 | /* util-linux 2.36.1 compat: steal ctty if we don't have it yet | 105 | /* util-linux 2.36.1 compat: steal ctty if we don't have it yet |
103 | * (yes, util-linux uses force=1) */ | 106 | * (yes, util-linux uses force=1) */ |