grub2/0006-bootp-Add-processing-DHCPACK-packet-from-HTTP-Boot.patch
Michael Chang 62e3547e57 Accepting request 741033 from home:michael-chang:devel
- Version bump to 2.04
  * removed
    - translations-20170427.tar.xz
  * grub2.spec
    - Make signed grub-tpm.efi specific to x86_64-efi build, the platform
      currently shipped with tpm module from upstream codebase
    - Add shim_lock to signed grub.efi in x86_64-efi build
    - x86_64: linuxefi now depends on linux, both will verify kernel via
      shim_lock
    - Remove translation tarball and po file hacks as it's been included in
      upstream tarball
  * rediff
    - grub2-setup-try-fs-embed-if-mbr-gap-too-small.patch
    - grub2-commands-introduce-read_file-subcommand.patch
    - grub2-secureboot-add-linuxefi.patch
    - 0001-add-support-for-UEFI-network-protocols.patch
    - grub2-efi-HP-workaround.patch
    - grub2-secureboot-install-signed-grub.patch
    - grub2-linux.patch
    - use-grub2-as-a-package-name.patch
    - grub2-pass-corret-root-for-nfsroot.patch
    - grub2-secureboot-use-linuxefi-on-uefi.patch
    - grub2-secureboot-no-insmod-on-sb.patch
    - grub2-secureboot-provide-linuxefi-config.patch
    - grub2-secureboot-chainloader.patch
    - grub2-s390x-01-Changes-made-and-files-added-in-order-to-allow-s390x.patch
    - grub2-s390x-02-kexec-module-added-to-emu.patch
    - grub2-s390x-04-grub2-install.patch
    - grub2-btrfs-01-add-ability-to-boot-from-subvolumes.patch
    - grub2-efi-chainloader-root.patch

OBS-URL: https://build.opensuse.org/request/show/741033
OBS-URL: https://build.opensuse.org/package/show/Base:System/grub2?expand=0&rev=340
2019-10-18 10:18:53 +00:00

103 lines
3.5 KiB
Diff

From 8191aae462f8b755972a0a801f4adbdd6ecaa66c Mon Sep 17 00:00:00 2001
From: Michael Chang <mchang@suse.com>
Date: Thu, 14 Jul 2016 18:45:14 +0800
Subject: [PATCH 6/8] bootp: Add processing DHCPACK packet from HTTP Boot
The vendor class identifier with the string "HTTPClient" is used to denote the
packet as responding to HTTP boot request. In DHCP4 config, the filename for
HTTP boot is the URL of the boot file while for PXE boot it is the path to the
boot file. As a consequence, the next-server becomes obseleted because the HTTP
URL already contains the server address for the boot file. For DHCP6 config,
there's no difference definition in existing config as dhcp6.bootfile-url can
be used to specify URL for both HTTP and PXE boot file.
This patch adds processing for "HTTPClient" vendor class identifier in DHCPACK
packet by treating it as HTTP format, not as the PXE format.
Signed-off-by: Michael Chang <mchang@suse.com>
Signed-off-by: Ken Lin <ken.lin@hpe.com>
---
grub-core/net/bootp.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++--
include/grub/net.h | 1 +
2 files changed, 66 insertions(+), 2 deletions(-)
Index: grub-2.04~rc1/grub-core/net/bootp.c
===================================================================
--- grub-2.04~rc1.orig/grub-core/net/bootp.c
+++ grub-2.04~rc1/grub-core/net/bootp.c
@@ -340,6 +340,53 @@ grub_net_configure_by_dhcp_ack (const ch
if (!inter)
return 0;
+ /* FIXME: Introduce new http flag for better synergy with existing tftp code base */
+ if (size > OFFSET_OF (vendor, bp))
+ {
+ char *cidvar;
+ const char *cid;
+
+ opt = find_dhcp_option (bp, size, GRUB_NET_BOOTP_VENDOR_CLASS_IDENTIFIER, &opt_len);
+ if (opt && opt_len)
+ grub_env_set_net_property (name, "vendor_class_identifier", (const char *) opt, opt_len);
+ cidvar = grub_xasprintf ("net_%s_%s", name, "vendor_class_identifier");
+ cid = grub_env_get (cidvar);
+ grub_free (cidvar);
+
+ if (cid && grub_strcmp (cid, "HTTPClient") == 0)
+ {
+ char *proto, *ip, *pa;
+
+ /* FIXME: Provide better URL function that returns in place pointers
+ * so that we don't have to free them.
+ */
+ if (!dissect_url (bp->boot_file, &proto, &ip, &pa))
+ return inter;
+
+ if (is_def)
+ {
+ grub_net_default_server = grub_strdup (ip);
+ grub_env_set ("net_default_interface", name);
+ grub_env_export ("net_default_interface");
+ }
+ if (device && !*device)
+ {
+ *device = grub_xasprintf ("%s,%s", proto, ip);
+ grub_print_error ();
+ }
+
+ boot_file = pa;
+ boot_file_len = grub_strlen (pa);
+
+ /* FIXME: Don't use malloc buffer here */
+ grub_free (proto);
+ grub_free (ip);
+
+ /* FIXME: NEED TO FREE boot_file */
+ goto boot_file;
+ }
+ }
+
opt = find_dhcp_option (bp, size, GRUB_NET_DHCP_OVERLOAD, &opt_len);
if (opt && opt_len == 1)
overload = *opt;
@@ -416,6 +463,8 @@ grub_net_configure_by_dhcp_ack (const ch
}
}
+boot_file:
+
if (boot_file)
{
grub_env_set_net_property (name, "boot_file", boot_file, boot_file_len);
Index: grub-2.04~rc1/include/grub/net.h
===================================================================
--- grub-2.04~rc1.orig/include/grub/net.h
+++ grub-2.04~rc1/include/grub/net.h
@@ -523,6 +523,7 @@ enum
GRUB_NET_BOOTP_DOMAIN = 0x0f,
GRUB_NET_BOOTP_ROOT_PATH = 0x11,
GRUB_NET_BOOTP_EXTENSIONS_PATH = 0x12,
+ GRUB_NET_BOOTP_VENDOR_CLASS_IDENTIFIER = 0x3C,
GRUB_NET_DHCP_REQUESTED_IP_ADDRESS = 50,
GRUB_NET_DHCP_OVERLOAD = 52,
GRUB_NET_DHCP_MESSAGE_TYPE = 53,