diff options
author | Trumeet <yuuta@yuuta.moe> | 2022-12-23 23:39:52 -0800 |
---|---|---|
committer | Trumeet <yuuta@yuuta.moe> | 2022-12-23 23:39:52 -0800 |
commit | 213ef024f69c2509a774540d5a3e2d5a28c47dac (patch) | |
tree | 22524219497e2a2e564b9562c875efdc9f7ebdfb | |
parent | ce8e5821dff2673d23fe4f6ba394ab07afd0e73f (diff) | |
download | secdesk-213ef024f69c2509a774540d5a3e2d5a28c47dac.tar secdesk-213ef024f69c2509a774540d5a3e2d5a28c47dac.tar.gz secdesk-213ef024f69c2509a774540d5a3e2d5a28c47dac.tar.bz2 secdesk-213ef024f69c2509a774540d5a3e2d5a28c47dac.zip |
Use readpassphrase(3) to read password
-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; |