aboutsummaryrefslogtreecommitdiff
path: root/loginutils
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-10-20 19:20:22 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-10-20 19:20:22 +0000
commite5387a0574a4da88411753c4df959a03629063c9 (patch)
treede01aa892793e9fa1857551256500670280a8daf /loginutils
parent037576d77b62186551ad07b10eb46a73144b9f84 (diff)
downloadbusybox-w32-e5387a0574a4da88411753c4df959a03629063c9.tar.gz
busybox-w32-e5387a0574a4da88411753c4df959a03629063c9.tar.bz2
busybox-w32-e5387a0574a4da88411753c4df959a03629063c9.zip
bb_askpass: handle Ctrl-C, restore termoios on Ctrl-C.
sulogin: remove alarm handling, as it is redundant there. code shrink. After all differences cancel out: text data bss dec hex filename 777543 1000 9532 788075 c066b busybox_old 777543 1000 9532 788075 c066b busybox_unstripped
Diffstat (limited to 'loginutils')
-rw-r--r--loginutils/sulogin.c61
1 files changed, 31 insertions, 30 deletions
diff --git a/loginutils/sulogin.c b/loginutils/sulogin.c
index 7f100a162..f633fbbf1 100644
--- a/loginutils/sulogin.c
+++ b/loginutils/sulogin.c
@@ -9,29 +9,26 @@
9 9
10#include "libbb.h" 10#include "libbb.h"
11 11
12static const char *const forbid[] = { 12static const char forbid[] ALIGN1 =
13 "ENV", 13 "ENV" "\0"
14 "BASH_ENV", 14 "BASH_ENV" "\0"
15 "HOME", 15 "HOME" "\0"
16 "IFS", 16 "IFS" "\0"
17 "PATH", 17 "PATH" "\0"
18 "SHELL", 18 "SHELL" "\0"
19 "LD_LIBRARY_PATH", 19 "LD_LIBRARY_PATH" "\0"
20 "LD_PRELOAD", 20 "LD_PRELOAD" "\0"
21 "LD_TRACE_LOADED_OBJECTS", 21 "LD_TRACE_LOADED_OBJECTS" "\0"
22 "LD_BIND_NOW", 22 "LD_BIND_NOW" "\0"
23 "LD_AOUT_LIBRARY_PATH", 23 "LD_AOUT_LIBRARY_PATH" "\0"
24 "LD_AOUT_PRELOAD", 24 "LD_AOUT_PRELOAD" "\0"
25 "LD_NOWARN", 25 "LD_NOWARN" "\0"
26 "LD_KEEPDIR", 26 "LD_KEEPDIR" "\0";
27 (char *) 0 27
28}; 28//static void catchalarm(int ATTRIBUTE_UNUSED junk)
29 29//{
30 30// exit(EXIT_FAILURE);
31static void catchalarm(int ATTRIBUTE_UNUSED junk) 31//}
32{
33 exit(EXIT_FAILURE);
34}
35 32
36 33
37int sulogin_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 34int sulogin_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
@@ -40,7 +37,7 @@ int sulogin_main(int argc, char **argv)
40 char *cp; 37 char *cp;
41 int timeout = 0; 38 int timeout = 0;
42 char *timeout_arg; 39 char *timeout_arg;
43 const char *const *p; 40 const char *p;
44 struct passwd *pwd; 41 struct passwd *pwd;
45 const char *shell; 42 const char *shell;
46#if ENABLE_FEATURE_SHADOWPASSWDS 43#if ENABLE_FEATURE_SHADOWPASSWDS
@@ -71,10 +68,14 @@ int sulogin_main(int argc, char **argv)
71 } 68 }
72 69
73 /* Clear out anything dangerous from the environment */ 70 /* Clear out anything dangerous from the environment */
74 for (p = forbid; *p; p++) 71 p = forbid;
75 unsetenv(*p); 72 do {
73 unsetenv(p);
74 p += strlen(p) + 1;
75 } while (*p);
76 76
77 signal(SIGALRM, catchalarm); 77// bb_askpass() already handles this
78// signal(SIGALRM, catchalarm);
78 79
79 pwd = getpwuid(0); 80 pwd = getpwuid(0);
80 if (!pwd) { 81 if (!pwd) {
@@ -105,7 +106,7 @@ int sulogin_main(int argc, char **argv)
105 bb_error_msg("login incorrect"); 106 bb_error_msg("login incorrect");
106 } 107 }
107 memset(cp, 0, strlen(cp)); 108 memset(cp, 0, strlen(cp));
108 signal(SIGALRM, SIG_DFL); 109// signal(SIGALRM, SIG_DFL);
109 110
110 bb_info_msg("System Maintenance Mode"); 111 bb_info_msg("System Maintenance Mode");
111 112
@@ -122,6 +123,6 @@ int sulogin_main(int argc, char **argv)
122 /* Exec login shell with no additional parameters. Never returns. */ 123 /* Exec login shell with no additional parameters. Never returns. */
123 run_shell(shell, 1, NULL, NULL); 124 run_shell(shell, 1, NULL, NULL);
124 125
125auth_error: 126 auth_error:
126 bb_error_msg_and_die("no password entry for 'root'"); 127 bb_error_msg_and_die("no password entry for root");
127} 128}