aboutsummaryrefslogtreecommitdiff
path: root/loginutils
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2004-05-01 01:27:30 +0000
committerEric Andersen <andersen@codepoet.org>2004-05-01 01:27:30 +0000
commit6f9a7783ce2f3ffae28176f8bcfcd6b86c1b41b3 (patch)
treec8d14b02f851c42acde95b53c77527e5461c885b /loginutils
parent90d2bff4c67d65a4025451213d5028c539b7b91a (diff)
downloadbusybox-w32-6f9a7783ce2f3ffae28176f8bcfcd6b86c1b41b3.tar.gz
busybox-w32-6f9a7783ce2f3ffae28176f8bcfcd6b86c1b41b3.tar.bz2
busybox-w32-6f9a7783ce2f3ffae28176f8bcfcd6b86c1b41b3.zip
Do not use getpass(3)
Diffstat (limited to 'loginutils')
-rw-r--r--loginutils/passwd.c6
-rw-r--r--loginutils/sulogin.c28
-rw-r--r--loginutils/vlock.c8
3 files changed, 7 insertions, 35 deletions
diff --git a/loginutils/passwd.c b/loginutils/passwd.c
index 269e529f3..d0b2afc19 100644
--- a/loginutils/passwd.c
+++ b/loginutils/passwd.c
@@ -332,7 +332,7 @@ static int new_password(const struct passwd *pw, int amroot, int algo)
332 time_t start, now; 332 time_t start, now;
333 333
334 if (!amroot && crypt_passwd[0]) { 334 if (!amroot && crypt_passwd[0]) {
335 if (!(clear = getpass("Old password:"))) { 335 if (!(clear = bb_askpass(0, "Old password:"))) {
336 /* return -1; */ 336 /* return -1; */
337 return 1; 337 return 1;
338 } 338 }
@@ -356,7 +356,7 @@ static int new_password(const struct passwd *pw, int amroot, int algo)
356 } else { 356 } else {
357 orig[0] = '\0'; 357 orig[0] = '\0';
358 } 358 }
359 if (! (cp=getpass("Enter the new password (minimum of 5, maximum of 8 characters)\n" 359 if (! (cp=bb_askpass(0, "Enter the new password (minimum of 5, maximum of 8 characters)\n"
360 "Please use a combination of upper and lower case letters and numbers.\n" 360 "Please use a combination of upper and lower case letters and numbers.\n"
361 "Enter new password: "))) 361 "Enter new password: ")))
362 { 362 {
@@ -375,7 +375,7 @@ static int new_password(const struct passwd *pw, int amroot, int algo)
375 return 1; 375 return 1;
376 } 376 }
377 } 377 }
378 if (!(cp = getpass("Re-enter new password: "))) { 378 if (!(cp = bb_askpass(0, "Re-enter new password: "))) {
379 bzero(orig, sizeof orig); 379 bzero(orig, sizeof orig);
380 /* return -1; */ 380 /* return -1; */
381 return 1; 381 return 1;
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);
diff --git a/loginutils/vlock.c b/loginutils/vlock.c
index 7abf120d9..def484ae6 100644
--- a/loginutils/vlock.c
+++ b/loginutils/vlock.c
@@ -193,10 +193,9 @@ extern int vlock_main(int argc, char **argv)
193 193
194 snprintf(prompt, 100, "%s's password: ", pw->pw_name); 194 snprintf(prompt, 100, "%s's password: ", pw->pw_name);
195 195
196 if ((pass = getpass(prompt)) == NULL) { 196 if ((pass = bb_askpass(0, prompt)) == NULL) {
197 perror("getpass");
198 restore_terminal(); 197 restore_terminal();
199 exit(1); 198 bb_perror_msg_and_die("password");
200 } 199 }
201 200
202 crypt_pass = pw_encrypt(pass, pw->pw_passwd); 201 crypt_pass = pw_encrypt(pass, pw->pw_passwd);
@@ -210,9 +209,8 @@ extern int vlock_main(int argc, char **argv)
210 memset(crypt_pass, 0, strlen(crypt_pass)); 209 memset(crypt_pass, 0, strlen(crypt_pass));
211 210
212 if (isatty(STDIN_FILENO) == 0) { 211 if (isatty(STDIN_FILENO) == 0) {
213 perror("isatty");
214 restore_terminal(); 212 restore_terminal();
215 exit(1); 213 bb_perror_msg_and_die("isatty");
216 } 214 }
217 215
218 sleep(++times); 216 sleep(++times);