From: Lennart Poettering Date: Fri, 31 Jan 2025 19:23:39 +0000 (+0100) Subject: nspawn: set TERM to "dumb" if we are invoked outside of TTY context X-Git-Tag: v258-rc1~1227^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ddb503b7f601f7874d68bc4959c2a426f9740fc9;p=thirdparty%2Fsystemd.git nspawn: set TERM to "dumb" if we are invoked outside of TTY context --- diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index a504279fa52..91bc8e8b0e1 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -3582,9 +3582,9 @@ static int inner_child( /* LXC sets container=lxc, so follow the scheme here */ envp[n_env++] = strjoina("container=", arg_container_service_name); - envp[n_env] = strv_find_prefix(environ, "TERM="); - if (envp[n_env]) - n_env++; + /* Propagate $TERM unless we are invoked in pipe mode and stdin/stdout/stderr don't refer to a TTY */ + const char *term = (arg_console_mode != CONSOLE_PIPE || on_tty()) ? strv_find_prefix(environ, "TERM=") : NULL; + envp[n_env++] = (char*) (term ?: "TERM=dumb"); if (home || !uid_is_valid(arg_uid) || arg_uid == 0) if (asprintf(envp + n_env++, "HOME=%s", home ?: "/root") < 0)