core/main: fix logging of /sbin/init exec failure
Follow-up for 93e19483dc
While at it, avoid duplicate manager_status_printf()
(error_message will be shown in main()).
This commit is contained in:
committed by
Lennart Poettering
parent
b8790a875e
commit
fce19eb67f
+7
-6
@@ -2124,22 +2124,23 @@ static int do_reexecute(
|
||||
args[0] = "/sbin/init";
|
||||
(void) execv(args[0], (char* const*) args);
|
||||
r = -errno;
|
||||
|
||||
manager_status_printf(NULL, STATUS_TYPE_EMERGENCY,
|
||||
ANSI_HIGHLIGHT_RED " !! " ANSI_NORMAL,
|
||||
"Failed to execute /sbin/init");
|
||||
*ret_error_message = "Failed to execute /sbin/init";
|
||||
|
||||
if (r == -ENOENT) {
|
||||
manager_status_printf(NULL, STATUS_TYPE_EMERGENCY,
|
||||
ANSI_HIGHLIGHT_RED " !! " ANSI_NORMAL,
|
||||
"%s", *ret_error_message);
|
||||
|
||||
log_warning_errno(r, "No /sbin/init, trying fallback shell");
|
||||
|
||||
args[0] = "/bin/sh";
|
||||
args[1] = NULL;
|
||||
(void) execve(args[0], (char* const*) args, saved_env);
|
||||
r = -errno;
|
||||
*ret_error_message = "Failed to execute fallback shell";
|
||||
}
|
||||
|
||||
*ret_error_message = "Failed to execute fallback shell";
|
||||
return log_error_errno(r, "Failed to execute /bin/sh, giving up: %m");
|
||||
return log_error_errno(r, "%s, giving up: %m", *ret_error_message);
|
||||
}
|
||||
|
||||
static int invoke_main_loop(
|
||||
|
||||
Reference in New Issue
Block a user