From 28da4ed72db466feeb02de8f1856dfe2a424df3e Mon Sep 17 00:00:00 2001 From: Ondrej Kozina Date: Mon, 31 Jul 2023 14:53:18 +0200 Subject: [PATCH] Make luksErase work with detached header. For it to work correctly with LUKS2 OPAL we have to set data device properly so it can erase OPAL locking range (or revert via PSID). --- src/cryptsetup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cryptsetup.c b/src/cryptsetup.c index f60998ce..6bed1589 100644 --- a/src/cryptsetup.c +++ b/src/cryptsetup.c @@ -2722,8 +2722,8 @@ static int action_luksErase(void) char *msg = NULL; int i, max, r, hw_enc; - if ((r = crypt_init(&cd, uuid_or_device_header(NULL)))) - goto out; + if ((r = crypt_init_data_device(&cd, uuid_or_device(ARG_STR(OPT_HEADER_ID) ?: action_argv[0]), action_argv[0]))) + return r; /* Allow factory reset even if there's no LUKS header, as long as OPAL is enabled on the device */ if (ARG_SET(OPT_HW_OPAL_FACTORY_RESET_ID)) {