ryantimwilson / rpms / systemd

Forked from rpms/systemd a month ago
Clone
5d016e
From f975f1cc748929942188ae1490cf8480f8a64877 Mon Sep 17 00:00:00 2001
5d016e
From: Anita Zhang <the.anitazha@gmail.com>
5d016e
Date: Thu, 4 Mar 2021 19:56:16 -0800
5d016e
Subject: [PATCH 1/2] shutdown: set always_reopen_console
5d016e
5d016e
Back in v232 systemd-shutdown would log to /dev/console. However after
5d016e
the addition of always_reopen_console (v233) it would log to STDERR.
5d016e
This caused some debugging issues as container systemd-shutdown logs
5d016e
weren't being logged to console as the arg `--log-target=console` suggested.
5d016e
5d016e
Since it appears that always_reopen_console was intended for pid1, set
5d016e
it in systemd-shutdown as well so logs will go to /dev/console.
5d016e
---
5d016e
 src/shutdown/shutdown.c | 3 +++
5d016e
 1 file changed, 3 insertions(+)
5d016e
5d016e
diff --git a/src/shutdown/shutdown.c b/src/shutdown/shutdown.c
5d016e
index 0d07865542e..c1fdc885afb 100644
5d016e
--- a/src/shutdown/shutdown.c
5d016e
+++ b/src/shutdown/shutdown.c
5d016e
@@ -322,6 +322,9 @@ int main(int argc, char *argv[]) {
5d016e
         log_set_prohibit_ipc(true);
5d016e
         log_parse_environment();
5d016e
 
5d016e
+        if (getpid_cached() == 1)
5d016e
+                log_set_always_reopen_console(true);
5d016e
+
5d016e
         r = parse_argv(argc, argv);
5d016e
         if (r < 0)
5d016e
                 goto error;
5d016e
5d016e
From 016f36ae72611210d6517b37429bfbdc26c5e31c Mon Sep 17 00:00:00 2001
5d016e
From: Anita Zhang <the.anitazha@gmail.com>
5d016e
Date: Thu, 4 Mar 2021 20:00:05 -0800
5d016e
Subject: [PATCH 2/2] shutdown: log on container exit
5d016e
5d016e
---
5d016e
 src/shutdown/shutdown.c | 4 +++-
5d016e
 1 file changed, 3 insertions(+), 1 deletion(-)
5d016e
5d016e
diff --git a/src/shutdown/shutdown.c b/src/shutdown/shutdown.c
5d016e
index c1fdc885afb..06b6618ff4c 100644
5d016e
--- a/src/shutdown/shutdown.c
5d016e
+++ b/src/shutdown/shutdown.c
5d016e
@@ -559,8 +559,10 @@ int main(int argc, char *argv[]) {
5d016e
                 sync_with_progress();
5d016e
 
5d016e
         if (streq(arg_verb, "exit")) {
5d016e
-                if (in_container)
5d016e
+                if (in_container) {
5d016e
+                        log_info("Exiting container.");
5d016e
                         return arg_exit_code;
5d016e
+                }
5d016e
 
5d016e
                 cmd = RB_POWER_OFF; /* We cannot exit() on the host, fallback on another method. */
5d016e
         }