diff options
author | Denis Vlasenko | 2007-09-27 10:12:02 +0000 |
---|---|---|
committer | Denis Vlasenko | 2007-09-27 10:12:02 +0000 |
commit | 33b900f984e7397c4143c580eef9c8930677a9e2 (patch) | |
tree | 65d42590231bc868543a3b14666350ca5e384807 /loginutils | |
parent | 5d61e71c3a8ac3296afbfe9a014c62050c5a9234 (diff) | |
download | busybox-33b900f984e7397c4143c580eef9c8930677a9e2.zip busybox-33b900f984e7397c4143c580eef9c8930677a9e2.tar.gz |
vlock: get rid of statics
Diffstat (limited to 'loginutils')
-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 d18a9f2..8e3a1ea 100644 --- a/loginutils/vlock.c +++ b/loginutils/vlock.c @@ -19,15 +19,13 @@ #include "libbb.h" #include <sys/vt.h> -static struct passwd *pw; -static struct vt_mode ovtm; -static struct termios oterm; -static int vfd; -static unsigned long o_lock_all; +enum { vfd = 3 }; + +/* static unsigned long o_lock_all; */ static void release_vt(int signo) { - ioctl(vfd, VT_RELDISP, !o_lock_all); + ioctl(vfd, VT_RELDISP, (unsigned long) !option_mask32 /*!o_lock_all*/); } static void acquire_vt(int signo) @@ -35,12 +33,6 @@ static void acquire_vt(int signo) ioctl(vfd, VT_RELDISP, VT_ACKACQ); } -static void restore_terminal(void) -{ - ioctl(vfd, VT_SETMODE, &ovtm); - tcsetattr(STDIN_FILENO, TCSANOW, &oterm); -} - int vlock_main(int argc, char **argv); int vlock_main(int argc, char **argv) { @@ -48,8 +40,12 @@ int vlock_main(int argc, char **argv) struct sigaction sa; struct vt_mode vtm; struct termios term; - uid_t uid = getuid(); + struct termios oterm; + struct vt_mode ovtm; + uid_t uid; + struct passwd *pw; + uid = getuid(); pw = getpwuid(uid); if (pw == NULL) bb_error_msg_and_die("unknown uid %d", uid); @@ -58,10 +54,10 @@ int vlock_main(int argc, char **argv) bb_show_usage(); } - o_lock_all = getopt32(argv, "a"); - - vfd = xopen(CURRENT_TTY, O_RDWR); + /*o_lock_all = */getopt32(argv, "a"); + /* Avoid using statics - use constant fd */ + xmove_fd(xopen(CURRENT_TTY, O_RDWR), vfd); xioctl(vfd, VT_GETMODE, &vtm); /* mask a bunch of signals */ @@ -105,13 +101,17 @@ int vlock_main(int argc, char **argv) tcsetattr(STDIN_FILENO, TCSANOW, &term); do { - printf("Virtual Console%s locked by %s.\n", (o_lock_all) ? "s" : "", pw->pw_name); + printf("Virtual console%s locked by %s.\n", + option_mask32 /*o_lock_all*/ ? "s" : "", + pw->pw_name); if (correct_password(pw)) { break; } bb_do_delay(FAIL_DELAY); puts("Password incorrect"); } while (1); - restore_terminal(); + + ioctl(vfd, VT_SETMODE, &ovtm); + tcsetattr(STDIN_FILENO, TCSANOW, &oterm); fflush_stdout_and_exit(0); } |