2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-09-02 15:25:58 +00:00

now deals with timeout <= 0

This commit is contained in:
Todd C. Miller
1996-07-08 13:55:43 +00:00
parent bf55f57bd4
commit a27847e1ba

View File

@@ -165,6 +165,10 @@ char * tgetpass(prompt, timeout)
(void) rewind(output); (void) rewind(output);
} }
/*
* Timeout of <= 0 means no timeout
*/
if (timeout > 0) {
/* setup for select(2) */ /* setup for select(2) */
FD_ZERO(&readfds); FD_ZERO(&readfds);
FD_SET(fileno(input), &readfds); FD_SET(fileno(input), &readfds);
@@ -189,6 +193,14 @@ char * tgetpass(prompt, timeout)
if (buf[n - 1] == '\n') if (buf[n - 1] == '\n')
buf[n - 1] = '\0'; buf[n - 1] = '\0';
} }
} else {
buf[0] = '\0';
if (fgets(buf, sizeof(buf), input)) {
n = strlen(buf);
if (buf[n - 1] == '\n')
buf[n - 1] = '\0';
}
}
/* turn on echo */ /* turn on echo */
#ifdef HAVE_TERMIOS_H #ifdef HAVE_TERMIOS_H