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

Skip to content

Commit aa33959

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

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

login-utils/login.1.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ If password aging has been enabled for the account, the user may be prompted for
2828

2929
The user and group ID will be set according to their values in the _/etc/passwd_ file. There is one exception if the user ID is zero. In this case, only the primary group ID of the account is set. This should allow the system administrator to login even in case of network problems. The environment variable values for *$HOME*, *$USER*, *$SHELL*, *$PATH*, *$LOGNAME*, and *$MAIL* are set according to the appropriate fields in the password entry. *$PATH* defaults to _/usr/local/bin:/bin:/usr/bin_ for normal users, and to _/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin_ for root, if not otherwise configured.
3030

31-
The environment variable *$TERM* will be preserved, if it exists, else it will be initialized to the terminal type on your tty. Other environment variables are preserved if the *-p* option is given.
31+
The environment variable *$TERM* will be preserved, if it exists, else it will be initialized to the terminal type on your tty. The environment variables *$COLORTERM* and *$NO_COLOR* will be preserved if they exist.
32+
33+
Other environment variables are preserved if the *-p* option is given or if *LOGIN_ENV_SAFELIST* defined in _/etc/login.defs_ (see below).
3234

3335
The environment variables defined by PAM are always preserved.
3436

login-utils/login.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,6 +1194,8 @@ static void init_environ(struct login_context *cxt)
11941194
int len, i;
11951195

11961196
saved = env_list_add_getenv(NULL, "TERM", "dumb");
1197+
saved = env_list_add_getenv(saved, "COLORTERM", NULL);
1198+
saved = env_list_add_getenv(saved, "NO_COLOR", NULL);
11971199

11981200
/* destroy environment unless user has requested preservation (-p) */
11991201
if (!cxt->keep_env) {

0 commit comments

Comments
 (0)
0