dryang / rpms / systemd

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