[systemd-devel] [PATCH 1/2] core: Refuse to run a user instance when the system hasn't been booted with systemd.

Thomas Bächler thomas at archlinux.org
Fri Oct 5 16:11:52 PDT 2012


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.

Signed-off-by: Thomas Bächler <thomas at archlinux.org>
---
 src/core/main.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/core/main.c b/src/core/main.c
index f9aba46..3df38c2 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,
@@ -1381,6 +1382,10 @@ int main(int argc, char *argv[]) {
         } else {
 
                 /* Running as user instance */
+                if(!sd_booted()) {
+                        log_error("Trying to run as user instance, but the system has not been booted with systemd.");
+                        goto finish;
+                }
                 arg_running_as = SYSTEMD_USER;
                 log_set_target(LOG_TARGET_AUTO);
                 log_open();
-- 
1.7.12.2



More information about the systemd-devel mailing list