summaryrefslogtreecommitdiff
path: root/src/systemctl/systemctl.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2012-11-21 23:22:03 +0100
committerTom Gundersen <teg@jklm.no>2012-12-28 23:37:18 +0100
commit13068da8b0b27bc56f0c5b245e5dbaa3dcd102d9 (patch)
tree2a2ae8c8db3641ef488cc6f78dca5c0ad2dbde2b /src/systemctl/systemctl.c
parent485507b8c031e0c75f43c4b4fce5a0082a812fbb (diff)
systemctl: switch-root - read init= from /proc/cmdline
If the path to init is not specified as an argumnt to systemctl, but init= is given on the kernel commandline, use that. This means the initrd does not need glue code to parse the kernel commandline before passing on init= to systemctl. Cc: Harald Hoyer <harald@redhat.com> Cc: Dave Reisner <dreisner@archlinux.org>
Diffstat (limited to 'src/systemctl/systemctl.c')
-rw-r--r--src/systemctl/systemctl.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 876e782e7d..463c72f659 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -3324,7 +3324,8 @@ finish:
static int switch_root(DBusConnection *bus, char **args) {
unsigned l;
- const char *root, *init;
+ const char *root;
+ _cleanup_free_ char *init = NULL;
l = strv_length(args);
if (l < 2 || l > 3) {
@@ -3333,7 +3334,23 @@ static int switch_root(DBusConnection *bus, char **args) {
}
root = args[1];
- init = l >= 3 ? args[2] : "";
+
+ if (l >= 3)
+ init = strdup(args[2]);
+ else {
+ parse_env_file("/proc/cmdline", WHITESPACE,
+ "init", &init,
+ NULL);
+
+ if (!init)
+ init = strdup("");
+
+ if (!init)
+ return log_oom();
+
+ }
+
+ log_debug("switching root - root: %s; init: %s", root, init);
return bus_method_call_with_reply (
bus,