forked from soccera/rdo
Don't search for tty, open it directly.
This commit is contained in:
parent
2f0bdc7712
commit
b34d64fd5c
1 changed files with 5 additions and 9 deletions
|
@ -6,8 +6,8 @@
|
||||||
char* readpassphrase(const char* prompt, char* buf, size_t bufsz, int read_pw_from_stdin) {
|
char* readpassphrase(const char* prompt, char* buf, size_t bufsz, int read_pw_from_stdin) {
|
||||||
int n;
|
int n;
|
||||||
int is_tty = !read_pw_from_stdin;
|
int is_tty = !read_pw_from_stdin;
|
||||||
int infd = -1;
|
int infd;
|
||||||
int outfd = -1;
|
int outfd;
|
||||||
|
|
||||||
struct termios term;
|
struct termios term;
|
||||||
|
|
||||||
|
@ -16,13 +16,9 @@ char* readpassphrase(const char* prompt, char* buf, size_t bufsz, int read_pw_fr
|
||||||
outfd = 1;
|
outfd = 1;
|
||||||
is_tty = tcgetattr(outfd, &term) == 0;
|
is_tty = tcgetattr(outfd, &term) == 0;
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < 3; i++) {
|
infd = outfd = open("/dev/tty", O_RDWR);
|
||||||
if (tcgetattr(i, &term) == 0) {
|
if (!(infd >= 0 && tcgetattr(outfd, &term) == 0))
|
||||||
infd = i;
|
return NULL;
|
||||||
outfd = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (infd < 0)
|
if (infd < 0)
|
||||||
|
|
Loading…
Add table
Reference in a new issue