nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

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

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