]> git.ipfire.org Git - thirdparty/grub.git/commit
cryptodisk: Refactor to discard have_it global
authorGlenn Washburn <development@efficientek.com>
Thu, 9 Dec 2021 17:14:51 +0000 (11:14 -0600)
committerDaniel Kiper <daniel.kiper@oracle.com>
Thu, 23 Dec 2021 00:53:43 +0000 (01:53 +0100)
commit26406d8908a1610b43b05a39c7b0eedb634cd0f6
tree3914fa48f15c6754ab5f92c69bc5b8ca5d64786d
parent74101d6c9927048597adeb362ae5c21044c0e58d
cryptodisk: Refactor to discard have_it global

The global "have_it" was never used by the crypto-backends, but was used to
determine if a crypto-backend successfully mounted a cryptodisk with a given
UUID. This is not needed however, because grub_device_iterate() will return
1 if and only if grub_cryptodisk_scan_device() returns 1. And
grub_cryptodisk_scan_device() will now only return 1 if a search_uuid has
been specified and a cryptodisk was successfully setup by a crypto-backend or
a cryptodisk of the requested UUID is already open.

To implement this grub_cryptodisk_scan_device_real() is modified to return
a cryptodisk or NULL on failure and having the appropriate grub_errno set to
indicated failure. Note that grub_cryptodisk_scan_device_real() will fail now
with a new errno GRUB_ERR_BAD_MODULE when none of the cryptodisk backend
modules succeed in identifying the source disk.

With this change grub_device_iterate() will return 1 when a crypto device is
successfully decrypted or when the source device has already been successfully
opened. Prior to this change, trying to mount an already successfully opened
device would trigger an error with the message "no such cryptodisk found",
which is at best misleading. The mount should silently succeed in this case,
which is what happens with this patch.

Signed-off-by: Glenn Washburn <development@efficientek.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/disk/cryptodisk.c