chiark / gitweb /
core: if we cannot JOB_ISOLATE the default target JOB_REPLACE it instead
[elogind.git] / src / core / main.c
index 1c2453c9b1871e21fcf781e7849e14e80a93b2be..7b039835a8cffe03f38164150c1c9b645a6ddfad 100644 (file)
@@ -67,6 +67,7 @@
 #include "selinux-setup.h"
 #include "ima-setup.h"
 #include "fileio.h"
+#include "smack-setup.h"
 
 static enum {
         ACTION_RUN,
@@ -1357,10 +1358,13 @@ int main(int argc, char *argv[]) {
                 }
 
                 if (!skip_setup) {
+                        mount_setup_early();
                         if (selinux_setup(&loaded_policy) < 0)
                                 goto finish;
                         if (ima_setup() < 0)
                                 goto finish;
+                        if (smack_setup() < 0)
+                                goto finish;
                 }
 
                 if (label_init(NULL) < 0)
@@ -1732,11 +1736,22 @@ int main(int argc, char *argv[]) {
                 }
 
                 r = manager_add_job(m, JOB_START, target, JOB_ISOLATE, false, &error, &default_unit_job);
-                if (r < 0) {
-                        log_error("Failed to start default target: %s", bus_error(&error, r));
+                if (r == -EPERM) {
+                        log_error("Default target could not be isolated, starting instead: %s", bus_error(&error, r));
+                        dbus_error_free(&error);
+
+                        r = manager_add_job(m, JOB_START, target, JOB_REPLACE, false, &error, &default_unit_job);
+                        if (r < 0) {
+                                log_error("Failed to start default target: %s", bus_error(&error, r));
+                                dbus_error_free(&error);
+                                goto finish;
+                        }
+                } else if (r < 0) {
+                        log_error("Failed to isolate default target: %s", bus_error(&error, r));
                         dbus_error_free(&error);
                         goto finish;
                 }
+
                 m->default_unit_job_id = default_unit_job->id;
 
                 after_startup = now(CLOCK_MONOTONIC);