summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-08-17 20:42:53 +0200
committerLennart Poettering <lennart@poettering.net>2010-08-17 20:42:53 +0200
commit1c27d3f3fde312d399042a5f90fd4133da4f8a67 (patch)
tree00c22f37a8aaf992716abee8923026e9a4fe4863 /src/main.c
parent7f17ef2201b1765afd0bb6c747588f88b8f4cd46 (diff)
main: properly fallback to rescue.target if default.target is hosed
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index b0e1c2230b..2c91fe4578 100644
--- a/src/main.c
+++ b/src/main.c
@@ -851,7 +851,6 @@ fail:
int main(int argc, char *argv[]) {
Manager *m = NULL;
- Unit *target = NULL;
int r, retval = 1;
FDSet *fds = NULL;
bool reexecute = false;
@@ -1004,6 +1003,7 @@ int main(int argc, char *argv[]) {
serialization = NULL;
} else {
DBusError error;
+ Unit *target = NULL;
dbus_error_init(&error);
@@ -1012,12 +1012,19 @@ int main(int argc, char *argv[]) {
if ((r = manager_load_unit(m, arg_default_unit, NULL, &error, &target)) < 0) {
log_error("Failed to load default target: %s", bus_error(&error, r));
dbus_error_free(&error);
+ } else if (target->meta.load_state != UNIT_LOADED)
+ log_error("Failed to load default target: %s", strerror(-target->meta.load_error));
+ if (!target || target->meta.load_state != UNIT_LOADED) {
log_info("Trying to load rescue target...");
+
if ((r = manager_load_unit(m, SPECIAL_RESCUE_TARGET, NULL, &error, &target)) < 0) {
log_error("Failed to load rescue target: %s", bus_error(&error, r));
dbus_error_free(&error);
goto finish;
+ } else if (target->meta.load_state != UNIT_LOADED) {
+ log_error("Failed to load rescue target: %s", strerror(-target->meta.load_error));
+ goto finish;
}
}