cryptodisk: teach grub_cryptodisk_insert() about partitions (bug #45889)
It is not possible to configure encrypted containers on multiple partitions of the same disk; after the first one all subsequent fail with disk/cryptodisk.c:978: already mounted as crypto0 Store partition offset in cryptomount descriptor to distinguish between them.
This commit is contained in:
parent
bcf8c5814d
commit
c7f93a20c4
2 changed files with 7 additions and 1 deletions
|
@ -25,6 +25,7 @@
|
|||
#include <grub/fs.h>
|
||||
#include <grub/file.h>
|
||||
#include <grub/procfs.h>
|
||||
#include <grub/partition.h>
|
||||
|
||||
#ifdef GRUB_UTIL
|
||||
#include <grub/emu/hostdisk.h>
|
||||
|
@ -718,6 +719,7 @@ grub_cryptodisk_insert (grub_cryptodisk_t newdev, const char *name,
|
|||
newdev->id = last_cryptodisk_id++;
|
||||
newdev->source_id = source->id;
|
||||
newdev->source_dev_id = source->dev->id;
|
||||
newdev->partition_start = grub_partition_get_start (source->partition);
|
||||
newdev->next = cryptodisk_list;
|
||||
cryptodisk_list = newdev;
|
||||
|
||||
|
@ -740,7 +742,9 @@ grub_cryptodisk_get_by_source_disk (grub_disk_t disk)
|
|||
grub_cryptodisk_t dev;
|
||||
for (dev = cryptodisk_list; dev != NULL; dev = dev->next)
|
||||
if (dev->source_id == disk->id && dev->source_dev_id == disk->dev->id)
|
||||
return dev;
|
||||
if ((disk->partition && grub_partition_get_start (disk->partition) == dev->partition_start) ||
|
||||
(!disk->partition && dev->partition_start == 0))
|
||||
return dev;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -761,6 +765,7 @@ grub_cryptodisk_cheat_insert (grub_cryptodisk_t newdev, const char *name,
|
|||
newdev->cheat_fd = GRUB_UTIL_FD_INVALID;
|
||||
newdev->source_id = source->id;
|
||||
newdev->source_dev_id = source->dev->id;
|
||||
newdev->partition_start = grub_partition_get_start (source->partition);
|
||||
newdev->id = last_cryptodisk_id++;
|
||||
newdev->next = cryptodisk_list;
|
||||
cryptodisk_list = newdev;
|
||||
|
|
|
@ -97,6 +97,7 @@ struct grub_cryptodisk
|
|||
grub_uint8_t rekey_key[64];
|
||||
grub_uint64_t last_rekey;
|
||||
int rekey_derived_size;
|
||||
grub_disk_addr_t partition_start;
|
||||
};
|
||||
typedef struct grub_cryptodisk *grub_cryptodisk_t;
|
||||
|
||||
|
|
Loading…
Reference in a new issue