devmapper: check for valid device abstraction in get_grub_dev
This was lost when code was refactored. Patch restores previous behavior. It is still not clear whether this is the right one. Due to the way we detect DM abstraction, partitions on DM are skipped, we fall through to generic detection which ends up in assuming parent device is BIOS disk. It is useful to install GRUB on VM disk from the host. But it also means that GRUB will mistakenly allow install on real system as well. For now let's fix regression; future behavior needs to be discussed. Closes: 45163
This commit is contained in:
parent
a9399f2e1e
commit
3bca85b418
2 changed files with 21 additions and 14 deletions
|
@ -223,11 +223,14 @@ grub_util_get_devmapper_grub_dev (const char *os_dev)
|
|||
uuid = get_dm_uuid (os_dev);
|
||||
if (!uuid)
|
||||
return NULL;
|
||||
|
||||
if (strncmp (uuid, "LVM-", sizeof ("LVM-") - 1) == 0)
|
||||
|
||||
switch (grub_util_get_dev_abstraction (os_dev))
|
||||
{
|
||||
case GRUB_DEV_ABSTRACTION_LVM:
|
||||
{
|
||||
unsigned i;
|
||||
int dashes[] = { 0, 6, 10, 14, 18, 22, 26, 32, 38, 42, 46, 50, 54, 58};
|
||||
|
||||
grub_dev = xmalloc (grub_strlen (uuid) + 40);
|
||||
optr = grub_stpcpy (grub_dev, "lvmid/");
|
||||
for (i = 0; i < ARRAY_SIZE (dashes) - 1; i++)
|
||||
|
@ -245,19 +248,23 @@ grub_util_get_devmapper_grub_dev (const char *os_dev)
|
|||
return grub_dev;
|
||||
}
|
||||
|
||||
if (strncmp (uuid, "CRYPT-LUKS1-", sizeof ("CRYPT-LUKS1-") - 1) == 0)
|
||||
{
|
||||
char *dash;
|
||||
dash = grub_strchr (uuid + sizeof ("CRYPT-LUKS1-") - 1, '-');
|
||||
if (dash)
|
||||
*dash = 0;
|
||||
grub_dev = grub_xasprintf ("cryptouuid/%s",
|
||||
uuid + sizeof ("CRYPT-LUKS1-") - 1);
|
||||
case GRUB_DEV_ABSTRACTION_LUKS:
|
||||
{
|
||||
char *dash;
|
||||
|
||||
dash = grub_strchr (uuid + sizeof ("CRYPT-LUKS1-") - 1, '-');
|
||||
if (dash)
|
||||
*dash = 0;
|
||||
grub_dev = grub_xasprintf ("cryptouuid/%s",
|
||||
uuid + sizeof ("CRYPT-LUKS1-") - 1);
|
||||
grub_free (uuid);
|
||||
return grub_dev;
|
||||
}
|
||||
|
||||
default:
|
||||
grub_free (uuid);
|
||||
return grub_dev;
|
||||
return NULL;
|
||||
}
|
||||
grub_free (uuid);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *
|
||||
|
|
|
@ -1075,7 +1075,7 @@ grub_util_get_grub_dev_os (const char *os_dev)
|
|||
switch (grub_util_get_dev_abstraction (os_dev))
|
||||
{
|
||||
/* Fallback for non-devmapper build. In devmapper-builds LVM is handled
|
||||
in rub_util_get_devmapper_grub_dev and this point isn't reached.
|
||||
in grub_util_get_devmapper_grub_dev and this point isn't reached.
|
||||
*/
|
||||
case GRUB_DEV_ABSTRACTION_LVM:
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue