summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bächler <thomas@archlinux.org>2012-10-06 01:11:52 +0200
committerLennart Poettering <lennart@poettering.net>2012-10-16 02:17:46 +0200
commit6bae23a0388dd077fee99e83e161d297c3e2b768 (patch)
treeb88dc058c0111f52ba762523a173e43ecba4b3f9
parent080ffcb4a124bd77054a3909bbd5f14d62f79b62 (diff)
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.
-rw-r--r--src/core/main.c11
1 files changed, 10 insertions, 1 deletions
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
@@ -59,12 +59,13 @@
#include "hostname-setup.h"
#include "machine-id-setup.h"
#include "locale-setup.h"
#include "hwclock.h"
#include "selinux-setup.h"
#include "ima-setup.h"
+#include "sd-daemon.h"
static enum {
ACTION_RUN,
ACTION_HELP,
ACTION_VERSION,
ACTION_TEST,
@@ -1420,17 +1421,25 @@ int main(int argc, char *argv[]) {
log_parse_environment();
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) {
log_error("Cannot be run in a chroot() environment.");
goto finish;
}