diff options
author | Elie De Brauwer <eliedebrauwer@gmail.com> | 2012-07-20 08:42:44 +0200 |
---|---|---|
committer | Elie De Brauwer <eliedebrauwer@gmail.com> | 2012-07-20 08:42:44 +0200 |
commit | 21ef5ce1c65383829f9278588c37dda7c5b7dc1c (patch) | |
tree | e3360ca73198503357ed356421650b19a6fa8937 /toys/login.c | |
parent | a76ba3d58ad526e9ee9bb0d86671ba1f39d99729 (diff) | |
download | toybox-21ef5ce1c65383829f9278588c37dda7c5b7dc1c.tar.gz |
toys/login.c: make use of the read_passwd function offered by the passwd library.
Diffstat (limited to 'toys/login.c')
-rw-r--r-- | toys/login.c | 40 |
1 files changed, 1 insertions, 39 deletions
diff --git a/toys/login.c b/toys/login.c index ca62081a..78fa55f8 100644 --- a/toys/login.c +++ b/toys/login.c @@ -67,49 +67,11 @@ void sanitize_env() } while (*p); } -int read_password(char * buff, int buflen) -{ - int i = 0; - struct termios termio, oldtermio; - tcgetattr(0, &oldtermio); - tcflush(0, TCIFLUSH); - termio = oldtermio; - - termio.c_iflag &= ~(IUCLC|IXON|IXOFF|IXANY); - termio.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHONL|TOSTOP); - tcsetattr(0, TCSANOW, &termio); - - fputs("Password: ", stdout); - fflush(stdout); - - while (1) { - int ret = read(0, &buff[i], 1); - if ( ret < 0 ) - { - buff[0] = 0; - tcsetattr(0, TCSANOW, &oldtermio); - return 1; - } - else if ( ret == 0 || buff[i] == '\n' || - buff[i] == '\r' || buflen == i+1) - { - buff[i] = '\0'; - break; - } - i++; - } - - tcsetattr(0, TCSANOW, &oldtermio); - puts("\n"); - fflush(stdout); - return 0; -} - int verify_password(char * pwd) { char * pass; - if (read_password(toybuf, sizeof(toybuf))) + if (read_passwd(toybuf, sizeof(toybuf), "Password: ")) return 1; if (!pwd) return 1; |