Package: kbd / 2.7.1-2+exp1

Check-for-X-in-kbd_mode.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
From: Denis Barbier <barbier@debian.org>
Date: Thu, 10 Dec 2015 20:31:03 +0100
Subject: Check for X in kbd_mode

Bug-Debian: http://bugs.debian.org/281305

"kbd_mode" can render X unusable.  Add checks to unicode_{start,stop} to
avoid the problem.

This patch originated in console-tools.
---
 src/unicode_start | 13 +++++++++++++
 src/unicode_stop  |  6 ++++++
 2 files changed, 19 insertions(+)

diff --git a/src/unicode_start b/src/unicode_start
index f1f3f0b..b123d90 100755
--- a/src/unicode_start
+++ b/src/unicode_start
@@ -13,6 +13,19 @@ esac
 
 # Enables Unicode processing in the current console.
 #
+
+if [ ! -e /proc/self/fd/0 ] ; then
+   echo "Won't set unicode mode: Can't determine console type;" >&2
+   echo " Please ensure that /proc is mounted." >&2
+   exit 1
+fi
+
+readlink /proc/self/fd/0 | grep -q -e /dev/vc -e '/dev/tty[^p]' -e /dev/console
+if [ $? -eq 1 ]; then
+    echo  "Won't set unicode mode: not a VT." >&2
+    exit 1
+fi
+
 # 1. The input side: the keyboard driver.
 
 # Set the keyboard driver in Unicode mode. (Default is ASCII mode.)
diff --git a/src/unicode_stop b/src/unicode_stop
index ed57d10..30a494f 100755
--- a/src/unicode_stop
+++ b/src/unicode_stop
@@ -1,5 +1,11 @@
 #!/bin/sh
 
+if [ ! -e /proc/self/fd/0 ] ; then
+   echo "Won't set ascii mode: Can't determine console type;" >&2
+   echo " Please ensure that /proc is mounted." >&2
+   exit 1
+fi
+
 TTY=$(/usr/bin/tty)
 case "$TTY" in
 	/dev/console|/dev/vc*|/dev/tty[0-9]*)