X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fsystemctl.c;h=3ca146447aa4c181b9c2e127aaaa2766f206a6e4;hp=1e3385f8604074ff59ea09939cc2be1d722da66e;hb=48a21c9b37372e508fdf1f29a0b4dc90ea051ba3;hpb=ee5762e3780c048b230e8c1e7659e40fc1f443bf diff --git a/src/systemctl.c b/src/systemctl.c index 1e3385f86..3ca146447 100644 --- a/src/systemctl.c +++ b/src/systemctl.c @@ -3933,7 +3933,8 @@ static int halt_parse_argv(int argc, char *argv[]) { break; case 'p': - arg_action = ACTION_POWEROFF; + if (arg_action != ACTION_REBOOT) + arg_action = ACTION_POWEROFF; break; case ARG_REBOOT: @@ -4209,8 +4210,22 @@ static int parse_argv(int argc, char *argv[]) { arg_action = ACTION_POWEROFF; return shutdown_parse_argv(argc, argv); } else if (strstr(program_invocation_short_name, "init")) { - arg_action = ACTION_INVALID; - return telinit_parse_argv(argc, argv); + + if (sd_booted() > 0) { + arg_action = ACTION_INVALID; + return telinit_parse_argv(argc, argv); + } else { + /* Hmm, so some other init system is + * running, we need to forward this + * request to it. For now we simply + * guess that it is Upstart. */ + + execv("/lib/upstart/telinit", argv); + + log_error("Couldn't find an alternative telinit implementation to spawn."); + return -EIO; + } + } else if (strstr(program_invocation_short_name, "runlevel")) { arg_action = ACTION_RUNLEVEL; return runlevel_parse_argv(argc, argv); @@ -4426,7 +4441,6 @@ static int systemctl_main(DBusConnection *bus, int argc, char *argv[], DBusError int left; unsigned i; - assert(bus); assert(argc >= 0); assert(argv); assert(error); @@ -4517,18 +4531,17 @@ static int reload_with_fallback(DBusConnection *bus) { static int start_with_fallback(DBusConnection *bus) { int r; - if (bus) { /* First, try systemd via D-Bus. */ if ((r = start_unit(bus, NULL, 0)) > 0) goto done; - - /* Hmm, talking to systemd via D-Bus didn't work. Then - * let's try to talk to Upstart via D-Bus. */ - if ((r = talk_upstart()) > 0) - goto done; } + /* Hmm, talking to systemd via D-Bus didn't work. Then + * let's try to talk to Upstart via D-Bus. */ + if ((r = talk_upstart()) > 0) + goto done; + /* Nothing else worked, so let's try * /dev/initctl */ if ((r = talk_initctl()) != 0)