mirror of
https://github.com/sudo-project/sudo.git
synced 2025-08-31 22:35:10 +00:00
now deals with timeout <= 0
This commit is contained in:
12
tgetpass.c
12
tgetpass.c
@@ -165,6 +165,10 @@ char * tgetpass(prompt, timeout)
|
||||
(void) rewind(output);
|
||||
}
|
||||
|
||||
/*
|
||||
* Timeout of <= 0 means no timeout
|
||||
*/
|
||||
if (timeout > 0) {
|
||||
/* setup for select(2) */
|
||||
FD_ZERO(&readfds);
|
||||
FD_SET(fileno(input), &readfds);
|
||||
@@ -189,6 +193,14 @@ char * tgetpass(prompt, timeout)
|
||||
if (buf[n - 1] == '\n')
|
||||
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 */
|
||||
#ifdef HAVE_TERMIOS_H
|
||||
|
Reference in New Issue
Block a user