#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:
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: