core: Refuse to run a user instance when the system hasn't been booted with systemd.

Running as a user instance won't work at all if systemd isn't running as system
manager, so refuse to start in that case.
This commit is contained in:
Thomas Bächler 2012-10-06 01:11:52 +02:00 committed by Lennart Poettering
parent 080ffcb4a1
commit 6bae23a038

View file

@ -62,6 +62,7 @@
#include "hwclock.h" #include "hwclock.h"
#include "selinux-setup.h" #include "selinux-setup.h"
#include "ima-setup.h" #include "ima-setup.h"
#include "sd-daemon.h"
static enum { static enum {
ACTION_RUN, ACTION_RUN,
@ -1423,11 +1424,19 @@ int main(int argc, char *argv[]) {
if (parse_argv(argc, argv) < 0) if (parse_argv(argc, argv) < 0)
goto finish; goto finish;
if (arg_action == ACTION_TEST && geteuid() == 0) { if (arg_action == ACTION_TEST &&
geteuid() == 0) {
log_error("Don't run test mode as root."); log_error("Don't run test mode as root.");
goto finish; goto finish;
} }
if (arg_running_as == SYSTEMD_USER &&
arg_action == ACTION_RUN &&
sd_booted() <= 0) {
log_error("Trying to run as user instance, but the system has not been booted with systemd.");
goto finish;
}
if (arg_running_as == SYSTEMD_SYSTEM && if (arg_running_as == SYSTEMD_SYSTEM &&
arg_action == ACTION_RUN && arg_action == ACTION_RUN &&
running_in_chroot() > 0) { running_in_chroot() > 0) {