|
|
65878a |
From fee295c75582ada1c7cfe8a2b69f32d610d92020 Mon Sep 17 00:00:00 2001
|
|
|
65878a |
From: Lukas Nykryn <lnykryn@redhat.com>
|
|
|
65878a |
Date: Fri, 12 Sep 2014 13:27:36 +0200
|
|
|
65878a |
Subject: [PATCH] systemctl: unbreak switchroot
|
|
|
65878a |
|
|
|
65878a |
rhel-only patch
|
|
|
65878a |
cad8ec5980d63253586d9f884649c45eed0667a1 backport broke it
|
|
|
65878a |
|
|
|
65878a |
Related: #1138546
|
|
|
65878a |
---
|
|
|
65878a |
src/systemctl/systemctl.c | 22 +++++++++++-----------
|
|
|
65878a |
1 file changed, 11 insertions(+), 11 deletions(-)
|
|
|
65878a |
|
|
|
65878a |
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
|
|
|
65878a |
index 90a80bd..544025c 100644
|
|
|
65878a |
--- a/src/systemctl/systemctl.c
|
|
|
65878a |
+++ b/src/systemctl/systemctl.c
|
|
|
65878a |
@@ -4147,8 +4147,8 @@ static int show_enviroment(DBusConnection *bus, char **args) {
|
|
|
65878a |
}
|
|
|
65878a |
|
|
|
65878a |
static int switch_root(DBusConnection *bus, char **args) {
|
|
|
65878a |
- _cleanup_free_ char *cmdline_init = NULL;
|
|
|
65878a |
- const char *root, *init;
|
|
|
65878a |
+ _cleanup_free_ char *init = NULL;
|
|
|
65878a |
+ const char *root;
|
|
|
65878a |
unsigned l;
|
|
|
65878a |
int r;
|
|
|
65878a |
|
|
|
65878a |
@@ -4161,23 +4161,20 @@ static int switch_root(DBusConnection *bus, char **args) {
|
|
|
65878a |
root = args[1];
|
|
|
65878a |
|
|
|
65878a |
if (l >= 3)
|
|
|
65878a |
- init = args[2];
|
|
|
65878a |
+ init = strdup(args[2]);
|
|
|
65878a |
else {
|
|
|
65878a |
r = parse_env_file("/proc/cmdline", WHITESPACE,
|
|
|
65878a |
- "init", &cmdline_init,
|
|
|
65878a |
+ "init", &init,
|
|
|
65878a |
NULL);
|
|
|
65878a |
if (r < 0)
|
|
|
65878a |
log_debug("Failed to parse /proc/cmdline: %s", strerror(-r));
|
|
|
65878a |
|
|
|
65878a |
- init = cmdline_init;
|
|
|
65878a |
+ if (!init)
|
|
|
65878a |
+ init = strdup("");
|
|
|
65878a |
}
|
|
|
65878a |
- if (!init)
|
|
|
65878a |
- return log_oom();
|
|
|
65878a |
|
|
|
65878a |
- if (isempty(init))
|
|
|
65878a |
- init = NULL;
|
|
|
65878a |
|
|
|
65878a |
- if (init) {
|
|
|
65878a |
+ if (!isempty(init)) {
|
|
|
65878a |
const char *root_systemd_path = NULL, *root_init_path = NULL;
|
|
|
65878a |
|
|
|
65878a |
root_systemd_path = strappenda(root, "/" SYSTEMD_BINARY_PATH);
|
|
|
65878a |
@@ -4186,9 +4183,12 @@ static int switch_root(DBusConnection *bus, char **args) {
|
|
|
65878a |
/* If the passed init is actually the same as the
|
|
|
65878a |
* systemd binary, then let's suppress it. */
|
|
|
65878a |
if (files_same(root_init_path, root_systemd_path) > 0)
|
|
|
65878a |
- init = NULL;
|
|
|
65878a |
+ init = strdup("");
|
|
|
65878a |
}
|
|
|
65878a |
|
|
|
65878a |
+ if (!init)
|
|
|
65878a |
+ return log_oom();
|
|
|
65878a |
+
|
|
|
65878a |
log_debug("Switching root - root: %s; init: %s", root, strna(init));
|
|
|
65878a |
|
|
|
65878a |
return bus_method_call_with_reply(
|
|
|
65878a |
--
|
|
|
65878a |
1.8.3.1
|
|
|
65878a |
|