richardphibel / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
be0c12
From 858519383fec2b3fadc1b8423214f703d69d6a6c Mon Sep 17 00:00:00 2001
be0c12
From: Lennart Poettering <lennart@poettering.net>
be0c12
Date: Wed, 22 Apr 2020 21:52:22 +0200
be0c12
Subject: [PATCH] core: make sure we don't get confused when setting TERM for a
be0c12
 tty fd
be0c12
be0c12
Fixes: #15344
be0c12
(cherry picked from commit e8cf09b2a2ad0d48e5493050d54251d5f512d9b6)
be0c12
be0c12
Resolves: #2045307
be0c12
---
be0c12
 src/core/execute.c | 9 +++++----
be0c12
 1 file changed, 5 insertions(+), 4 deletions(-)
be0c12
be0c12
diff --git a/src/core/execute.c b/src/core/execute.c
be0c12
index d528d08830..a104294966 100644
be0c12
--- a/src/core/execute.c
be0c12
+++ b/src/core/execute.c
be0c12
@@ -1709,12 +1709,13 @@ static int build_environment(
be0c12
 
be0c12
                 tty_path = exec_context_tty_path(c);
be0c12
 
be0c12
-                /* If we are forked off PID 1 and we are supposed to operate on /dev/console, then let's try to inherit
be0c12
-                 * the $TERM set for PID 1. This is useful for containers so that the $TERM the container manager
be0c12
-                 * passes to PID 1 ends up all the way in the console login shown. */
be0c12
+                /* If we are forked off PID 1 and we are supposed to operate on /dev/console, then let's try
be0c12
+                 * to inherit the $TERM set for PID 1. This is useful for containers so that the $TERM the
be0c12
+                 * container manager passes to PID 1 ends up all the way in the console login shown. */
be0c12
 
be0c12
-                if (path_equal(tty_path, "/dev/console") && getppid() == 1)
be0c12
+                if (path_equal_ptr(tty_path, "/dev/console") && getppid() == 1)
be0c12
                         term = getenv("TERM");
be0c12
+
be0c12
                 if (!term)
be0c12
                         term = default_term_for_tty(tty_path);
be0c12