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:
@@ -1046,7 +1046,7 @@ int lock_dev_console(void) {
|
||||
return TAKE_FD(fd);
|
||||
}
|
||||
|
||||
int make_console_stdio(void) {
|
||||
int make_console_stdio(bool switch_to_text) {
|
||||
int fd, r;
|
||||
|
||||
/* Make /dev/console the controlling terminal and stdin/stdout/stderr, if we can. If we can't use
|
||||
@@ -1062,7 +1062,7 @@ int make_console_stdio(void) {
|
||||
return log_error_errno(r, "Failed to make /dev/null stdin/stdout/stderr: %m");
|
||||
|
||||
} else {
|
||||
reset_dev_console_fd(fd, /* switch_to_text= */ true);
|
||||
reset_dev_console_fd(fd, switch_to_text);
|
||||
|
||||
r = rearrange_stdio(fd, fd, fd); /* This invalidates 'fd' both on success and on failure. */
|
||||
if (r < 0)
|
||||
|
||||
@@ -112,7 +112,7 @@ int vtnr_from_tty(const char *tty);
|
||||
|
||||
void reset_dev_console_fd(int fd, bool switch_to_text);
|
||||
int lock_dev_console(void);
|
||||
int make_console_stdio(void);
|
||||
int make_console_stdio(bool switch_to_text);
|
||||
|
||||
int getenv_columns(void);
|
||||
int fd_columns(int fd);
|
||||
|
||||
Reference in New Issue
Block a user