Package: busybox / 1:1.17.1-8+deb6u11

vlock-disable-linux-console-calls-on-other-systems.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
From 68fca4cd55e7bf6075eb1ccd303ae57a7ec1b8da Mon Sep 17 00:00:00 2001
From: Jeremie Koenig <jk@jk.fr.eu.org>
Date: Thu, 29 Jul 2010 04:29:52 +0200
Subject: [PATCH 12/12] vlock: disable linux console calls on other systems

Signed-off-by: Jeremie Koenig <jk@jk.fr.eu.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
---
 loginutils/Config.src |    1 -
 loginutils/vlock.c    |   15 +++++++++++++--
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/loginutils/Config.src b/loginutils/Config.src
index 6ec2893..5d497c4 100644
--- a/loginutils/Config.src
+++ b/loginutils/Config.src
@@ -295,7 +295,6 @@ config SULOGIN
 config VLOCK
 	bool "vlock"
 	default y
-	depends on PLATFORM_LINUX
 	select FEATURE_SUID
 	help
 	  Build the "vlock" applet which allows you to lock (virtual) terminals.
diff --git a/loginutils/vlock.c b/loginutils/vlock.c
index 85f489c..59aeb54 100644
--- a/loginutils/vlock.c
+++ b/loginutils/vlock.c
@@ -15,9 +15,11 @@
 /* Fixed by Erik Andersen to do passwords the tinylogin way...
  * It now works with md5, sha1, etc passwords. */
 
-#include <sys/vt.h>
 #include "libbb.h"
 
+#ifdef __linux__
+#include <sys/vt.h>
+
 static void release_vt(int signo UNUSED_PARAM)
 {
 	/* If -a, param is 0, which means:
@@ -30,14 +32,17 @@ static void acquire_vt(int signo UNUSED_PARAM)
 	/* ACK to kernel that switch to console is successful */
 	ioctl(STDIN_FILENO, VT_RELDISP, VT_ACKACQ);
 }
+#endif
 
 int vlock_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
 int vlock_main(int argc UNUSED_PARAM, char **argv)
 {
+#ifdef __linux__
 	struct vt_mode vtm;
+	struct vt_mode ovtm;
+#endif
 	struct termios term;
 	struct termios oterm;
-	struct vt_mode ovtm;
 	struct passwd *pw;
 
 	pw = xgetpwuid(getuid());
@@ -55,6 +60,7 @@ int vlock_main(int argc UNUSED_PARAM, char **argv)
 		+ (1 << SIGINT )
 		, SIG_IGN);
 
+#ifdef __linux__
 	/* We will use SIGUSRx for console switch control: */
 	/* 1: set handlers */
 	signal_SA_RESTART_empty_mask(SIGUSR1, release_vt);
@@ -62,12 +68,14 @@ int vlock_main(int argc UNUSED_PARAM, char **argv)
 	/* 2: unmask them */
 	sig_unblock(SIGUSR1);
 	sig_unblock(SIGUSR2);
+#endif
 
 	/* Revert stdin/out to our controlling tty
 	 * (or die if we have none) */
 	xmove_fd(xopen(CURRENT_TTY, O_RDWR), STDIN_FILENO);
 	xdup2(STDIN_FILENO, STDOUT_FILENO);
 
+#ifdef __linux__
 	xioctl(STDIN_FILENO, VT_GETMODE, &vtm);
 	ovtm = vtm;
 	/* "console switches are controlled by us, not kernel!" */
@@ -75,6 +83,7 @@ int vlock_main(int argc UNUSED_PARAM, char **argv)
 	vtm.relsig = SIGUSR1;
 	vtm.acqsig = SIGUSR2;
 	ioctl(STDIN_FILENO, VT_SETMODE, &vtm);
+#endif
 
 	tcgetattr(STDIN_FILENO, &oterm);
 	term = oterm;
@@ -95,7 +104,9 @@ int vlock_main(int argc UNUSED_PARAM, char **argv)
 		puts("Password incorrect");
 	} while (1);
 
+#ifdef __linux__
 	ioctl(STDIN_FILENO, VT_SETMODE, &ovtm);
+#endif
 	tcsetattr_stdin_TCSANOW(&oterm);
 	fflush_stdout_and_exit(EXIT_SUCCESS);
 }
-- 
1.7.1