tizen 2.3.1 release
[external/busybox.git] / debian / patches / vlock-disable-linux-console-calls-on-other-systems.patch
1 From 68fca4cd55e7bf6075eb1ccd303ae57a7ec1b8da Mon Sep 17 00:00:00 2001
2 From: Jeremie Koenig <jk@jk.fr.eu.org>
3 Date: Thu, 29 Jul 2010 04:29:52 +0200
4 Subject: [PATCH 12/12] vlock: disable linux console calls on other systems
5
6 Signed-off-by: Jeremie Koenig <jk@jk.fr.eu.org>
7 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
8 ---
9  loginutils/Config.src |    1 -
10  loginutils/vlock.c    |   15 +++++++++++++--
11  2 files changed, 13 insertions(+), 3 deletions(-)
12
13 diff --git a/loginutils/Config.src b/loginutils/Config.src
14 index 6ec2893..5d497c4 100644
15 --- a/loginutils/Config.src
16 +++ b/loginutils/Config.src
17 @@ -295,7 +295,6 @@ config SULOGIN
18  config VLOCK
19         bool "vlock"
20         default y
21 -       depends on PLATFORM_LINUX
22         select FEATURE_SUID
23         help
24           Build the "vlock" applet which allows you to lock (virtual) terminals.
25 diff --git a/loginutils/vlock.c b/loginutils/vlock.c
26 index 85f489c..59aeb54 100644
27 --- a/loginutils/vlock.c
28 +++ b/loginutils/vlock.c
29 @@ -15,9 +15,11 @@
30  /* Fixed by Erik Andersen to do passwords the tinylogin way...
31   * It now works with md5, sha1, etc passwords. */
32  
33 -#include <sys/vt.h>
34  #include "libbb.h"
35  
36 +#ifdef __linux__
37 +#include <sys/vt.h>
38 +
39  static void release_vt(int signo UNUSED_PARAM)
40  {
41         /* If -a, param is 0, which means:
42 @@ -30,14 +32,17 @@ static void acquire_vt(int signo UNUSED_PARAM)
43         /* ACK to kernel that switch to console is successful */
44         ioctl(STDIN_FILENO, VT_RELDISP, VT_ACKACQ);
45  }
46 +#endif
47  
48  int vlock_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
49  int vlock_main(int argc UNUSED_PARAM, char **argv)
50  {
51 +#ifdef __linux__
52         struct vt_mode vtm;
53 +       struct vt_mode ovtm;
54 +#endif
55         struct termios term;
56         struct termios oterm;
57 -       struct vt_mode ovtm;
58         struct passwd *pw;
59  
60         pw = xgetpwuid(getuid());
61 @@ -55,6 +60,7 @@ int vlock_main(int argc UNUSED_PARAM, char **argv)
62                 + (1 << SIGINT )
63                 , SIG_IGN);
64  
65 +#ifdef __linux__
66         /* We will use SIGUSRx for console switch control: */
67         /* 1: set handlers */
68         signal_SA_RESTART_empty_mask(SIGUSR1, release_vt);
69 @@ -62,12 +68,14 @@ int vlock_main(int argc UNUSED_PARAM, char **argv)
70         /* 2: unmask them */
71         sig_unblock(SIGUSR1);
72         sig_unblock(SIGUSR2);
73 +#endif
74  
75         /* Revert stdin/out to our controlling tty
76          * (or die if we have none) */
77         xmove_fd(xopen(CURRENT_TTY, O_RDWR), STDIN_FILENO);
78         xdup2(STDIN_FILENO, STDOUT_FILENO);
79  
80 +#ifdef __linux__
81         xioctl(STDIN_FILENO, VT_GETMODE, &vtm);
82         ovtm = vtm;
83         /* "console switches are controlled by us, not kernel!" */
84 @@ -75,6 +83,7 @@ int vlock_main(int argc UNUSED_PARAM, char **argv)
85         vtm.relsig = SIGUSR1;
86         vtm.acqsig = SIGUSR2;
87         ioctl(STDIN_FILENO, VT_SETMODE, &vtm);
88 +#endif
89  
90         tcgetattr(STDIN_FILENO, &oterm);
91         term = oterm;
92 @@ -95,7 +104,9 @@ int vlock_main(int argc UNUSED_PARAM, char **argv)
93                 puts("Password incorrect");
94         } while (1);
95  
96 +#ifdef __linux__
97         ioctl(STDIN_FILENO, VT_SETMODE, &ovtm);
98 +#endif
99         tcsetattr_stdin_TCSANOW(&oterm);
100         fflush_stdout_and_exit(EXIT_SUCCESS);
101  }
102 -- 
103 1.7.1
104