diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-09-27 10:12:02 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-09-27 10:12:02 +0000 |
commit | 33b900f984e7397c4143c580eef9c8930677a9e2 (patch) | |
tree | 65d42590231bc868543a3b14666350ca5e384807 | |
parent | 5d61e71c3a8ac3296afbfe9a014c62050c5a9234 (diff) | |
download | busybox-w32-33b900f984e7397c4143c580eef9c8930677a9e2.tar.gz busybox-w32-33b900f984e7397c4143c580eef9c8930677a9e2.tar.bz2 busybox-w32-33b900f984e7397c4143c580eef9c8930677a9e2.zip |
vlock: get rid of statics
-rw-r--r-- | loginutils/vlock.c | 36 |
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 | ||
22 | static struct passwd *pw; | 22 | enum { vfd = 3 }; |
23 | static struct vt_mode ovtm; | 23 | |
24 | static struct termios oterm; | 24 | /* static unsigned long o_lock_all; */ |
25 | static int vfd; | ||
26 | static unsigned long o_lock_all; | ||
27 | 25 | ||
28 | static void release_vt(int signo) | 26 | static 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 | ||
33 | static void acquire_vt(int signo) | 31 | static 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 | ||
38 | static void restore_terminal(void) | ||
39 | { | ||
40 | ioctl(vfd, VT_SETMODE, &ovtm); | ||
41 | tcsetattr(STDIN_FILENO, TCSANOW, &oterm); | ||
42 | } | ||
43 | |||
44 | int vlock_main(int argc, char **argv); | 36 | int vlock_main(int argc, char **argv); |
45 | int vlock_main(int argc, char **argv) | 37 | int 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 | } |