From: Lennart Poettering Date: Wed, 22 Apr 2020 19:52:22 +0000 (+0200) Subject: core: make sure we don't get confused when setting TERM for a tty fd X-Git-Tag: v245.6~110 X-Git-Url: http://git-history.diyao.me/?a=commitdiff_plain;h=ae5a9f27c5e5c7581d5a0aaeb32f9b8a829d0864;p=systemd%2F.git core: make sure we don't get confused when setting TERM for a tty fd Fixes: #15344 (cherry picked from commit e8cf09b2a2ad0d48e5493050d54251d5f512d9b6) --- diff --git a/src/core/execute.c b/src/core/execute.c index 2a65ee3fbb..359eb5e403 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -1820,12 +1820,13 @@ static int build_environment( tty_path = exec_context_tty_path(c); - /* If we are forked off PID 1 and we are supposed to operate on /dev/console, then let's try to inherit - * the $TERM set for PID 1. This is useful for containers so that the $TERM the container manager - * passes to PID 1 ends up all the way in the console login shown. */ + /* If we are forked off PID 1 and we are supposed to operate on /dev/console, then let's try + * to inherit the $TERM set for PID 1. This is useful for containers so that the $TERM the + * container manager passes to PID 1 ends up all the way in the console login shown. */ - if (path_equal(tty_path, "/dev/console") && getppid() == 1) + if (path_equal_ptr(tty_path, "/dev/console") && getppid() == 1) term = getenv("TERM"); + if (!term) term = default_term_for_tty(tty_path);