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