Zbigniew Jędrzejewski-Szmek 5d6eed
From 228523c0b9f077d60a4744776a73ff29b4c18dd2 Mon Sep 17 00:00:00 2001
Zbigniew Jędrzejewski-Szmek 5d6eed
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Zbigniew Jędrzejewski-Szmek 5d6eed
Date: Sat, 28 Jan 2017 21:18:31 -0500
Zbigniew Jędrzejewski-Szmek 5d6eed
Subject: [PATCH] systemctl: always avoid being killed when doing switch-root
Zbigniew Jędrzejewski-Szmek 5d6eed
Zbigniew Jędrzejewski-Szmek 5d6eed
The same logic as described in acc28e2e3037d689d6481e applies to any time we are
Zbigniew Jędrzejewski-Szmek 5d6eed
switching root, to just set the flag unconditionally.
Zbigniew Jędrzejewski-Szmek 5d6eed
Zbigniew Jędrzejewski-Szmek 5d6eed
(cherry picked from commit b3ad0ff48c154ed056a6bded2adac609395a9439)
Zbigniew Jędrzejewski-Szmek 5d6eed
---
Zbigniew Jędrzejewski-Szmek 5d6eed
 src/systemctl/systemctl.c | 8 +++-----
Zbigniew Jędrzejewski-Szmek 5d6eed
 1 file changed, 3 insertions(+), 5 deletions(-)
Zbigniew Jędrzejewski-Szmek 5d6eed
Zbigniew Jędrzejewski-Szmek 5d6eed
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
Zbigniew Jędrzejewski-Szmek 5d6eed
index b598a2a19d..4f528f6079 100644
Zbigniew Jędrzejewski-Szmek 5d6eed
--- a/src/systemctl/systemctl.c
Zbigniew Jędrzejewski-Szmek 5d6eed
+++ b/src/systemctl/systemctl.c
Zbigniew Jędrzejewski-Szmek 5d6eed
@@ -5587,11 +5587,9 @@ static int switch_root(int argc, char *argv[], void *userdata) {
Zbigniew Jędrzejewski-Szmek 5d6eed
         }
Zbigniew Jędrzejewski-Szmek 5d6eed
 
Zbigniew Jędrzejewski-Szmek 5d6eed
         /* Instruct PID1 to exclude us from its killing spree applied during
Zbigniew Jędrzejewski-Szmek 5d6eed
-         * the transition from the initrd to the main system otherwise we would
Zbigniew Jędrzejewski-Szmek 5d6eed
-         * exit with a failure status even though the switch to the new root
Zbigniew Jędrzejewski-Szmek 5d6eed
-         * has succeed. */
Zbigniew Jędrzejewski-Szmek 5d6eed
-        if (in_initrd())
Zbigniew Jędrzejewski-Szmek 5d6eed
-                argv_cmdline[0] = '@';
Zbigniew Jędrzejewski-Szmek 5d6eed
+         * the transition. Otherwise we would exit with a failure status even
Zbigniew Jędrzejewski-Szmek 5d6eed
+         * though the switch to the new root has succeed. */
Zbigniew Jędrzejewski-Szmek 5d6eed
+        argv_cmdline[0] = '@';
Zbigniew Jędrzejewski-Szmek 5d6eed
 
Zbigniew Jędrzejewski-Szmek 5d6eed
         r = acquire_bus(BUS_MANAGER, &bus;;
Zbigniew Jędrzejewski-Szmek 5d6eed
         if (r < 0)