8000 su: protect COLORTERM and NO_COLOR env. variables · util-linux/util-linux@81bb424 · GitHub
[go: up one dir, main page]

Skip to content

Commit 81bb424

Browse files
committed
su: protect COLORTERM and NO_COLOR env. variables
Fixes: #3463 Signed-off-by: Karel Zak <kzak@redhat.com>
1 parent aa33959 commit 81bb424

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

login-utils/runuser.1.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Specify a supplementary group. This option is available to the root user only. T
4747
*-*, *-l*, *--login*::
4848
Start the shell as a login shell with an environment similar to a real login:
4949
+
50-
* clears all the environment variables except for *TERM* and variables specified by *--whitelist-environment*
50+
* clears all the environment variables except for *TERM*, *COLORTERM*, *NO_COLOR* and variables specified by *--whitelist-environment*
5151
* initializes the environment variables *HOME*, *SHELL*, *USER*, *LOGNAME*, and *PATH*
5252
* changes to the target user's home directory
5353
* sets argv[0] of the shell to '*-*' in order to make the shell a login shell

login-utils/su-common.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -704,8 +704,10 @@ static void modify_environment(struct su_context *su, const char *shell)
704704
* --whitelist-environment if specified.
705705
*/
706706
if (su->simulate_login) {
707-
/* leave TERM unchanged */
707+
/* leave unchanged */
708708
su->env_whitelist = env_list_add_getenv(su->env_whitelist, "TERM", NULL);
709+
su->env_whitelist = env_list_add_getenv(su->env_whitelist, "COLORTERM", NULL);
710+
su->env_whitelist = env_list_add_getenv(su->env_whitelist, "NO_COLOR", NULL);
709711

710712
/* Note that original su(1) has allocated environ[] by malloc
711713
* to the number of expected variables. This seems unnecessary

login-utils/su.1.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ PAM) from this point of view. You need to use tools like *systemd-run* or
5555
+
5656
*su* does:
5757
+
58-
* clears all the environment variables except *TERM* and variables specified by *--whitelist-environment*
58+
* clears all the environment variables except *TERM*, *COLORTERM*, *NO_COLOR* and variables specified by *--whitelist-environment*
5959
* initializes the environment variables *HOME*, *SHELL*, *USER*, *LOGNAME*, and *PATH*
6060
* changes to the target user's home directory
6161
* sets argv[0] of the shell to '*-*' in order to make the shell a login shell

0 commit comments

Comments
 (0)
0