Blob Blame History Raw
From 132c355d3ba10b6ec303cbc059d6732056474695 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 6 Oct 2020 15:04:27 +0100
Subject: [PATCH 4/4] options: Ignore errors from guestfs_luks_uuid.

For BitLocker disks cryptsetup does not (yet? ever?) support reading
UUIDs and this function will fail.  Skip reading the UUID in this
case.

Updates commit bb4a2dc17a78b53437896d4215ae82df8e11b788.
---
 options/decrypt.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/options/decrypt.c b/options/decrypt.c
index 8eb24bc..434b7d5 100644
--- a/common/options/decrypt.c
+++ b/common/options/decrypt.c
@@ -25,6 +25,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <stdbool.h>
 #include <string.h>
 #include <libintl.h>
 #include <error.h>
@@ -82,11 +83,19 @@ inspect_do_decrypt (guestfs_h *g, struct key_store *ks)
     CLEANUP_FREE char *type = guestfs_vfs_type (g, partitions[i]);
     if (type &&
         (STREQ (type, "crypto_LUKS") || STREQ (type, "BitLocker"))) {
+      bool is_bitlocker = STREQ (type, "BitLocker");
       char mapname[32];
       make_mapname (partitions[i], mapname, sizeof mapname);
 
 #ifdef GUESTFS_HAVE_LUKS_UUID
-      CLEANUP_FREE char *uuid = guestfs_luks_uuid (g, partitions[i]);
+      CLEANUP_FREE char *uuid = NULL;
+
+      /* This fails for Windows BitLocker disks because cryptsetup
+       * luksUUID cannot read a UUID (unclear if this is a limitation
+       * of the format or cryptsetup).
+       */
+      if (!is_bitlocker)
+        uuid = guestfs_luks_uuid (g, partitions[i]);
 #else
       const char *uuid = NULL;
 #endif
-- 
2.18.4