[systemd-devel] [PATCH] Try to start rescue.target if default.target is missing

Tomasz Torcz tomek at pipebreaker.pl
Tue Sep 11 03:06:18 PDT 2012


>From 0a3f3b2a46607a94efd2936ae7094a9ef7421e76 Mon Sep 17 00:00:00 2001
From: Tomasz Torcz <tomek at pipebreaker.pl>
Date: Fri, 7 Sep 2012 14:14:44 +0200
Subject: [PATCH] Try to start rescue.target if default.target is missing

In rare cases when default.target symlink is missing, systemd fails
instantly and gets into reboot loop.
Noticed by XReaper on IRC.
Be a bit more resilient, try to fallback to rescue.target first.
---
 src/core/main.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/core/main.c b/src/core/main.c
index 7b5c861..60e213a 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -1301,7 +1301,17 @@ int main(int argc, char *argv[]) {
         r = set_default_unit(SPECIAL_DEFAULT_TARGET);
         if (r < 0) {
                 log_error("Failed to set default unit %s: %s", SPECIAL_DEFAULT_TARGET, strerror(-r));
-                goto finish;
+
+		if (arg_running_as == MANAGER_USER) 
+			goto finish;
+		else {
+			/* Give administrator a chance to fix things */
+			r = set_default_unit(SPECIAL_RESCUE_TARGET);
+			if (r < 0) {
+				log_error("Failed to set %s: %s", SPECIAL_RESCUE_TARGET, strerror(-r));
+	                	goto finish;
+			}
+		}
         }
 
         /* By default, mount "cpu" and "cpuacct" together */
-- 
1.7.11.4


-- 
Tomasz Torcz              ,,If you try to upissue this patchset I shall be seeking
xmpp: zdzichubg at chrome.pl   an IP-routable hand grenade.'' -- Andrew Morton (LKML)



More information about the systemd-devel mailing list