summaryrefslogtreecommitdiff
path: root/src/vconsole
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/vconsole
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/vconsole')
-rw-r--r--src/vconsole/vconsole-setup.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/vconsole/vconsole-setup.c b/src/vconsole/vconsole-setup.c
index 1feb8d9370..140e0badd2 100644
--- a/src/vconsole/vconsole-setup.c
+++ b/src/vconsole/vconsole-setup.c
@@ -76,6 +76,13 @@ static int toggle_utf8(const char *name, int fd, bool utf8) {
assert(name);
+ r = vt_verify_kbmode(fd);
+ if (r == -EBUSY) {
+ log_warning_errno(r, "Virtual console %s is not in K_XLATE or K_UNICODE: %m", name);
+ return 0;
+ } else if (r < 0)
+ return log_warning_errno(r, "Failed to verify kbdmode on %s: %m", name);
+
r = ioctl(fd, KDSKBMODE, utf8 ? K_UNICODE : K_XLATE);
if (r < 0)
return log_warning_errno(errno, "Failed to %s UTF-8 kbdmode on %s: %m", enable_disable(utf8), name);