regression in cryptomount -u
Prior commit 3cf2e848bc03 ("disk/cryptodisk: Allows UUIDs to be compared in a dash-insensitive manner") the grub.cfg below worked as expected:
create a menu, which if selected tries to open the specified partition and does further processing. In case the passphrase was wrong, it would just return and offer the menu again.
With the commit above, the specified partition is opened, but cryptomount returns an error. As a result no further processing is done, the menu is shown again. It needs to be selected once more to do the actual processing.
This change works for me:
grub-core/disk/cryptodisk.c +1 -1
@@ -1236,7 +1236,7 @@ grub_cryptodisk_scan_device (const char *name, dev =grub_cryptodisk_scan_device_real (name, source, cargs);if (dev) { - ret = (cargs->search_uuid !=NULL &&grub_strcasecmp (cargs->search_uuid, dev->uuid) ==0 ); + ret = cargs->search_uuid && !grub_uuidcasecmp (cargs->search_uuid, dev->uuid,sizeof (dev->uuid)); goto cleanup; }
submenu x {
insmod luks
if cryptomount -u ${uuid_without_dashes} ; then
do_work
fi
}
Olaf
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Adding Glenn and Patrick...
Olaf, please always CC at least original author of the patch...
Thanks for the report!
Quoted 25 lines · Olaf Hering
Prior commit
3cf2e848bc03("disk/cryptodisk: Allows UUIDs to be compared in a dash-insensitive manner") the grub.cfg below worked as expected:
create a menu, which if selected tries to open the specified partition and does further processing. In case the passphrase was wrong, it would just return and offer the menu again.With the commit above, the specified partition is opened, but cryptomount returns an error. As a result no further processing is done, the menu is shown again. It needs to be selected once more to do the actual processing.
This change works for me:
grub-core/disk/cryptodisk.c +1
-1@@ -1236,7 +1236,7 @@ grub_cryptodisk_scan_device (const char *name, dev =grub_cryptodisk_scan_device_real (name, source, cargs);if (dev) { - ret = (cargs->search_uuid !=NULL &&grub_strcasecmp (cargs->search_uuid, dev->uuid) ==0 ); + ret = cargs->search_uuid && !grub_uuidcasecmp (cargs->search_uuid, dev->uuid,sizeof (dev->uuid)); goto cleanup; }
Quoted 6 lines
submenu x {
insmod luks
if cryptomount -u ${uuid_without_dashes} ; then
do_work
fi
}
Daniel
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 15 lines · On Thu, 17 Aug 2023 10:52:58 +0200 Olaf Hering <[email protected]> wrote:
Prior commit
3cf2e848bc03("disk/cryptodisk: Allows UUIDs to be compared in a dash-insensitive manner") the grub.cfg below worked as expected:
create a menu, which if selected tries to open the specified partition and does further processing. In case the passphrase was wrong, it would just return and offer the menu again.With the commit above, the specified partition is opened, but cryptomount returns an error. As a result no further processing is done, the menu is shown again. It needs to be selected once more to do the actual processing.
This change works for me:
grub-core/disk/cryptodisk.c grub_cryptodisk_scan_device (const char *name, · line 1239
Quoted 5 lines
grub-core/disk/cryptodisk.c +1
-1@@ -1236,7 +1236,7 @@ grub_cryptodisk_scan_device (const char *name, dev =grub_cryptodisk_scan_device_real (name, source, cargs);if (dev) { - ret = (cargs->search_uuid !=NULL &&grub_strcasecmp (cargs->search_uuid, dev->uuid) ==0 ); + ret = cargs->search_uuid && !grub_uuidcasecmp (cargs->search_uuid, dev->uuid,sizeof (dev->uuid));
You confused me with the unnecessary changes here into thinking there was a logic error. Yes, grub_strcasecmp should be replaced with grub_uuidcasecmp here. Thanks for catching this. Would you like to send a proper patch to the list or should I?
Glenn
Quoted 13 lines
grub-core/disk/cryptodisk.c +0
-0goto cleanup; }submenu x {
insmod luks
if cryptomount -u ${uuid_without_dashes} ; then
do_work
fi
}
Quoted 1 line
Olaf
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 8 lines
{- ret = (
cargs->search_uuid!= NULL &&grub_strcasecmp
(cargs->search_uuid,dev->uuid) == 0);
+ ret =cargs->search_uuid&& !grub_uuidcasecmp(cargs->search_uuid,dev->uuid,sizeof(dev->uuid));
Please keep comparison with == 0 explicit. Also comparison with NULL improved readability
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Thu, 17 Aug 2023 15:31:52 -0500 Glenn Washburn <[email protected]>:
Quoted 1 line
Would you like to send a proper patch to the list or should I?
Please go ahead and propose a proper patch/fix.
Thanks,
Olaf
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 9 lines · Olaf Hering
Prior commit
3cf2e848bc03("disk/cryptodisk: Allows UUIDs to be compared in a dash-insensitive manner") the grub.cfg below worked as expected:
create a menu, which if selected tries to open the specified partition and does further processing. In case the passphrase was wrong, it would just return and offer the menu again.With the commit above, the specified partition is opened, but cryptomount returns an error. As a result no further processing is done, the menu is shown again. It needs to be selected once more to do the actual processing.
I have ran into the error as well. As a side note the error message looked like:
Enter passphrase for hd1,gpt3 (471eff62-ee8a-4b69-b449-031dd5449198):
Attempting to decrypt master key...
Slot 0 opened
error: ../../grub-core/disk/cryptodisk.c:1512:no such cryptodisk found, perhaps a needed disk or cryptodisk module is not loaded.
For me the disk unlocked and continued without problem despite the error.
Thanks,
Michael
Quoted 24 lines
This change works for me:
grub-core/disk/cryptodisk.c +1
-1@@ -1236,7 +1236,7 @@ grub_cryptodisk_scan_device (const char *name, dev =grub_cryptodisk_scan_device_real (name, source, cargs);if (dev) { - ret = (cargs->search_uuid !=NULL &&grub_strcasecmp (cargs->search_uuid, dev->uuid) ==0 ); + ret = cargs->search_uuid && !grub_uuidcasecmp (cargs->search_uuid, dev->uuid,sizeof (dev->uuid)); goto cleanup; }submenu x {
insmod luks
if cryptomount -u ${uuid_without_dashes} ; then
do_work
fi
}
Quoted 8 lines
Olaf
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel