grub2/grub2-efi-HP-workaround.patch
Michael Chang 8ee92f5194 Accepting request 1105405 from home:michael-chang:grub:2.12rc1
- Implement NV index mode for TPM 2.0 key protector
  0001-protectors-Implement-NV-index.patch
- Fall back to passphrase mode when the key protector fails to
  unlock the disk
  0002-cryptodisk-Fallback-to-passphrase.patch
- Wipe out the cached key cleanly
  0003-cryptodisk-wipe-out-the-cached-keys-from-protectors.patch
- Make diskfiler to look up cryptodisk devices first
  0004-diskfilter-look-up-cryptodisk-devices-first.patch

- Version bump to 2.12~rc1
  * Added:
    - grub-2.12~rc1.tar.xz
  * Removed:
    - grub-2.06.tar.xz
  * Patch dropped merged by new version:
    - grub2-GRUB_CMDLINE_LINUX_RECOVERY-for-recovery-mode.patch
    - grub2-s390x-02-kexec-module-added-to-emu.patch
    - grub2-efi-chainloader-root.patch
    - grub2-Fix-incorrect-netmask-on-ppc64.patch
    - 0001-osdep-Introduce-include-grub-osdep-major.h-and-use-i.patch
    - 0002-osdep-linux-hostdisk-Use-stat-instead-of-udevadm-for.patch
    - 0002-net-read-bracketed-ipv6-addrs-and-port-numbers.patch
    - grub2-s390x-10-keep-network-at-kexec.patch
    - 0001-Fix-build-error-in-binutils-2.36.patch
    - 0001-emu-fix-executable-stack-marking.patch
    - 0046-squash-verifiers-Move-verifiers-API-to-kernel-image.patch
    - 0001-30_uefi-firmware-fix-printf-format-with-null-byte.patch
    - 0001-tpm-Pass-unknown-error-as-non-fatal-but-debug-print-.patch
    - 0001-Filter-out-POSIX-locale-for-translation.patch

OBS-URL: https://build.opensuse.org/request/show/1105405
OBS-URL: https://build.opensuse.org/package/show/Base:System/grub2?expand=0&rev=458
2023-08-24 03:25:56 +00:00

96 lines
2.2 KiB
Diff

v2: Add GRUB_FILE_TYPE_CONFIG to grub_file_open, see also upstream commit
ca0a4f689 verifiers: File type for fine-grained signature-verification controlling
--- a/grub-core/kern/efi/init.c
+++ b/grub-core/kern/efi/init.c
@@ -28,6 +28,7 @@
#include <grub/env.h>
#include <grub/mm.h>
#include <grub/kernel.h>
+#include <grub/file.h>
#include <grub/stack_protector.h>
#ifdef GRUB_STACK_PROTECTOR
@@ -135,6 +136,67 @@
void (*grub_efi_net_config) (grub_efi_handle_t hnd,
char **device,
char **path);
+static char *
+workaround_efi_firmware_path (const char *device, const char *path)
+{
+ char *config = NULL;;
+ char *config_upper = NULL;
+ char *path_upper = NULL;
+ char *ret_path = NULL;
+ grub_file_t config_fd = NULL;
+ char *s;
+
+ if (!device || !path)
+ return NULL;
+
+ /* only workaround if booting off from cd device */
+ if (grub_strncmp (device, "cd", 2) != 0)
+ goto quit;
+
+ config = grub_xasprintf ("(%s)%s/grub.cfg", device, path);
+ config_fd = grub_file_open (config, GRUB_FILE_TYPE_CONFIG);
+
+ /* everything's fine, so quit the workaround */
+ if (config_fd)
+ goto quit;
+
+ /* reset grub error state because noone else does... */
+ grub_errno = GRUB_ERR_NONE;
+
+ /* try again, this time upper case path */
+ path_upper = grub_strdup (path);
+ if (! path_upper)
+ goto quit;
+
+ s = path_upper;
+ for (; *s; s++) *s = grub_toupper(*s);
+
+ config_upper = grub_xasprintf ("(%s)%s/grub.cfg", device, path_upper);
+ if (! config_upper)
+ goto quit;
+
+ config_fd = grub_file_open (config_upper, GRUB_FILE_TYPE_CONFIG);
+
+ /* if config can be found by the upper case path, return it */
+ if (config_fd)
+ ret_path = grub_strdup (path_upper);
+
+quit:
+
+ if (config_fd)
+ grub_file_close (config_fd);
+
+ if (grub_errno)
+ grub_errno = GRUB_ERR_NONE;
+
+ if (config)
+ grub_free (config);
+
+ if (config_upper)
+ grub_free (config_upper);
+
+ return ret_path;
+}
void
grub_machine_get_bootlocation (char **device, char **path)
@@ -159,6 +221,12 @@
p = grub_strrchr (*path, '/');
if (p)
*p = '\0';
+
+ if ((p = workaround_efi_firmware_path (*device, *path)))
+ {
+ grub_free (*path);
+ *path = p;
+ }
}
}