diff options
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | consent.c | 14 |
2 files changed, 7 insertions, 8 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a9a6f9..c6b6e48 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,3 +4,4 @@ project(secdesk C) set(CMAKE_C_STANDARD 11) add_executable(secdesk main.c log.c log.h common.h consent.c sd.c) +target_link_libraries(secdesk PRIVATE bsd)
\ No newline at end of file @@ -7,6 +7,7 @@ #include <stdio.h> #include <errno.h> +#include <bsd/readpassphrase.h> int main_consent(int secure) { if (!secure) { @@ -45,19 +46,16 @@ int main_consent(int secure) { } case mode_password: { fprintf(stderr, "Please enter password. " - "The program will know your password.\n" - "Password: "); + "The program will know your password.\n"); char buf[10]; - if (!fgets(buf, sizeof(buf) - 1, stdin)) { - int r = errno; - LOGFV("read: %m", r); + if (!readpassphrase("Password: ", buf, sizeof(buf), 0)) { + LOGF("Cannot read passphrase."); if (secure) { - fprintf(stderr, "Cannot read your response: %m. Press any key to return.\n", - errno); + fprintf(stderr, "Cannot read your response. Press any key to return.\n"); fgetc(stdin); fprintf(stderr, "\033[r\033[H\033[J"); } - return r; + return 1; } dprintf(p_env.out, "%s", buf); break; |