aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrumeet <yuuta@yuuta.moe>2022-12-23 22:51:08 -0800
committerTrumeet <yuuta@yuuta.moe>2022-12-23 22:51:08 -0800
commit03ab6ba2c4efd9c9c5b92d8fb1f51ad51e255a08 (patch)
treedc3ff5409e4bb39d9745b09c27fc9d45822cc64e
parent184dab1c74db05d59d63bfaabedf0ef4e6bf61c9 (diff)
downloadsecdesk-03ab6ba2c4efd9c9c5b92d8fb1f51ad51e255a08.tar
secdesk-03ab6ba2c4efd9c9c5b92d8fb1f51ad51e255a08.tar.gz
secdesk-03ab6ba2c4efd9c9c5b92d8fb1f51ad51e255a08.tar.bz2
secdesk-03ab6ba2c4efd9c9c5b92d8fb1f51ad51e255a08.zip
Improve prompt
-rw-r--r--consent.c24
-rw-r--r--main.c2
2 files changed, 14 insertions, 12 deletions
diff --git a/consent.c b/consent.c
index 61710b0..882ac79 100644
--- a/consent.c
+++ b/consent.c
@@ -10,27 +10,29 @@
int main_consent(int secure) {
if (!secure) {
- printf("WARNING: The terminal you are about to enter passwords is insecure.\n");
+ fprintf(stderr, "WARNING: The terminal you are about to enter passwords is insecure.\n");
} else {
- printf("\033[r\033[H\033[J");
+ fprintf(stderr, "\033[r\033[H\033[J");
}
- printf("Program %s from user %d (process %d: '%s'), is asking for authorization.\n",
+ fprintf(stderr, "Program %s from user %d (process %d: '%s'), is asking for authorization.\n"
+ "It prompts that:\n\n%s\n\n",
a_env.exe,
a_env.usr,
a_env.pid,
- "todo");
+ "todo",
+ a_env.prompt);
switch (a_env.mode) {
case mode_consent: {
- printf("Consent '%s'? (Y / N) ", a_env.prompt);
+ fprintf(stderr, "Consent? (Y / N) ");
char buf[5];
if (read(STDIN_FILENO, buf, sizeof(buf) - 1) < 0) {
int r = errno;
LOGFV("read: %m", r);
if (secure) {
- printf("Cannot read response: %m. Press any key to return.\n",
+ fprintf(stderr, "Cannot read response: %m. Press any key to return.\n",
errno);
fgetc(stdin);
- printf("\033[r\033[H\033[J");
+ fprintf(stderr, "\033[r\033[H\033[J");
}
return r;
}
@@ -42,18 +44,18 @@ int main_consent(int secure) {
break;
}
case mode_password: {
- printf("Enter password for '%s'. "
+ fprintf(stderr, "Please enter password. "
"The program will know your password.\n"
- "Password: ", a_env.prompt);
+ "Password: ");
char buf[10];
if (!fgets(buf, sizeof(buf) - 1, stdin)) {
int r = errno;
LOGFV("read: %m", r);
if (secure) {
- printf("Cannot read your response: %m. Press any key to return.\n",
+ fprintf(stderr, "Cannot read your response: %m. Press any key to return.\n",
errno);
fgetc(stdin);
- printf("\033[r\033[H\033[J");
+ fprintf(stderr, "\033[r\033[H\033[J");
}
return r;
}
diff --git a/main.c b/main.c
index 0865bb4..8c537d3 100644
--- a/main.c
+++ b/main.c
@@ -37,7 +37,7 @@ int main(int argc, char **argv) {
if ((a_env.prompt = argv[2])) {
char *p = argv[2];
do {
- if ((*p) < 32 || (*p) > 126) {
+ if (*p != '\n' && (*p) < 32 || (*p) > 126) {
fprintf(stderr, "The given prompt is illegal.\n");
return 64;
}