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

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