mirror of https://github.com/skeeto/enchive.git
Check write() from TTY prompt.
parent
bb46184a49
commit
1716985257
|
@ -92,7 +92,8 @@ get_passphrase(char *buf, size_t len, char *prompt)
|
||||||
char newline = '\n';
|
char newline = '\n';
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
struct termios old, new;
|
struct termios old, new;
|
||||||
write(tty, prompt, strlen(prompt));
|
if (write(tty, prompt, strlen(prompt)) == -1)
|
||||||
|
fatal("error asking for passphrase");
|
||||||
tcgetattr(tty, &old);
|
tcgetattr(tty, &old);
|
||||||
new = old;
|
new = old;
|
||||||
new.c_lflag &= ~ECHO;
|
new.c_lflag &= ~ECHO;
|
||||||
|
@ -105,7 +106,8 @@ get_passphrase(char *buf, size_t len, char *prompt)
|
||||||
}
|
}
|
||||||
buf[i] = 0;
|
buf[i] = 0;
|
||||||
tcsetattr(tty, TCSANOW, &old);
|
tcsetattr(tty, TCSANOW, &old);
|
||||||
write(tty, &newline, 1);
|
if (write(tty, &newline, 1) == -1)
|
||||||
|
fatal("error asking for passphrase");
|
||||||
close(tty);
|
close(tty);
|
||||||
if (errno)
|
if (errno)
|
||||||
fatal("could not read passphrase from /dev/tty");
|
fatal("could not read passphrase from /dev/tty");
|
||||||
|
|
Loading…
Reference in New Issue