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:
Andrei Borzenkov 2015-12-26 21:45:22 +03:00
parent a9399f2e1e
commit 3bca85b418
2 changed files with 21 additions and 14 deletions

View file

@ -224,10 +224,13 @@ grub_util_get_devmapper_grub_dev (const char *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,9 +248,10 @@ grub_util_get_devmapper_grub_dev (const char *os_dev)
return grub_dev;
}
if (strncmp (uuid, "CRYPT-LUKS1-", sizeof ("CRYPT-LUKS1-") - 1) == 0)
case GRUB_DEV_ABSTRACTION_LUKS:
{
char *dash;
dash = grub_strchr (uuid + sizeof ("CRYPT-LUKS1-") - 1, '-');
if (dash)
*dash = 0;
@ -256,9 +260,12 @@ grub_util_get_devmapper_grub_dev (const char *os_dev)
grub_free (uuid);
return grub_dev;
}
default:
grub_free (uuid);
return NULL;
}
}
char *
grub_util_get_vg_uuid (const char *os_dev)

View file

@ -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:
{