Blame SOURCES/0287-Make-root_url-reflect-the-protocol-hostname-of-our-b.patch

28f7f8
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
28f7f8
From: Peter Jones <pjones@redhat.com>
28f7f8
Date: Mon, 30 Jul 2018 16:39:57 -0400
28f7f8
Subject: [PATCH] Make root_url reflect the protocol+hostname of our boot url.
28f7f8
28f7f8
Signed-off-by: Peter Jones <pjones@redhat.com>
28f7f8
---
28f7f8
 grub-core/net/efi/http.c | 19 +++++++++++++++++++
28f7f8
 1 file changed, 19 insertions(+)
28f7f8
28f7f8
diff --git a/grub-core/net/efi/http.c b/grub-core/net/efi/http.c
28f7f8
index 3f61fd2fa5b..243acbaa35b 100644
28f7f8
--- a/grub-core/net/efi/http.c
28f7f8
+++ b/grub-core/net/efi/http.c
28f7f8
@@ -4,6 +4,7 @@
28f7f8
 #include <grub/misc.h>
28f7f8
 #include <grub/net/efi.h>
28f7f8
 #include <grub/charset.h>
28f7f8
+#include <grub/env.h>
28f7f8
 
28f7f8
 static void
28f7f8
 http_configure (struct grub_efi_net_device *dev, int prefer_ip6)
28f7f8
@@ -351,6 +352,24 @@ grub_efihttp_open (struct grub_efi_net_device *dev,
28f7f8
   grub_err_t err;
28f7f8
   grub_off_t size;
28f7f8
   char *buf;
28f7f8
+  char *root_url;
28f7f8
+  grub_efi_ipv6_address_t address;
28f7f8
+  const char *rest;
28f7f8
+
28f7f8
+  if (grub_efi_string_to_ip6_address (file->device->net->server, &address, &rest) && *rest == 0)
28f7f8
+    root_url = grub_xasprintf ("%s://[%s]", type ? "https" : "http", file->device->net->server);
28f7f8
+  else
28f7f8
+    root_url = grub_xasprintf ("%s://%s", type ? "https" : "http", file->device->net->server);
28f7f8
+  if (root_url)
28f7f8
+    {
28f7f8
+      grub_env_unset ("root_url");
28f7f8
+      grub_env_set ("root_url", root_url);
28f7f8
+      grub_free (root_url);
28f7f8
+    }
28f7f8
+  else
28f7f8
+    {
28f7f8
+      return grub_errno;
28f7f8
+    }
28f7f8
 
28f7f8
   err = efihttp_request (dev->http, file->device->net->server, file->device->net->name, type, 1, 0);
28f7f8
   if (err != GRUB_ERR_NONE)