Avoid setting LOGNAME, USER and USERNAME variables twice when
set_logname is enabled.
This commit is contained in:
@@ -835,6 +835,8 @@ rebuild_env(void)
|
||||
} else {
|
||||
if (!ISSET(didvar, DID_SHELL))
|
||||
sudo_setenv2("SHELL", sudo_user.pw->pw_shell, false, true);
|
||||
/* We will set LOGNAME later in the !def_set_logname case. */
|
||||
if (!def_set_logname) {
|
||||
if (!ISSET(didvar, DID_LOGNAME))
|
||||
sudo_setenv2("LOGNAME", user_name, false, true);
|
||||
if (!ISSET(didvar, DID_USER))
|
||||
@@ -842,6 +844,7 @@ rebuild_env(void)
|
||||
if (!ISSET(didvar, DID_USERNAME))
|
||||
sudo_setenv2("USERNAME", user_name, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
/* If we didn't keep HOME, reset it based on target user. */
|
||||
if (!ISSET(didvar, KEPT_HOME))
|
||||
@@ -892,8 +895,8 @@ rebuild_env(void)
|
||||
/*
|
||||
* Set $USER, $LOGNAME and $USERNAME to target if "set_logname" is not
|
||||
* disabled. We skip this if we are running a login shell (because
|
||||
* they have already been set them) or sudoedit (because we want the
|
||||
* editor to find the user's startup files).
|
||||
* they have already been set) or sudoedit (because we want the editor
|
||||
* to find the invoking user's startup files).
|
||||
*/
|
||||
if (def_set_logname && !ISSET(sudo_mode, MODE_LOGIN_SHELL|MODE_EDIT)) {
|
||||
if (!ISSET(didvar, KEPT_LOGNAME))
|
||||
|
Reference in New Issue
Block a user