Changeset 1770 in MondoRescue for branches/stable/mindi-busybox/loginutils/vlock.c
- Timestamp:
- Nov 6, 2007, 11:01:53 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mindi-busybox/loginutils/vlock.c
r821 r1770 1 1 /* vi: set sw=4 ts=4: */ 2 2 3 /* 3 4 * vlock implementation for busybox … … 16 17 * It now works with md5, sha1, etc passwords. */ 17 18 18 #include <stdio.h> 19 #include <stdlib.h> 19 #include "libbb.h" 20 20 #include <sys/vt.h> 21 #include <signal.h>22 #include <string.h>23 #include <unistd.h>24 #include <fcntl.h>25 #include <errno.h>26 #include <sys/ioctl.h>27 #include <termios.h>28 29 #include "busybox.h"30 21 31 22 static struct passwd *pw; … … 37 28 static void release_vt(int signo) 38 29 { 39 if (!o_lock_all) 40 ioctl(vfd, VT_RELDISP, 1); 41 else 42 ioctl(vfd, VT_RELDISP, 0); 30 ioctl(vfd, VT_RELDISP, !o_lock_all); 43 31 } 44 32 … … 54 42 } 55 43 44 int vlock_main(int argc, char **argv); 56 45 int vlock_main(int argc, char **argv) 57 46 { … … 60 49 struct vt_mode vtm; 61 50 struct termios term; 51 uid_t uid = getuid(); 52 53 pw = getpwuid(uid); 54 if (pw == NULL) 55 bb_error_msg_and_die("unknown uid %d", uid); 62 56 63 57 if (argc > 2) { … … 65 59 } 66 60 67 o_lock_all = bb_getopt_ulflags (argc,argv, "a");61 o_lock_all = getopt32(argv, "a"); 68 62 69 if((pw = getpwuid(getuid())) == NULL) { 70 bb_error_msg_and_die("Unknown uid %d", getuid()); 71 } 63 vfd = xopen(CURRENT_TTY, O_RDWR); 72 64 73 vfd = bb_xopen(CURRENT_TTY, O_RDWR); 74 75 if (ioctl(vfd, VT_GETMODE, &vtm) < 0) { 76 bb_perror_msg_and_die("VT_GETMODE"); 77 } 65 xioctl(vfd, VT_GETMODE, &vtm); 78 66 79 67 /* mask a bunch of signals */ … … 118 106 119 107 do { 120 printf("Virtual Console%s locked.\n%s's ", (o_lock_all) ? "s" : "", pw->pw_name); 121 fflush(stdout); 122 if (correct_password (pw)) { 108 printf("Virtual Console%s locked by %s.\n", (o_lock_all) ? "s" : "", pw->pw_name); 109 if (correct_password(pw)) { 123 110 break; 124 111 } 125 112 bb_do_delay(FAIL_DELAY); 126 puts("Password incorrect .");113 puts("Password incorrect"); 127 114 } while (1); 128 115 restore_terminal(); 129 return 0;116 fflush_stdout_and_exit(0); 130 117 }
Note:
See TracChangeset
for help on using the changeset viewer.