shutdown: preserve console graphics mode across the exitrd handoff

make_console_stdio() forces KD_TEXT while reopening /dev/console. When
systemd-shutdown enters the exitrd, this can expose the text console over
a retained graphical shutdown splash.

Let callers choose whether to switch to text mode, and preserve the mode
for the exitrd handoff. Keep the existing text-mode behavior for manager
reexecution and the crash shell. Restore text mode if executing /shutdown
fails and before reporting a fatal error and freezing.

Add an unsafe, nonparallel virtual-console regression test requiring
explicit opt-in and an already-owned inactive VT in a disposable VM.
Check graphics preservation and text restoration through a private
/dev/console bind mount, retain stderr diagnostics, and restore the saved
mode in the parent even if the child fails.
This commit is contained in:
Birk Skyum
2026-09-23 11:36:55 +09:00
committed by Yu Watanabe
parent 137ce9b975
commit ef3e0ff7bb
7 changed files with 117 additions and 7 deletions
+1 -1
View File
@@ -2331,7 +2331,7 @@ static int do_reexecute(
log_warning_errno(r, "Failed to move /run/systemd/ to /run/systemd.pre-switch-root/, ignoring: %m");
/* Reopen the console */
(void) make_console_stdio();
(void) make_console_stdio(/* switch_to_text= */ true);
i = 1; /* Leave args[0] empty for now. */
for (int j = 1; j <= argc; j++)