diff options
author | Nick Mathewson <nickm@torproject.org> | 2015-06-17 10:41:22 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2015-06-17 10:41:22 -0400 |
commit | b9b658e727520d947e6c14475ee22e8606e9f062 (patch) | |
tree | 76a1997f4787d5879b2e3a57ac25f865fe426a60 /src/ext/readpassphrase.c | |
parent | 8d44ce910ddb00d6a9c18b912f2b027f822e5dc1 (diff) | |
download | tor-b9b658e727520d947e6c14475ee22e8606e9f062.tar.gz tor-b9b658e727520d947e6c14475ee22e8606e9f062.zip |
Add the openssh 6.8p1 readpassphrase implementation
This way glibc users don't have to fall back to getpass.
Windows users are still out of luck
Diffstat (limited to 'src/ext/readpassphrase.c')
-rw-r--r-- | src/ext/readpassphrase.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/ext/readpassphrase.c b/src/ext/readpassphrase.c index d63cdf2f0e..7bdecaf637 100644 --- a/src/ext/readpassphrase.c +++ b/src/ext/readpassphrase.c @@ -22,7 +22,7 @@ /* OPENBSD ORIGINAL: lib/libc/gen/readpassphrase.c */ -#include "includes.h" +#include "orconfig.h" #ifndef HAVE_READPASSPHRASE @@ -35,6 +35,10 @@ #include <string.h> #include <unistd.h> +#ifndef _PATH_TTY +# define _PATH_TTY "/dev/tty" +#endif + #ifdef TCSASOFT # define _T_FLUSH (TCSAFLUSH|TCSASOFT) #else @@ -61,6 +65,7 @@ static void handler(int); char * readpassphrase(const char *prompt, char *buf, size_t bufsiz, int flags) { + ssize_t bytes_written = 0; ssize_t nr; int input, output, save_errno, i, need_restart; char ch, *p, *end; @@ -132,7 +137,7 @@ restart: /* No I/O if we are already backgrounded. */ if (signo[SIGTTOU] != 1 && signo[SIGTTIN] != 1) { if (!(flags & RPP_STDIN)) - (void)write(output, prompt, strlen(prompt)); + bytes_written = write(output, prompt, strlen(prompt)); end = buf + bufsiz - 1; p = buf; while ((nr = read(input, &ch, 1)) == 1 && ch != '\n' && ch != '\r') { @@ -151,9 +156,11 @@ restart: *p = '\0'; save_errno = errno; if (!(term.c_lflag & ECHO)) - (void)write(output, "\n", 1); + bytes_written = write(output, "\n", 1); } + (void) bytes_written; + /* Restore old terminal settings and signals. */ if (memcmp(&term, &oterm, sizeof(term)) != 0) { while (tcsetattr(input, _T_FLUSH, &oterm) == -1 && |