richardphibel / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
b11b5f
From 74632586b46c7e88b09c57eec50f9c4aed254b98 Mon Sep 17 00:00:00 2001
b11b5f
From: David Tardon <dtardon@redhat.com>
b11b5f
Date: Mon, 30 Jan 2023 14:31:23 +0100
b11b5f
Subject: [PATCH] systemctl: preserve old behavior unless requested
b11b5f
b11b5f
Currently, the legacy shutdown commands ignore inhibitors and reboot
b11b5f
immediately if run by root. Let's preserve that behavior in RHEL-8 by
b11b5f
default. The new behavior can be turned on by those who want it by
b11b5f
exporting SYSTEMD_NEW_SHUTDOWN=1 .
b11b5f
b11b5f
RHEL-only
b11b5f
b11b5f
Related: #2053273
b11b5f
---
b11b5f
 src/systemctl/systemctl.c | 9 ++++++++-
b11b5f
 1 file changed, 8 insertions(+), 1 deletion(-)
b11b5f
b11b5f
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
b11b5f
index a26e4a913a..1546119ce5 100644
b11b5f
--- a/src/systemctl/systemctl.c
b11b5f
+++ b/src/systemctl/systemctl.c
b11b5f
@@ -8714,7 +8714,7 @@ static int halt_main_old(void) {
b11b5f
         return log_error_errno(r, "Failed to reboot: %m");
b11b5f
 }
b11b5f
 
b11b5f
-static int halt_main(void) {
b11b5f
+static int halt_main_new(void) {
b11b5f
         int r;
b11b5f
 
b11b5f
         /* always try logind first */
b11b5f
@@ -8765,6 +8765,13 @@ static int halt_main(void) {
b11b5f
         return log_error_errno(r, "Failed to reboot: %m");
b11b5f
 }
b11b5f
 
b11b5f
+static int halt_main(void) {
b11b5f
+        if (getenv_bool("SYSTEMD_NEW_SHUTDOWN") > 0)
b11b5f
+                return halt_main_new();
b11b5f
+        else
b11b5f
+                return halt_main_old();
b11b5f
+}
b11b5f
+
b11b5f
 static int runlevel_main(void) {
b11b5f
         int r, runlevel, previous;
b11b5f