Commit 53bea079 authored by Peter Hutterer's avatar Peter Hutterer

xfree86: always call KDSKBMODE on vt enter with logind

Where we're running with systemd-logind integration we have to assume that
logind may change the KDSKBMODE while we're VT-switched away. If that happens
and we return, our keyboard input may leak to the console.

Fix this by always calling K_OFF/K_RAW on VT switch back. We don't update
the current settings though, so on shutdown we will restore to settings we had
on init. Given the assumption is that if something messes with our vt, it will
mess again anyway, it's not worth the bother.

Fixes #857
Signed-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
parent 454b3a82
Pipeline #50814 passed with stages
in 9 minutes and 14 seconds
......@@ -28,5 +28,6 @@
int linux_parse_vt_settings(int may_fail);
int linux_get_keeptty(void);
void linux_block_tty_kbd(void);
#endif
......@@ -169,6 +169,36 @@ linux_get_keeptty(void)
return KeepTty;
}
void
linux_block_tty_kbd(void)
{
static Bool first_time = TRUE;
int ret;
if (xf86Info.ShareVTs)
return;
/* disable kernel special keys and buffering */
SYSCALL(ret = ioctl(xf86Info.consoleFd, KDSKBMODE, K_OFF));
if (ret < 0)
{
/* fine, just disable special keys */
SYSCALL(ret = ioctl(xf86Info.consoleFd, KDSKBMODE, K_RAW));
if (ret < 0)
FatalError("xf86OpenConsole: KDSKBMODE K_RAW failed %s\n",
strerror(errno));
/* ... and drain events, else the kernel gets angry. This
* is only necessary once on init but not after every VT switch.
*/
if (first_time)
{
xf86SetConsoleHandler(drain_console, NULL);
first_time = FALSE;
}
}
}
void
xf86OpenConsole(void)
{
......@@ -258,19 +288,7 @@ xf86OpenConsole(void)
tcgetattr(xf86Info.consoleFd, &tty_attr);
SYSCALL(ioctl(xf86Info.consoleFd, KDGKBMODE, &tty_mode));
/* disable kernel special keys and buffering */
SYSCALL(ret = ioctl(xf86Info.consoleFd, KDSKBMODE, K_OFF));
if (ret < 0)
{
/* fine, just disable special keys */
SYSCALL(ret = ioctl(xf86Info.consoleFd, KDSKBMODE, K_RAW));
if (ret < 0)
FatalError("xf86OpenConsole: KDSKBMODE K_RAW failed %s\n",
strerror(errno));
/* ... and drain events, else the kernel gets angry */
xf86SetConsoleHandler(drain_console, NULL);
}
linux_block_tty_kbd();
nTty = tty_attr;
nTty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
......
......@@ -255,6 +255,8 @@ systemd_logind_vtenter(void)
xf86VTEnter();
info->vt_active = TRUE;
linux_block_tty_kbd();
/* Activate any input devices which were resumed before the drm nodes */
for (pInfo = xf86InputDevs; pInfo; pInfo = pInfo->next)
if ((pInfo->flags & XI86_SERVER_FD) && pInfo->fd != -1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment