summaryrefslogtreecommitdiff
path: root/src/shared/bus-util.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2018-05-09 17:06:46 +0900
committerSven Eden <yamakuzure@gmx.net>2018-08-24 16:47:08 +0200
commitf2062b93c88f7849cf5b14b7bc03f3ff126a26ce (patch)
tree8e3a847195bd689649973f48dbe51403fa423003 /src/shared/bus-util.c
parent00c297256b05cc08db92e312d5a45a2d5c0d8425 (diff)
bus-util: print a friendly message when PID1 is not systemd
Follow-up for 861f16d2679eeda79e8185057cef24653913e300. Fixes #8913.
Diffstat (limited to 'src/shared/bus-util.c')
-rw-r--r--src/shared/bus-util.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c
index 7263593ac..52f8432fc 100644
--- a/src/shared/bus-util.c
+++ b/src/shared/bus-util.c
@@ -1307,10 +1307,16 @@ int bus_connect_transport(BusTransport transport, const char *host, bool user, s
#if 0 /// elogind does not support a user bus
if (user)
r = sd_bus_default_user(&bus);
- else
#endif // 0
- r = sd_bus_default_system(&bus);
+ else {
+ if (sd_booted() <= 0) {
+ /* Print a friendly message when the local system is actually not running systemd as PID 1. */
+ log_error("System has not been booted with elogind as init system (PID 1). Can't operate.");
+ return -EHOSTDOWN;
+ }
+ r = sd_bus_default_system(&bus);
+ }
break;
case BUS_TRANSPORT_REMOTE:
@@ -1352,9 +1358,15 @@ int bus_connect_transport_systemd(BusTransport transport, const char *host, bool
case BUS_TRANSPORT_LOCAL:
if (user)
r = bus_connect_user_systemd(bus);
- else
- r = bus_connect_system_systemd(bus);
+ else {
+ if (sd_booted() <= 0) {
+ /* Print a friendly message when the local system is actually not running systemd as PID 1. */
+ log_error("System has not been booted with systemd as init system (PID 1). Can't operate.");
+ return -EHOSTDOWN;
+ }
+ r = bus_connect_system_systemd(bus);
+ }
break;
case BUS_TRANSPORT_REMOTE: