grub2/grub2-efi-xen-cfg-unquote.patch

91 lines
2.6 KiB
Diff
Raw Normal View History

From: Petr Tesarik <ptesarik@suse.cz>
Subject: Unquote parameters written to Xen EFI config file
References: bsc#900418
Patch-mainline: not yet
The GRUB_CMDLINE_* value is copied verbatim to grub.conf, so it is first
parsed by GRUB2 before being passed down to the kernel. OTOH Xen EFI loader
takes the config file options verbatim. This means that any special GRUB2
syntax must be evaluated when generating that file.
Of course, some things are not even possible (e.g. substituting GRUB runtime
variables), but let's call them known limitations.
Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
---
util/grub.d/20_linux_xen.in | 54 ++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 52 insertions(+), 2 deletions(-)
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 05:25:56 +02:00
--- a/util/grub.d/20_linux_xen.in
+++ b/util/grub.d/20_linux_xen.in
@@ -139,6 +139,52 @@
is_efi=false
fi
+grub2_unquote ()
+{
+ awk '
+ BEGIN {
+ bare = "[^{}|&$;<> \t\n'\''\"\\\\]+"
+ esc = "\\\\."
+ id = "[[:alpha:]_][[:alnum:]_]*|[[:digit:]]+|[?#*@]"
+ var = "\\$("id")|\\$\\{("id")\\}"
+ dqesc = "\\\\[$\"\\\\]"
+ dqstr = "\\$?\"([^\"]|"var"|"dqesc")*\""
+ sqstr = "'\''[^'\'']*'\''"
+ pat = bare"|"esc"|"var"|"dqstr"|"sqstr
+ ORS = ""
+ }
+ {
+ patsplit($0, words, pat, sep)
+ print sep[0]
+ for (i in words) {
+ w = words[i]
+ if (w ~ /^\$?"/) {
+ # Double-quoted string
+ patsplit(w, segs, var"|"dqesc, ssep)
+ print ssep[0]
+ for (j in segs) {
+ if (segs[j] ~ /^\\/)
+ print substr(segs[j], 2)
+ print ssep[j]
+ }
+ } else if (w ~ /^'\''/) {
+ # Single-quoted string
+ print substr(w, 2, length(w)-2)
+ } else if (w ~ /^\\/) {
+ # Escape sequence
+ print substr(w, 2)
+ } else if (w ~ /^\$/) {
+ # Variable expansion
+ } else {
+ # Bare word
+ print w
+ }
+ print sep[i]
+ }
+ print "\n"
+ }'
+}
+
linux_entry ()
{
Accepting request 904721 from home:michael-chang:grub:2.06 - Version bump to 2.06 * rediff - 0001-add-support-for-UEFI-network-protocols.patch - 0002-net-read-bracketed-ipv6-addrs-and-port-numbers.patch - 0003-Make-grub_error-more-verbose.patch - 0003-bootp-New-net_bootp6-command.patch - 0005-grub.texi-Add-net_bootp6-doument.patch - 0006-bootp-Add-processing-DHCPACK-packet-from-HTTP-Boot.patch - 0006-efi-Set-image-base-address-before-jumping-to-the-PE-.patch - 0008-efinet-Setting-DNS-server-from-UEFI-protocol.patch - 0046-squash-verifiers-Move-verifiers-API-to-kernel-image.patch - grub-install-force-journal-draining-to-ensure-data-i.patch - grub2-btrfs-01-add-ability-to-boot-from-subvolumes.patch - grub2-diskfilter-support-pv-without-metadatacopies.patch - grub2-efi-HP-workaround.patch - grub2-efi-xen-cfg-unquote.patch - grub2-efi-xen-chainload.patch - grub2-fix-menu-in-xen-host-server.patch - grub2-gfxmenu-support-scrolling-menu-entry-s-text.patch - grub2-install-remove-useless-check-PReP-partition-is-empty.patch - grub2-lvm-allocate-metadata-buffer-from-raw-contents.patch - grub2-mkconfig-default-entry-correction.patch - grub2-pass-corret-root-for-nfsroot.patch - grub2-s390x-03-output-7-bit-ascii.patch - grub2-s390x-04-grub2-install.patch - grub2-secureboot-install-signed-grub.patch - grub2-setup-try-fs-embed-if-mbr-gap-too-small.patch - use-grub2-as-a-package-name.patch * update by patch squashed: - 0001-Add-support-for-Linux-EFI-stub-loading-on-aarch64.patch OBS-URL: https://build.opensuse.org/request/show/904721 OBS-URL: https://build.opensuse.org/package/show/Base:System/grub2?expand=0&rev=386
2021-07-08 11:03:14 +02:00
linux_entry_xsm "$@" false
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 05:25:56 +02:00
@@ -209,11 +255,13 @@
else
section="failsafe.$section_count"
fi
+ xen_args_unq=$(echo $xen_args | grub2_unquote)
+ args_unq=$(echo $args | grub2_unquote)
cat <<-EOF >> $grub_dir/$xen_cfg
[$section]
- options=${xen_args}
- kernel=${basename} root=${linux_root_device_thisversion} ${args}
+ options=${xen_args_unq}
+ kernel=${basename} root=${linux_root_device_thisversion} ${args_unq}
ramdisk=${initrd_real}
EOF
message="$(gettext_printf "Loading Xen %s with Linux %s ..." ${xen_version} ${version})"