diff options
author | toni <matzeton@googlemail.com> | 2016-12-26 15:35:41 +0100 |
---|---|---|
committer | toni <matzeton@googlemail.com> | 2016-12-26 15:35:41 +0100 |
commit | 2a6ddd22196bcc76c5567596e3b9c7da6be48604 (patch) | |
tree | 0eb8272351524190330d90b64f297d7c019974cf | |
parent | c5a9d164b14e3ee015df264919302e772212a7b4 (diff) |
improved passphrase input
-rw-r--r-- | src/shell/shell.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/shell/shell.c b/src/shell/shell.c index 79b4792..771e447 100644 --- a/src/shell/shell.c +++ b/src/shell/shell.c @@ -6,6 +6,8 @@ #include <termios.h> +static const size_t maxTries = 5; + int main(int argc, char **argv) { struct termios old, new; @@ -23,13 +25,17 @@ int main(int argc, char **argv) { if ( tcsetattr(0, TCSANOW, &new) != 0 ) return -1; - printf("Enter a passphrase: "); - char *line = calloc(128, sizeof(char)); - size_t len = 128; - ssize_t read = getline(&line, &len, stdin); - if (write(passfifo_fd, line, len) == -1) - perror("write"); - printf("\n"); + size_t tries = 0; + while (tries++ < maxTries) { + printf("[%u/%u] Enter a passphrase: ", (unsigned int)tries, (unsigned int)maxTries); + char *line = calloc(128, sizeof(char)); + size_t len = 128; + ssize_t read = getline(&line, &len, stdin); + if (write(passfifo_fd, line, len) == -1) + perror("write"); + printf("\n"); + sleep(3); + } if ( tcsetattr(0, TCSANOW, &old) != 0 ) return -1; |