aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremie Koenig <jk@jk.fr.eu.org>2010-07-29 04:29:52 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-07-30 03:03:29 +0200
commit68fca4cd55e7bf6075eb1ccd303ae57a7ec1b8da (patch)
treef2a7a27063cb173e7898d367d97d500ae7c0c750
parente7a0632b7b38f635853a08c276dad2fbd395ba92 (diff)
downloadbusybox-w32-68fca4cd55e7bf6075eb1ccd303ae57a7ec1b8da.tar.gz
busybox-w32-68fca4cd55e7bf6075eb1ccd303ae57a7ec1b8da.tar.bz2
busybox-w32-68fca4cd55e7bf6075eb1ccd303ae57a7ec1b8da.zip
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>
-rw-r--r--loginutils/Config.src1
-rw-r--r--loginutils/vlock.c15
2 files changed, 13 insertions, 3 deletions
diff --git a/loginutils/Config.src b/loginutils/Config.src
index 6ec289355..5d497c4dc 100644
--- a/loginutils/Config.src
+++ b/loginutils/Config.src
@@ -295,7 +295,6 @@ config SULOGIN
295config VLOCK 295config VLOCK
296 bool "vlock" 296 bool "vlock"
297 default y 297 default y
298 depends on PLATFORM_LINUX
299 select FEATURE_SUID 298 select FEATURE_SUID
300 help 299 help
301 Build the "vlock" applet which allows you to lock (virtual) terminals. 300 Build the "vlock" applet which allows you to lock (virtual) terminals.
diff --git a/loginutils/vlock.c b/loginutils/vlock.c
index 85f489c22..59aeb54e8 100644
--- a/loginutils/vlock.c
+++ b/loginutils/vlock.c
@@ -15,9 +15,11 @@
15/* Fixed by Erik Andersen to do passwords the tinylogin way... 15/* Fixed by Erik Andersen to do passwords the tinylogin way...
16 * It now works with md5, sha1, etc passwords. */ 16 * It now works with md5, sha1, etc passwords. */
17 17
18#include <sys/vt.h>
19#include "libbb.h" 18#include "libbb.h"
20 19
20#ifdef __linux__
21#include <sys/vt.h>
22
21static void release_vt(int signo UNUSED_PARAM) 23static void release_vt(int signo UNUSED_PARAM)
22{ 24{
23 /* If -a, param is 0, which means: 25 /* If -a, param is 0, which means:
@@ -30,14 +32,17 @@ static void acquire_vt(int signo UNUSED_PARAM)
30 /* ACK to kernel that switch to console is successful */ 32 /* ACK to kernel that switch to console is successful */
31 ioctl(STDIN_FILENO, VT_RELDISP, VT_ACKACQ); 33 ioctl(STDIN_FILENO, VT_RELDISP, VT_ACKACQ);
32} 34}
35#endif
33 36
34int vlock_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 37int vlock_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
35int vlock_main(int argc UNUSED_PARAM, char **argv) 38int vlock_main(int argc UNUSED_PARAM, char **argv)
36{ 39{
40#ifdef __linux__
37 struct vt_mode vtm; 41 struct vt_mode vtm;
42 struct vt_mode ovtm;
43#endif
38 struct termios term; 44 struct termios term;
39 struct termios oterm; 45 struct termios oterm;
40 struct vt_mode ovtm;
41 struct passwd *pw; 46 struct passwd *pw;
42 47
43 pw = xgetpwuid(getuid()); 48 pw = xgetpwuid(getuid());
@@ -55,6 +60,7 @@ int vlock_main(int argc UNUSED_PARAM, char **argv)
55 + (1 << SIGINT ) 60 + (1 << SIGINT )
56 , SIG_IGN); 61 , SIG_IGN);
57 62
63#ifdef __linux__
58 /* We will use SIGUSRx for console switch control: */ 64 /* We will use SIGUSRx for console switch control: */
59 /* 1: set handlers */ 65 /* 1: set handlers */
60 signal_SA_RESTART_empty_mask(SIGUSR1, release_vt); 66 signal_SA_RESTART_empty_mask(SIGUSR1, release_vt);
@@ -62,12 +68,14 @@ int vlock_main(int argc UNUSED_PARAM, char **argv)
62 /* 2: unmask them */ 68 /* 2: unmask them */
63 sig_unblock(SIGUSR1); 69 sig_unblock(SIGUSR1);
64 sig_unblock(SIGUSR2); 70 sig_unblock(SIGUSR2);
71#endif
65 72
66 /* Revert stdin/out to our controlling tty 73 /* Revert stdin/out to our controlling tty
67 * (or die if we have none) */ 74 * (or die if we have none) */
68 xmove_fd(xopen(CURRENT_TTY, O_RDWR), STDIN_FILENO); 75 xmove_fd(xopen(CURRENT_TTY, O_RDWR), STDIN_FILENO);
69 xdup2(STDIN_FILENO, STDOUT_FILENO); 76 xdup2(STDIN_FILENO, STDOUT_FILENO);
70 77
78#ifdef __linux__
71 xioctl(STDIN_FILENO, VT_GETMODE, &vtm); 79 xioctl(STDIN_FILENO, VT_GETMODE, &vtm);
72 ovtm = vtm; 80 ovtm = vtm;
73 /* "console switches are controlled by us, not kernel!" */ 81 /* "console switches are controlled by us, not kernel!" */
@@ -75,6 +83,7 @@ int vlock_main(int argc UNUSED_PARAM, char **argv)
75 vtm.relsig = SIGUSR1; 83 vtm.relsig = SIGUSR1;
76 vtm.acqsig = SIGUSR2; 84 vtm.acqsig = SIGUSR2;
77 ioctl(STDIN_FILENO, VT_SETMODE, &vtm); 85 ioctl(STDIN_FILENO, VT_SETMODE, &vtm);
86#endif
78 87
79 tcgetattr(STDIN_FILENO, &oterm); 88 tcgetattr(STDIN_FILENO, &oterm);
80 term = oterm; 89 term = oterm;
@@ -95,7 +104,9 @@ int vlock_main(int argc UNUSED_PARAM, char **argv)
95 puts("Password incorrect"); 104 puts("Password incorrect");
96 } while (1); 105 } while (1);
97 106
107#ifdef __linux__
98 ioctl(STDIN_FILENO, VT_SETMODE, &ovtm); 108 ioctl(STDIN_FILENO, VT_SETMODE, &ovtm);
109#endif
99 tcsetattr_stdin_TCSANOW(&oterm); 110 tcsetattr_stdin_TCSANOW(&oterm);
100 fflush_stdout_and_exit(EXIT_SUCCESS); 111 fflush_stdout_and_exit(EXIT_SUCCESS);
101} 112}