From f96e19147cd65b8cb45e09d1d0a0c2b2982912da Mon Sep 17 00:00:00 2001 From: Ondrej Kozina Date: Thu, 28 Jul 2022 12:08:04 +0200 Subject: [PATCH] Add prompt for LUKS2 decryption with header export. --- src/utils_reencrypt.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/utils_reencrypt.c b/src/utils_reencrypt.c index 78cdf477..87ead680 100644 --- a/src/utils_reencrypt.c +++ b/src/utils_reencrypt.c @@ -703,7 +703,7 @@ static int decrypt_luks2_datashift_init(struct crypt_device **cd, size_t passwordLen; struct stat hdr_st; bool remove_header = false; - char *active_name = NULL, *password = NULL; + char *msg, *active_name = NULL, *password = NULL; struct crypt_params_reencrypt params = { .mode = CRYPT_REENCRYPT_DECRYPT, .direction = CRYPT_REENCRYPT_FORWARD, @@ -715,6 +715,18 @@ static int decrypt_luks2_datashift_init(struct crypt_device **cd, .flags = CRYPT_REENCRYPT_MOVE_FIRST_SEGMENT }; + if (!ARG_SET(OPT_BATCH_MODE_ID)) { + r = asprintf(&msg, _("Header file %s does not exist. Do you want to initialize LUKS2 " + "decryption of device %s and export LUKS2 header to file %s?"), + expheader, data_device, expheader); + if (r < 0) + return -ENOMEM; + r = yesDialog(msg, _("Operation aborted.\n")) ? 0 : -EINVAL; + free(msg); + if (r < 0) + return r; + } + if ((r = decrypt_verify_and_set_params(¶ms))) return r;