From 139dff3525e7140a1d2e6aefdc1d35930d05c6d2 Mon Sep 17 00:00:00 2001 From: Ingo Franzki Date: Wed, 7 Aug 2019 13:04:20 +0200 Subject: [PATCH] zkey: Make confirmation prompts more user friendly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Show '[y/N]' on all user confirmation prompts to give the user a hint what to reply. Also indicate that the operation was aborted on a negative confirmation. Signed-off-by: Ingo Franzki Signed-off-by: Jan Höppner --- zkey/keystore.c | 4 +++- zkey/zkey-cryptsetup.c | 12 +++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/zkey/keystore.c b/zkey/keystore.c index ff5563ca..0f880170 100644 --- a/zkey/keystore.c +++ b/zkey/keystore.c @@ -3072,7 +3072,8 @@ static int _keystore_prompt_for_remove(struct keystore *keystore, _keystore_msg_for_volumes(msg, key_prop, VOLUME_TYPE_PLAIN); free(msg); - printf("%s: Remove key '%s'? ", program_invocation_short_name, name); + printf("%s: Remove key '%s' [y/N]? ", program_invocation_short_name, + name); if (fgets(str, sizeof(str), stdin) == NULL) { rc = -EIO; goto out; @@ -3081,6 +3082,7 @@ static int _keystore_prompt_for_remove(struct keystore *keystore, str[strlen(str) - 1] = '\0'; pr_verbose(keystore, "Prompt reply: '%s'", str); if (strcasecmp(str, "y") != 0 && strcasecmp(str, "yes") != 0) { + warnx("Operation aborted"); rc = -ECANCELED; goto out; } diff --git a/zkey/zkey-cryptsetup.c b/zkey/zkey-cryptsetup.c index 8180b4a3..ce4e1948 100644 --- a/zkey/zkey-cryptsetup.c +++ b/zkey/zkey-cryptsetup.c @@ -1275,7 +1275,7 @@ static int activate_unbound_keyslot(int token, int keyslot, const char *key, util_print_indented(complete_msg, 0); util_print_indented("All key slots containing the old volume key are " "now in unbound state. Do you want to remove " - "these key slots?", 0); + "these key slots [y/N]?", 0); if (!prompt_for_yes()) return 0; @@ -1524,7 +1524,7 @@ static int reencipher_prepare(int token) util_asprintf(&msg, "Staged volume key re-enciphering is " "already initiated for device '%s'. Do you want to " "cancel the pending re-enciphering and start a " - "new re-enciphering process?", g.pos_arg); + "new re-enciphering process [y/N]?", g.pos_arg); util_print_indented(msg, 0); free(msg); @@ -1690,7 +1690,7 @@ static int reencipher_complete(int token) "was completed.\n" "Do you want to re-encipher the secure key with " "the CCA master key in the CURRENT master key " - "register?", g.pos_arg); + "register [y/N]?", g.pos_arg); util_print_indented(msg, 0); free(msg); @@ -2014,12 +2014,13 @@ static int command_setkey(void) util_asprintf(&msg, "The secure key in file '%s' is " "enciphered with the CCA master key in the OLD " "master key register. Do you want to set this " - "key as the new volume key anyway?", + "key as the new volume key anyway [y/N]?", g.master_key_file); util_print_indented(msg, 0); free(msg); if (!prompt_for_yes()) { + warnx("Device '%s' is left unchanged", g.pos_arg); rc = -EINVAL; goto out; } @@ -2078,12 +2079,13 @@ static int command_setkey(void) "be correct. You will lose all data on the " "volume if you set the wrong volume key!\n" "Are you sure that the key in file '%s' is the " - "correct volume key for volume '%s'?", + "correct volume key for volume '%s' [y/N]?", g.master_key_file, g.pos_arg); util_print_indented(msg, 0); free(msg); if (!prompt_for_yes()) { + warnx("Device '%s' is left unchanged", g.pos_arg); rc = -EINVAL; goto out; }