dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

Blame SOURCES/0260-set-rootpath.patch

28f7f8
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
27a4da
From: Peter Jones <pjones@redhat.com>
27a4da
Date: Wed, 24 May 2017 15:02:40 -0400
28f7f8
Subject: [PATCH] set rootpath
27a4da
27a4da
Signed-off-by: Peter Jones <pjones@redhat.com>
27a4da
---
27a4da
 grub-core/net/bootp.c | 20 ++++++++++++++++++++
27a4da
 1 file changed, 20 insertions(+)
27a4da
27a4da
diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c
28f7f8
index d47ad80a2ad..249ca0c2dc6 100644
27a4da
--- a/grub-core/net/bootp.c
27a4da
+++ b/grub-core/net/bootp.c
27a4da
@@ -398,11 +398,31 @@ grub_net_configure_by_dhcp_ack (const char *name,
27a4da
 	      if (*path)
27a4da
 		{
27a4da
 		  char *slash;
27a4da
+		  int root_path_len;
27a4da
 		  slash = grub_strrchr (*path, '/');
27a4da
 		  if (slash)
27a4da
 		    *slash = 0;
27a4da
 		  else
27a4da
 		    **path = 0;
27a4da
+		  root_path_len = grub_strlen (*path);
27a4da
+		  if (root_path_len >= 9 &&
27a4da
+		      !grub_strcasecmp (&(*path)[root_path_len - 9], "/efi/boot"))
27a4da
+		    {
27a4da
+		      char *root_path;
27a4da
+		      grub_print_error ();
27a4da
+		      if (root_path_len - 9 == 0)
27a4da
+			{
27a4da
+			  root_path_len = 1;
27a4da
+			  root_path = grub_xasprintf ("/");
27a4da
+			}
27a4da
+		      else
27a4da
+			{
27a4da
+			  root_path_len -= 9;
27a4da
+			  root_path = grub_strndup (*path, root_path_len);
27a4da
+			}
27a4da
+		      grub_env_set_net_property (name, "rootpath",
27a4da
+						 root_path, root_path_len);
27a4da
+		    }
27a4da
 		}
27a4da
 	    }
27a4da
 	  grub_net_add_ipv4_local (inter, mask);