aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-09-27 10:12:02 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-09-27 10:12:02 +0000
commit33b900f984e7397c4143c580eef9c8930677a9e2 (patch)
tree65d42590231bc868543a3b14666350ca5e384807
parent5d61e71c3a8ac3296afbfe9a014c62050c5a9234 (diff)
downloadbusybox-w32-33b900f984e7397c4143c580eef9c8930677a9e2.tar.gz
busybox-w32-33b900f984e7397c4143c580eef9c8930677a9e2.tar.bz2
busybox-w32-33b900f984e7397c4143c580eef9c8930677a9e2.zip
vlock: get rid of statics
-rw-r--r--loginutils/vlock.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/loginutils/vlock.c b/loginutils/vlock.c
index d18a9f272..8e3a1ea4b 100644
--- a/loginutils/vlock.c
+++ b/loginutils/vlock.c
@@ -19,15 +19,13 @@
19#include "libbb.h" 19#include "libbb.h"
20#include <sys/vt.h> 20#include <sys/vt.h>
21 21
22static struct passwd *pw; 22enum { vfd = 3 };
23static struct vt_mode ovtm; 23
24static struct termios oterm; 24/* static unsigned long o_lock_all; */
25static int vfd;
26static unsigned long o_lock_all;
27 25
28static void release_vt(int signo) 26static void release_vt(int signo)
29{ 27{
30 ioctl(vfd, VT_RELDISP, !o_lock_all); 28 ioctl(vfd, VT_RELDISP, (unsigned long) !option_mask32 /*!o_lock_all*/);
31} 29}
32 30
33static void acquire_vt(int signo) 31static void acquire_vt(int signo)
@@ -35,12 +33,6 @@ static void acquire_vt(int signo)
35 ioctl(vfd, VT_RELDISP, VT_ACKACQ); 33 ioctl(vfd, VT_RELDISP, VT_ACKACQ);
36} 34}
37 35
38static void restore_terminal(void)
39{
40 ioctl(vfd, VT_SETMODE, &ovtm);
41 tcsetattr(STDIN_FILENO, TCSANOW, &oterm);
42}
43
44int vlock_main(int argc, char **argv); 36int vlock_main(int argc, char **argv);
45int vlock_main(int argc, char **argv) 37int vlock_main(int argc, char **argv)
46{ 38{
@@ -48,8 +40,12 @@ int vlock_main(int argc, char **argv)
48 struct sigaction sa; 40 struct sigaction sa;
49 struct vt_mode vtm; 41 struct vt_mode vtm;
50 struct termios term; 42 struct termios term;
51 uid_t uid = getuid(); 43 struct termios oterm;
44 struct vt_mode ovtm;
45 uid_t uid;
46 struct passwd *pw;
52 47
48 uid = getuid();
53 pw = getpwuid(uid); 49 pw = getpwuid(uid);
54 if (pw == NULL) 50 if (pw == NULL)
55 bb_error_msg_and_die("unknown uid %d", uid); 51 bb_error_msg_and_die("unknown uid %d", uid);
@@ -58,10 +54,10 @@ int vlock_main(int argc, char **argv)
58 bb_show_usage(); 54 bb_show_usage();
59 } 55 }
60 56
61 o_lock_all = getopt32(argv, "a"); 57 /*o_lock_all = */getopt32(argv, "a");
62
63 vfd = xopen(CURRENT_TTY, O_RDWR);
64 58
59 /* Avoid using statics - use constant fd */
60 xmove_fd(xopen(CURRENT_TTY, O_RDWR), vfd);
65 xioctl(vfd, VT_GETMODE, &vtm); 61 xioctl(vfd, VT_GETMODE, &vtm);
66 62
67 /* mask a bunch of signals */ 63 /* mask a bunch of signals */
@@ -105,13 +101,17 @@ int vlock_main(int argc, char **argv)
105 tcsetattr(STDIN_FILENO, TCSANOW, &term); 101 tcsetattr(STDIN_FILENO, TCSANOW, &term);
106 102
107 do { 103 do {
108 printf("Virtual Console%s locked by %s.\n", (o_lock_all) ? "s" : "", pw->pw_name); 104 printf("Virtual console%s locked by %s.\n",
105 option_mask32 /*o_lock_all*/ ? "s" : "",
106 pw->pw_name);
109 if (correct_password(pw)) { 107 if (correct_password(pw)) {
110 break; 108 break;
111 } 109 }
112 bb_do_delay(FAIL_DELAY); 110 bb_do_delay(FAIL_DELAY);
113 puts("Password incorrect"); 111 puts("Password incorrect");
114 } while (1); 112 } while (1);
115 restore_terminal(); 113
114 ioctl(vfd, VT_SETMODE, &ovtm);
115 tcsetattr(STDIN_FILENO, TCSANOW, &oterm);
116 fflush_stdout_and_exit(0); 116 fflush_stdout_and_exit(0);
117} 117}