Created
March 19, 2025 21:43
-
-
Save Mic92/395565fd2461dd1180ea2578441f355f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 3ceb739b696ac712dddfc6acf1f88e492d6f07d3 Mon Sep 17 00:00:00 2001 | |
From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= <[email protected]> | |
Date: Sat, 20 Jul 2024 10:23:57 +0200 | |
Subject: [PATCH] detect systemd by name rather than relying on | |
SYSTEMD_BINARY_PATH | |
MIME-Version: 1.0 | |
Content-Type: text/plain; charset=UTF-8 | |
Content-Transfer-Encoding: 8bit | |
This allows us in NixOS to run systemd binaries from the nix store | |
directly. | |
Signed-off-by: Jörg Thalheim <[email protected]> | |
--- | |
src/core/main.c | 2 +- | |
src/systemctl/systemctl-switch-root.c | 4 ---- | |
2 files changed, 1 insertion(+), 5 deletions(-) | |
diff --git a/src/core/main.c b/src/core/main.c | |
index e5c2dc914e..a4ea928782 100644 | |
--- a/src/core/main.c | |
+++ b/src/core/main.c | |
@@ -2000,7 +2000,7 @@ static int do_reexecute( | |
args_size = argc + 5; | |
args = newa(const char*, args_size); | |
- if (!switch_root_init) { | |
+ if (endswith(switch_root_init, "/systemd")) { | |
char sfd[STRLEN("--deserialize=") + DECIMAL_STR_MAX(int)]; | |
/* First try to spawn ourselves with the right path, and with full serialization. We do this | |
diff --git a/src/systemctl/systemctl-switch-root.c b/src/systemctl/systemctl-switch-root.c | |
index ae4a1a72c2..4c8be9da27 100644 | |
--- a/src/systemctl/systemctl-switch-root.c | |
+++ b/src/systemctl/systemctl-switch-root.c | |
@@ -83,10 +83,6 @@ int verb_switch_root(int argc, char *argv[], void *userdata) { | |
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Invalid path to init binary: %s", init); | |
if (!path_is_absolute(init)) | |
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Path to init binary is not absolute: %s", init); | |
- | |
- /* If the passed init is actually the same as the systemd binary, then let's suppress it. */ | |
- if (same_file_in_root(root, SYSTEMD_BINARY_PATH, init) > 0) | |
- init = NULL; | |
} | |
/* Instruct PID1 to exclude us from its killing spree applied during the transition. Otherwise we | |
-- | |
2.45.2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment