From 7a9512b871f59656d205a6fa4b11c7a66e321d08 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 27 Jul 2016 15:25:55 +0200 Subject: [PATCH] core: inherit TERM from PID 1 for all services started on /dev/console This way, invoking nspawn from a shell in the best case inherits the TERM setting all the way down into the login shell spawned in the container. Fixes: #3697 --- src/basic/terminal-util.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c index 0659310a7..0f2cde006 100644 --- a/src/basic/terminal-util.c +++ b/src/basic/terminal-util.c @@ -792,7 +792,7 @@ bool tty_is_vc_resolve(const char *tty) { } const char *default_term_for_tty(const char *tty) { - return tty && tty_is_vc_resolve(tty) ? "TERM=linux" : "TERM=vt220"; + return tty && tty_is_vc_resolve(tty) ? "linux" : "vt220"; } #endif // 0 @@ -1203,9 +1203,12 @@ int open_terminal_in_namespace(pid_t pid, const char *name, int mode) { } #endif // 0 -static bool getenv_terminal_is_dumb(void) { +bool terminal_is_dumb(void) { const char *e; + if (!on_tty()) + return true; + e = getenv("TERM"); if (!e) return true; @@ -1213,13 +1216,6 @@ static bool getenv_terminal_is_dumb(void) { return streq(e, "dumb"); } -bool terminal_is_dumb(void) { - if (!on_tty()) - return true; - - return getenv_terminal_is_dumb(); -} - bool colors_enabled(void) { static int enabled = -1; @@ -1229,9 +1225,6 @@ bool colors_enabled(void) { colors = getenv("SYSTEMD_COLORS"); if (colors) enabled = parse_boolean(colors) != 0; - else if (getpid() == 1) - /* PID1 outputs to the console without holding it open all the time */ - enabled = !getenv_terminal_is_dumb(); else enabled = !terminal_is_dumb(); } -- 2.30.2