From ab17a050b778412b11c82f4fa974be9c491ead36 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 7 Mar 2013 22:18:34 +0100 Subject: core: if we cannot JOB_ISOLATE the default target JOB_REPLACE it instead In order to maintain compatibility with older initrds which do not have AllowIsolate=yes set for their target units, fallback to JOB_REPLACE if JOB_ISOLATE doesn't work, but complain about it. --- src/core/main.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/core/main.c b/src/core/main.c index 727a410740..7b039835a8 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -1736,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); -- cgit v1.2.3-54-g00ecf