summaryrefslogtreecommitdiff
path: root/src/basic/terminal-util.c
diff options
context:
space:
mode:
authorBalint Reczey <balint.reczey@canonical.com>2019-04-24 17:24:02 +0200
committerBalint Reczey <balint.reczey@canonical.com>2019-05-15 22:28:56 +0200
commit13a43c73d8cbac4b65472de04bb88ea1bacdeb89 (patch)
treebefdf5213d26e22dd79a84270941a84fea368f15 /src/basic/terminal-util.c
parentbb5ac84d79ac3aef606a4a9eeaafef94a1f199be (diff)
downloadsystemd-13a43c73d8cbac4b65472de04bb88ea1bacdeb89.tar.gz
Add check to switch VTs only between K_XLATE or K_UNICODE
Switching to K_UNICODE from other than L_XLATE can make the keyboard unusable and possibly leak keypresses from X. BugLink: https://launchpad.net/bugs/1803993
Diffstat (limited to 'src/basic/terminal-util.c')
-rw-r--r--src/basic/terminal-util.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c
index 3a9c85e5a0..0b71220ec4 100644
--- a/src/basic/terminal-util.c
+++ b/src/basic/terminal-util.c
@@ -1267,11 +1267,18 @@ int vt_verify_kbmode(int fd) {
}
int vt_reset_keyboard(int fd) {
- int kb;
+ int kb, r;
/* If we can't read the default, then default to unicode. It's 2017 after all. */
kb = vt_default_utf8() != 0 ? K_UNICODE : K_XLATE;
+ r = vt_verify_kbmode(fd);
+ if (r == -EBUSY) {
+ log_debug_errno(r, "Keyboard is not in XLATE or UNICODE mode, not resetting: %m");
+ return 0;
+ } else if (r < 0)
+ return r;
+
if (ioctl(fd, KDSKBMODE, kb) < 0)
return -errno;