diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 3 | ||||
-rw-r--r-- | src/shell/shell.c | 37 | ||||
-rw-r--r-- | src/ui_elements.h | 1 |
3 files changed, 40 insertions, 1 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 44d2220..affd4d4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,7 @@ -bin_PROGRAMS=naskpass naskpass_check +bin_PROGRAMS=naskpass naskshell naskpass_check naskpass_SOURCES=main.c log.c opt.c status.c ui_ani.c ui.c ui_elements.c ui_input.c ui_ipc.c ui_txtwindow.c ui_statusbar.c naskpass_check_SOURCES=check/check.c +naskshell_SOURCES=shell/shell.c if DEBUG naskpass_CFLAGS=-O0 -g3 -DDEBUG else 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 <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <termios.h> + + +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; +} diff --git a/src/ui_elements.h b/src/ui_elements.h index a4ee287..3d99987 100644 --- a/src/ui_elements.h +++ b/src/ui_elements.h @@ -2,6 +2,7 @@ #define UI_ELEMENTS_H 1 #include "config.h" +#include "ui_txtwindow.h" void |