From b661452e3abd887b500ca23a123ebb233f47b3ce Mon Sep 17 00:00:00 2001 From: Ondrej Kozina Date: Wed, 6 Apr 2022 19:14:19 +0200 Subject: [PATCH] Asks offline reencryption confirmation only with image files. If auto-detection fails for other reason just return the error. Users may now bypass active device auto-detection with --force-offline-reencrypt option. --- src/utils_reencrypt.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/utils_reencrypt.c b/src/utils_reencrypt.c index c01f048d..dfb80a88 100644 --- a/src/utils_reencrypt.c +++ b/src/utils_reencrypt.c @@ -97,13 +97,15 @@ static int get_active_device_name(struct crypt_device *cd, const char *data_devi if (!ARG_SET(OPT_BATCH_MODE_ID)) log_std(_("Auto-detected active dm device '%s' for data device %s.\n"), *r_active_name, data_device); } else if (r < 0) { - if (r == -ENOTBLK) - log_std(_("Device %s is not a block device.\n"), data_device); - else + if (r != -ENOTBLK) { log_err(_("Failed to auto-detect device %s holders."), data_device); + return -EINVAL; + } r = -EINVAL; if (!ARG_SET(OPT_BATCH_MODE_ID)) { + log_std(_("Device %s is not a block device.\n"), data_device); + r = asprintf(&msg, _("Unable to decide if device %s is activated or not.\n" "Are you sure you want to proceed with reencryption in offline mode?\n" "It may lead to data corruption if the device is actually activated.\n"