diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-03-12 23:13:50 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-03-12 23:13:50 +0000 |
commit | 4cf1d08fc2e50f9abda999d468c5e972ff4995c2 (patch) | |
tree | 58dd8efdd7d0f0990d30d8b5f5f53cf2ee35d444 /loginutils | |
parent | 4e6d5117b839cef41cd3919966f95bf25d24d8d9 (diff) | |
download | busybox-w32-4cf1d08fc2e50f9abda999d468c5e972ff4995c2.tar.gz busybox-w32-4cf1d08fc2e50f9abda999d468c5e972ff4995c2.tar.bz2 busybox-w32-4cf1d08fc2e50f9abda999d468c5e972ff4995c2.zip |
nc: remove a bit of bloat
inetd: more NOMMU fixes
rx: shrink
devfsd: minor shrink
vlock: shrink
tcpudp: narrow down window where we have no wildcard socket
parse_one_line 1015 1102 +87
init_ring - 53 +53
xzalloc_lsa - 48 +48
read_byte 51 50 -1
rearm_alarm 28 25 -3
nc_main 1028 1000 -28
initring 53 - -53
vlock_main 583 496 -87
reread_config_file 1089 991 -98
rx_main 1046 912 -134
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 1/6 up/down: 188/-404) Total: -216 bytes
text data bss dec hex filename
800120 661 7428 808209 c5511 busybox_old
799796 661 7428 807885 c53cd busybox_unstripped
Diffstat (limited to 'loginutils')
-rw-r--r-- | loginutils/vlock.c | 84 |
1 files changed, 40 insertions, 44 deletions
diff --git a/loginutils/vlock.c b/loginutils/vlock.c index 6e928e239..846733ea8 100644 --- a/loginutils/vlock.c +++ b/loginutils/vlock.c | |||
@@ -1,5 +1,4 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | |||
3 | /* | 2 | /* |
4 | * vlock implementation for busybox | 3 | * vlock implementation for busybox |
5 | * | 4 | * |
@@ -16,27 +15,25 @@ | |||
16 | /* Fixed by Erik Andersen to do passwords the tinylogin way... | 15 | /* Fixed by Erik Andersen to do passwords the tinylogin way... |
17 | * It now works with md5, sha1, etc passwords. */ | 16 | * It now works with md5, sha1, etc passwords. */ |
18 | 17 | ||
19 | #include "libbb.h" | ||
20 | #include <sys/vt.h> | 18 | #include <sys/vt.h> |
21 | 19 | #include "libbb.h" | |
22 | enum { vfd = 3 }; | ||
23 | |||
24 | /* static unsigned long o_lock_all; */ | ||
25 | 20 | ||
26 | static void release_vt(int signo) | 21 | static void release_vt(int signo) |
27 | { | 22 | { |
28 | ioctl(vfd, VT_RELDISP, (unsigned long) !option_mask32 /*!o_lock_all*/); | 23 | /* If -a, param is 0, which means: |
24 | * "no, kernel, we don't allow console switch away from us!" */ | ||
25 | ioctl(STDIN_FILENO, VT_RELDISP, (unsigned long) !option_mask32); | ||
29 | } | 26 | } |
30 | 27 | ||
31 | static void acquire_vt(int signo) | 28 | static void acquire_vt(int signo) |
32 | { | 29 | { |
33 | ioctl(vfd, VT_RELDISP, VT_ACKACQ); | 30 | /* ACK to kernel that switch to console is successful */ |
31 | ioctl(STDIN_FILENO, VT_RELDISP, VT_ACKACQ); | ||
34 | } | 32 | } |
35 | 33 | ||
36 | int vlock_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 34 | int vlock_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
37 | int vlock_main(int argc, char **argv) | 35 | int vlock_main(int argc, char **argv) |
38 | { | 36 | { |
39 | sigset_t sig; | ||
40 | struct sigaction sa; | 37 | struct sigaction sa; |
41 | struct vt_mode vtm; | 38 | struct vt_mode vtm; |
42 | struct termios term; | 39 | struct termios term; |
@@ -48,49 +45,48 @@ int vlock_main(int argc, char **argv) | |||
48 | uid = getuid(); | 45 | uid = getuid(); |
49 | pw = getpwuid(uid); | 46 | pw = getpwuid(uid); |
50 | if (pw == NULL) | 47 | if (pw == NULL) |
51 | bb_error_msg_and_die("unknown uid %d", uid); | 48 | bb_error_msg_and_die("unknown uid %d", (int)uid); |
52 | 49 | ||
53 | if (argc > 2) { | 50 | opt_complementary = "=0"; /* no params! */ |
54 | bb_show_usage(); | 51 | getopt32(argv, "a"); |
55 | } | 52 | |
56 | 53 | /* Ignore some signals so that we don't get killed by them */ | |
57 | /*o_lock_all = */getopt32(argv, "a"); | 54 | bb_signals(0 |
58 | 55 | + (1 << SIGTSTP) | |
59 | /* Avoid using statics - use constant fd */ | 56 | + (1 << SIGTTIN) |
60 | xmove_fd(xopen(CURRENT_TTY, O_RDWR), vfd); | 57 | + (1 << SIGTTOU) |
61 | xioctl(vfd, VT_GETMODE, &vtm); | 58 | + (1 << SIGHUP ) |
62 | 59 | + (1 << SIGCHLD) /* paranoia :) */ | |
63 | /* mask a bunch of signals */ | 60 | + (1 << SIGQUIT) |
64 | sigprocmask(SIG_SETMASK, NULL, &sig); | 61 | + (1 << SIGINT ) |
65 | sigdelset(&sig, SIGUSR1); | 62 | , SIG_IGN); |
66 | sigdelset(&sig, SIGUSR2); | 63 | |
67 | sigaddset(&sig, SIGTSTP); | 64 | /* We will use SIGUSRx for console switch control: */ |
68 | sigaddset(&sig, SIGTTIN); | 65 | /* 1: set handlers */ |
69 | sigaddset(&sig, SIGTTOU); | 66 | sigemptyset(&sa.sa_mask); |
70 | sigaddset(&sig, SIGHUP); | ||
71 | sigaddset(&sig, SIGCHLD); | ||
72 | sigaddset(&sig, SIGQUIT); | ||
73 | sigaddset(&sig, SIGINT); | ||
74 | |||
75 | sigemptyset(&(sa.sa_mask)); | ||
76 | sa.sa_flags = SA_RESTART; | 67 | sa.sa_flags = SA_RESTART; |
77 | sa.sa_handler = release_vt; | 68 | sa.sa_handler = release_vt; |
78 | sigaction(SIGUSR1, &sa, NULL); | 69 | sigaction(SIGUSR1, &sa, NULL); |
79 | sa.sa_handler = acquire_vt; | 70 | sa.sa_handler = acquire_vt; |
80 | sigaction(SIGUSR2, &sa, NULL); | 71 | sigaction(SIGUSR2, &sa, NULL); |
81 | 72 | /* 2: unmask them */ | |
82 | /* need to handle some signals so that we don't get killed by them */ | 73 | sigprocmask(SIG_SETMASK, NULL, &sa.sa_mask); |
83 | sa.sa_handler = SIG_IGN; | 74 | sigdelset(&sa.sa_mask, SIGUSR1); |
84 | sigaction(SIGHUP, &sa, NULL); | 75 | sigdelset(&sa.sa_mask, SIGUSR2); |
85 | sigaction(SIGQUIT, &sa, NULL); | 76 | sigprocmask(SIG_SETMASK, &sa.sa_mask, NULL); |
86 | sigaction(SIGINT, &sa, NULL); | 77 | |
87 | sigaction(SIGTSTP, &sa, NULL); | 78 | /* Revert stdin/out to our controlling tty |
88 | 79 | * (or die if we have none) */ | |
80 | xmove_fd(xopen(CURRENT_TTY, O_RDWR), STDIN_FILENO); | ||
81 | xdup2(STDIN_FILENO, STDOUT_FILENO); | ||
82 | |||
83 | xioctl(STDIN_FILENO, VT_GETMODE, &vtm); | ||
89 | ovtm = vtm; | 84 | ovtm = vtm; |
85 | /* "console switches are controlled by us, not kernel!" */ | ||
90 | vtm.mode = VT_PROCESS; | 86 | vtm.mode = VT_PROCESS; |
91 | vtm.relsig = SIGUSR1; | 87 | vtm.relsig = SIGUSR1; |
92 | vtm.acqsig = SIGUSR2; | 88 | vtm.acqsig = SIGUSR2; |
93 | ioctl(vfd, VT_SETMODE, &vtm); | 89 | ioctl(STDIN_FILENO, VT_SETMODE, &vtm); |
94 | 90 | ||
95 | tcgetattr(STDIN_FILENO, &oterm); | 91 | tcgetattr(STDIN_FILENO, &oterm); |
96 | term = oterm; | 92 | term = oterm; |
@@ -111,7 +107,7 @@ int vlock_main(int argc, char **argv) | |||
111 | puts("Password incorrect"); | 107 | puts("Password incorrect"); |
112 | } while (1); | 108 | } while (1); |
113 | 109 | ||
114 | ioctl(vfd, VT_SETMODE, &ovtm); | 110 | ioctl(STDIN_FILENO, VT_SETMODE, &ovtm); |
115 | tcsetattr(STDIN_FILENO, TCSANOW, &oterm); | 111 | tcsetattr(STDIN_FILENO, TCSANOW, &oterm); |
116 | fflush_stdout_and_exit(0); | 112 | fflush_stdout_and_exit(0); |
117 | } | 113 | } |