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) {
|
||||
int n;
|
||||
int is_tty = !read_pw_from_stdin;
|
||||
int infd = -1;
|
||||
int outfd = -1;
|
||||
int infd;
|
||||
int outfd;
|
||||
|
||||
struct termios term;
|
||||
|
||||
|
@ -16,13 +16,9 @@ char* readpassphrase(const char* prompt, char* buf, size_t bufsz, int read_pw_fr
|
|||
outfd = 1;
|
||||
is_tty = tcgetattr(outfd, &term) == 0;
|
||||
} else {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (tcgetattr(i, &term) == 0) {
|
||||
infd = i;
|
||||
outfd = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
infd = outfd = open("/dev/tty", O_RDWR);
|
||||
if (!(infd >= 0 && tcgetattr(outfd, &term) == 0))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (infd < 0)
|
||||
|
|
Loading…
Add table
Reference in a new issue