From 2a6ddd22196bcc76c5567596e3b9c7da6be48604 Mon Sep 17 00:00:00 2001 From: toni Date: Mon, 26 Dec 2016 15:35:41 +0100 Subject: improved passphrase input --- src/shell/shell.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src/shell') 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 +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; -- cgit v1.2.3