gdm/SOURCES/0018-session-worker-fix-current-vt-detection-short-circui.patch
2021-10-08 11:13:47 +00:00

88 lines
3.0 KiB
Diff

From b9e5a2879a410b6a85be6c01c6f49cd7eb24c800 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Fri, 31 Aug 2018 15:20:39 -0400
Subject: [PATCH 18/51] session-worker: fix current vt detection short-circuit
logic
commit 8169cd4 attempts to avoid changing VTs if the active VT
is the same as the VT getting jumped to.
It fails to work, however, because accidentally treats a 0 return
code to the VT_GETSTATE ioctl as failure.
this commit fixes that.
---
daemon/gdm-session-worker.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/daemon/gdm-session-worker.c b/daemon/gdm-session-worker.c
index fd6470bab..391969d96 100644
--- a/daemon/gdm-session-worker.c
+++ b/daemon/gdm-session-worker.c
@@ -963,61 +963,61 @@ jump_to_vt (GdmSessionWorker *worker,
{
int fd;
int active_vt_tty_fd;
int active_vt = -1;
struct vt_stat vt_state = { 0 };
g_debug ("GdmSessionWorker: jumping to VT %d", vt_number);
active_vt_tty_fd = open ("/dev/tty0", O_RDWR | O_NOCTTY);
if (worker->priv->session_tty_fd != -1) {
fd = worker->priv->session_tty_fd;
g_debug ("GdmSessionWorker: first setting graphics mode to prevent flicker");
if (ioctl (fd, KDSETMODE, KD_GRAPHICS) < 0) {
g_debug ("GdmSessionWorker: couldn't set graphics mode: %m");
}
/* It's possible that the current VT was left in a broken
* combination of states (KD_GRAPHICS with VT_AUTO), that
* can't be switched away from. This call makes sure things
* are set in a way that VT_ACTIVATE should work and
* VT_WAITACTIVE shouldn't hang.
*/
fix_terminal_vt_mode (worker, active_vt_tty_fd);
} else {
fd = active_vt_tty_fd;
}
handle_terminal_vt_switches (worker, fd);
- if (ioctl (fd, VT_GETSTATE, &vt_state) <= 0) {
+ if (ioctl (fd, VT_GETSTATE, &vt_state) < 0) {
g_debug ("GdmSessionWorker: couldn't get current VT: %m");
} else {
active_vt = vt_state.v_active;
}
if (active_vt != vt_number) {
if (ioctl (fd, VT_ACTIVATE, vt_number) < 0) {
g_debug ("GdmSessionWorker: couldn't initiate jump to VT %d: %m",
vt_number);
} else if (ioctl (fd, VT_WAITACTIVE, vt_number) < 0) {
g_debug ("GdmSessionWorker: couldn't finalize jump to VT %d: %m",
vt_number);
}
}
close (active_vt_tty_fd);
}
static void
gdm_session_worker_set_state (GdmSessionWorker *worker,
GdmSessionWorkerState state)
{
if (worker->priv->state == state)
return;
worker->priv->state = state;
g_object_notify (G_OBJECT (worker), "state");
}
static void
--
2.27.0