From b3d0eb16f710f03dc6e4025e56897e937b9f3dbb Mon Sep 17 00:00:00 2001 From: toni Date: Wed, 6 Jul 2016 00:43:47 +0200 Subject: naskshell --- src/shell/shell.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/shell/shell.c (limited to 'src/shell') diff --git a/src/shell/shell.c b/src/shell/shell.c new file mode 100644 index 0000000..eff2566 --- /dev/null +++ b/src/shell/shell.c @@ -0,0 +1,37 @@ +#include +#include +#include +#include +#include +#include + + +int main(int argc, char **argv) { + struct termios old, new; + + int passfifo_fd = open("/lib/cryptsetup/passfifo", O_WRONLY); + if (passfifo_fd < 0) { + perror("open"); + return -1; + } + + if ( tcgetattr(0, &old) != 0 ) + return -1; + new = old; + new.c_lflag &= ~ECHO; + + 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); + write(passfifo_fd, line, len); + printf("\n"); + + if ( tcsetattr(0, TCSANOW, &old) != 0 ) + return -1; + + return 0; +} -- cgit v1.2.3