summaryrefslogtreecommitdiff
path: root/loginutils
diff options
context:
space:
mode:
Diffstat (limited to 'loginutils')
-rw-r--r--loginutils/login.c4
-rw-r--r--loginutils/su.c7
-rw-r--r--loginutils/sulogin.c9
3 files changed, 12 insertions, 8 deletions
diff --git a/loginutils/login.c b/loginutils/login.c
index cac4349..3322381 100644
--- a/loginutils/login.c
+++ b/loginutils/login.c
@@ -564,7 +564,9 @@ int login_main(int argc UNUSED_PARAM, char **argv)
change_identity(pw);
setup_environment(pw->pw_shell,
- (!(opt & LOGIN_OPT_p) * SETUP_ENV_CLEARENV) + SETUP_ENV_CHANGEENV,
+ (!(opt & LOGIN_OPT_p) * SETUP_ENV_CLEARENV)
+ + SETUP_ENV_CHANGEENV
+ + SETUP_ENV_CHDIR,
pw);
#if ENABLE_PAM
diff --git a/loginutils/su.c b/loginutils/su.c
index e1db759..6efe198 100644
--- a/loginutils/su.c
+++ b/loginutils/su.c
@@ -176,10 +176,9 @@ int su_main(int argc UNUSED_PARAM, char **argv)
change_identity(pw);
setup_environment(opt_shell,
- ((flags & SU_OPT_l) / SU_OPT_l * SETUP_ENV_CLEARENV)
- + (!(flags & SU_OPT_mp) * SETUP_ENV_CHANGEENV)
- + (!(flags & SU_OPT_l) * SETUP_ENV_NO_CHDIR),
- pw);
+ ((flags & SU_OPT_l) ? (SETUP_ENV_CLEARENV + SETUP_ENV_CHDIR) : 0)
+ + (!(flags & SU_OPT_mp) * SETUP_ENV_CHANGEENV),
+ pw);
IF_SELINUX(set_current_security_context(NULL);)
if (opt_command) {
diff --git a/loginutils/sulogin.c b/loginutils/sulogin.c
index c981796..681022a 100644
--- a/loginutils/sulogin.c
+++ b/loginutils/sulogin.c
@@ -94,10 +94,13 @@ int sulogin_main(int argc UNUSED_PARAM, char **argv)
shell = pwd->pw_shell;
/* util-linux 2.36.1 compat: cd to root's HOME, set a few envvars */
- setup_environment(shell, SETUP_ENV_CHANGEENV | SETUP_ENV_CHANGEENV_LOGNAME, pwd);
+ setup_environment(shell, 0
+ + SETUP_ENV_CHANGEENV_LOGNAME
+ + SETUP_ENV_CHDIR
+ , pwd);
// no SETUP_ENV_CLEARENV
- // SETUP_ENV_CHANGEENV[+LOGNAME] - set HOME, SHELL, USER,and LOGNAME
- // no SETUP_ENV_NO_CHDIR - IOW: cd to $HOME
+ // SETUP_ENV_CHANGEENV_LOGNAME - set HOME, SHELL, USER,and LOGNAME
+ // SETUP_ENV_CHDIR - cd to $HOME
/* util-linux 2.36.1 compat: steal ctty if we don't have it yet
* (yes, util-linux uses force=1) */