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:
12
tgetpass.c
12
tgetpass.c
@@ -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
|
||||||
|
Reference in New Issue
Block a user