]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
osdep/devmapper/getroot: Have devmapper recognize LUKS2
authorJosselin Poiret <dev@jpoiret.xyz>
Thu, 12 Jan 2023 23:05:08 +0000 (17:05 -0600)
committerDaniel Kiper <daniel.kiper@oracle.com>
Wed, 1 Feb 2023 15:20:54 +0000 (16:20 +0100)
Changes UUID comparisons so that LUKS1 and LUKS2 are both recognized
as being LUKS cryptodisks.

Signed-off-by: Josselin Poiret <dev@jpoiret.xyz>
Tested-by: Glenn Washburn <development@efficientek.com>
Reviewed-by: Patrick Steinhardt <ps@pks.im>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/osdep/devmapper/getroot.c

index 9ba5c9865559794124ed6f9c5b97116d9d6962a5..2bf4264cf09167d5071390655f19bb04bca0669f 100644 (file)
@@ -138,7 +138,8 @@ grub_util_get_dm_abstraction (const char *os_dev)
       grub_free (uuid);
       return GRUB_DEV_ABSTRACTION_LVM;
     }
-  if (strncmp (uuid, "CRYPT-LUKS1-", 12) == 0)
+  if (strncmp (uuid, "CRYPT-LUKS1-", sizeof ("CRYPT-LUKS1-") - 1) == 0
+      || strncmp (uuid, "CRYPT-LUKS2-", sizeof ("CRYPT-LUKS2-") - 1) == 0)
     {
       grub_free (uuid);
       return GRUB_DEV_ABSTRACTION_LUKS;
@@ -179,7 +180,9 @@ grub_util_pull_devmapper (const char *os_dev)
          grub_util_pull_device (subdev);
        }
     }
-  if (uuid && strncmp (uuid, "CRYPT-LUKS1-", sizeof ("CRYPT-LUKS1-") - 1) == 0
+  if (uuid
+      && (strncmp (uuid, "CRYPT-LUKS1-", sizeof ("CRYPT-LUKS1-") - 1) == 0
+          || strncmp (uuid, "CRYPT-LUKS2-", sizeof ("CRYPT-LUKS2-") - 1) == 0)
       && lastsubdev)
     {
       char *grdev = grub_util_get_grub_dev (lastsubdev);
@@ -253,11 +256,11 @@ grub_util_get_devmapper_grub_dev (const char *os_dev)
       {
        char *dash;
 
-       dash = grub_strchr (uuid + sizeof ("CRYPT-LUKS1-") - 1, '-');
+       dash = grub_strchr (uuid + sizeof ("CRYPT-LUKS*-") - 1, '-');
        if (dash)
          *dash = 0;
        grub_dev = grub_xasprintf ("cryptouuid/%s",
-                                  uuid + sizeof ("CRYPT-LUKS1-") - 1);
+                                  uuid + sizeof ("CRYPT-LUKS*-") - 1);
        grub_free (uuid);
        return grub_dev;
       }