From: Thomas Bächler Date: Fri, 5 Oct 2012 23:11:52 +0000 (+0200) Subject: core: Refuse to run a user instance when the system hasn't been booted with systemd. X-Git-Tag: v195~102 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=6bae23a0388dd077fee99e83e161d297c3e2b768;hp=080ffcb4a124bd77054a3909bbd5f14d62f79b62 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. --- diff --git a/src/core/main.c b/src/core/main.c index f9aba46b5..e094efeb3 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -62,6 +62,7 @@ #include "hwclock.h" #include "selinux-setup.h" #include "ima-setup.h" +#include "sd-daemon.h" static enum { ACTION_RUN, @@ -1423,11 +1424,19 @@ int main(int argc, char *argv[]) { if (parse_argv(argc, argv) < 0) 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."); 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 && arg_action == ACTION_RUN && running_in_chroot() > 0) {