diff options
author | Eric Andersen <andersen@codepoet.org> | 2004-05-01 01:27:30 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2004-05-01 01:27:30 +0000 |
commit | 6f9a7783ce2f3ffae28176f8bcfcd6b86c1b41b3 (patch) | |
tree | c8d14b02f851c42acde95b53c77527e5461c885b /loginutils/sulogin.c | |
parent | 90d2bff4c67d65a4025451213d5028c539b7b91a (diff) | |
download | busybox-w32-6f9a7783ce2f3ffae28176f8bcfcd6b86c1b41b3.tar.gz busybox-w32-6f9a7783ce2f3ffae28176f8bcfcd6b86c1b41b3.tar.bz2 busybox-w32-6f9a7783ce2f3ffae28176f8bcfcd6b86c1b41b3.zip |
Do not use getpass(3)
Diffstat (limited to 'loginutils/sulogin.c')
-rw-r--r-- | loginutils/sulogin.c | 28 |
1 files changed, 1 insertions, 27 deletions
diff --git a/loginutils/sulogin.c b/loginutils/sulogin.c index bb4716e0d..f21b09571 100644 --- a/loginutils/sulogin.c +++ b/loginutils/sulogin.c | |||
@@ -5,7 +5,6 @@ | |||
5 | #include <stdlib.h> | 5 | #include <stdlib.h> |
6 | #include <string.h> | 6 | #include <string.h> |
7 | #include <syslog.h> | 7 | #include <syslog.h> |
8 | #include <termios.h> | ||
9 | #include <unistd.h> | 8 | #include <unistd.h> |
10 | #include <utmp.h> | 9 | #include <utmp.h> |
11 | #include <sys/resource.h> | 10 | #include <sys/resource.h> |
@@ -55,7 +54,6 @@ extern int sulogin_main(int argc, char **argv) | |||
55 | const char *name = "root"; | 54 | const char *name = "root"; |
56 | int timeout = 0; | 55 | int timeout = 0; |
57 | static char pass[BUFSIZ]; | 56 | static char pass[BUFSIZ]; |
58 | struct termios termio; | ||
59 | struct passwd pwent; | 57 | struct passwd pwent; |
60 | struct passwd *pwd; | 58 | struct passwd *pwd; |
61 | time_t start, now; | 59 | time_t start, now; |
@@ -64,28 +62,6 @@ extern int sulogin_main(int argc, char **argv) | |||
64 | struct spwd *spwd = NULL; | 62 | struct spwd *spwd = NULL; |
65 | #endif /* CONFIG_FEATURE_SHADOWPASSWDS */ | 63 | #endif /* CONFIG_FEATURE_SHADOWPASSWDS */ |
66 | 64 | ||
67 | tcgetattr(0, &termio); | ||
68 | /* set control chars */ | ||
69 | termio.c_cc[VINTR] = 3; /* C-c */ | ||
70 | termio.c_cc[VQUIT] = 28; /* C-\ */ | ||
71 | termio.c_cc[VERASE] = 127; /* C-? */ | ||
72 | termio.c_cc[VKILL] = 21; /* C-u */ | ||
73 | termio.c_cc[VEOF] = 4; /* C-d */ | ||
74 | termio.c_cc[VSTART] = 17; /* C-q */ | ||
75 | termio.c_cc[VSTOP] = 19; /* C-s */ | ||
76 | termio.c_cc[VSUSP] = 26; /* C-z */ | ||
77 | /* use line dicipline 0 */ | ||
78 | termio.c_line = 0; | ||
79 | /* Make it be sane */ | ||
80 | termio.c_cflag &= CBAUD|CBAUDEX|CSIZE|CSTOPB|PARENB|PARODD; | ||
81 | termio.c_cflag |= CREAD|HUPCL|CLOCAL; | ||
82 | /* input modes */ | ||
83 | termio.c_iflag = ICRNL | IXON | IXOFF; | ||
84 | /* output modes */ | ||
85 | termio.c_oflag = OPOST | ONLCR; | ||
86 | /* local modes */ | ||
87 | termio.c_lflag = ISIG | ICANON | ECHO | ECHOE | ECHOK | ECHOCTL | ECHOKE | IEXTEN; | ||
88 | tcsetattr(0, TCSANOW, &termio); | ||
89 | openlog("sulogin", LOG_PID | LOG_CONS | LOG_NOWAIT, LOG_AUTH); | 65 | openlog("sulogin", LOG_PID | LOG_CONS | LOG_NOWAIT, LOG_AUTH); |
90 | if (argc > 1) { | 66 | if (argc > 1) { |
91 | if (strncmp(argv[1], "-t", 2) == 0) { | 67 | if (strncmp(argv[1], "-t", 2) == 0) { |
@@ -132,7 +108,6 @@ extern int sulogin_main(int argc, char **argv) | |||
132 | 108 | ||
133 | 109 | ||
134 | signal(SIGALRM, catchalarm); | 110 | signal(SIGALRM, catchalarm); |
135 | alarm(timeout); | ||
136 | if (!(pwd = getpwnam(name))) { | 111 | if (!(pwd = getpwnam(name))) { |
137 | syslog(LOG_WARNING, "No password entry for `root'\n"); | 112 | syslog(LOG_WARNING, "No password entry for `root'\n"); |
138 | bb_error_msg_and_die("No password entry for `root'\n"); | 113 | bb_error_msg_and_die("No password entry for `root'\n"); |
@@ -150,7 +125,7 @@ extern int sulogin_main(int argc, char **argv) | |||
150 | } | 125 | } |
151 | #endif /* CONFIG_FEATURE_SHADOWPASSWDS */ | 126 | #endif /* CONFIG_FEATURE_SHADOWPASSWDS */ |
152 | while (1) { | 127 | while (1) { |
153 | cp = getpass(SULOGIN_PROMPT); | 128 | cp = bb_askpass(timeout, SULOGIN_PROMPT); |
154 | if (!cp || !*cp) { | 129 | if (!cp || !*cp) { |
155 | puts("\n"); | 130 | puts("\n"); |
156 | fflush(stdout); | 131 | fflush(stdout); |
@@ -174,7 +149,6 @@ extern int sulogin_main(int argc, char **argv) | |||
174 | syslog(LOG_WARNING, "Incorrect root password\n"); | 149 | syslog(LOG_WARNING, "Incorrect root password\n"); |
175 | } | 150 | } |
176 | bzero(pass, strlen(pass)); | 151 | bzero(pass, strlen(pass)); |
177 | alarm(0); | ||
178 | signal(SIGALRM, SIG_DFL); | 152 | signal(SIGALRM, SIG_DFL); |
179 | puts("Entering System Maintenance Mode\n"); | 153 | puts("Entering System Maintenance Mode\n"); |
180 | fflush(stdout); | 154 | fflush(stdout); |