summaryrefslogtreecommitdiff
path: root/libbb/bb_askpass.c
diff options
context:
space:
mode:
Diffstat (limited to 'libbb/bb_askpass.c')
-rw-r--r--libbb/bb_askpass.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/libbb/bb_askpass.c b/libbb/bb_askpass.c
index c976497..c0dcf0c 100644
--- a/libbb/bb_askpass.c
+++ b/libbb/bb_askpass.c
@@ -15,7 +15,11 @@ static void askpass_timeout(int UNUSED_PARAM ignore)
{
}
-char* FAST_FUNC bb_askpass(int timeout, const char *prompt)
+char* FAST_FUNC bb_ask_stdin(const char *prompt)
+{
+ return bb_ask(STDIN_FILENO, 0, prompt);
+}
+char* FAST_FUNC bb_ask(const int fd, int timeout, const char *prompt)
{
/* Was static char[BIGNUM] */
enum { sizeof_passwd = 128 };
@@ -30,8 +34,8 @@ char* FAST_FUNC bb_askpass(int timeout, const char *prompt)
passwd = xmalloc(sizeof_passwd);
memset(passwd, 0, sizeof_passwd);
- tcgetattr(STDIN_FILENO, &oldtio);
- tcflush(STDIN_FILENO, TCIFLUSH);
+ tcgetattr(fd, &oldtio);
+ tcflush(fd, TCIFLUSH);
tio = oldtio;
tio.c_iflag &= ~(IUCLC|IXON|IXOFF|IXANY);
tio.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHONL|TOSTOP);
@@ -52,7 +56,7 @@ char* FAST_FUNC bb_askpass(int timeout, const char *prompt)
ret = NULL;
/* On timeout or Ctrl-C, read will hopefully be interrupted,
* and we return NULL */
- if (read(STDIN_FILENO, passwd, sizeof_passwd - 1) > 0) {
+ if (read(fd, passwd, sizeof_passwd - 1) > 0) {
ret = passwd;
i = 0;
/* Last byte is guaranteed to be 0