Blame SOURCES/0132-Try-mac-guid-etc-before-grub.cfg-on-tftp-config-file.patch

f731ee
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
f731ee
From: Peter Jones <pjones@redhat.com>
f731ee
Date: Thu, 6 Mar 2014 11:51:33 -0500
f731ee
Subject: [PATCH] Try mac/guid/etc before grub.cfg on tftp config files.
f731ee
f731ee
Signed-off-by: Peter Jones <pjones@redhat.com>
f731ee
---
f731ee
 grub-core/normal/main.c | 80 ++++++++++++++++++++++++++-----------------------
f731ee
 1 file changed, 43 insertions(+), 37 deletions(-)
f731ee
f731ee
diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c
f731ee
index 5e2ac150e12..4190985ad37 100644
f731ee
--- a/grub-core/normal/main.c
f731ee
+++ b/grub-core/normal/main.c
f731ee
@@ -341,53 +341,59 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)),
f731ee
       /* Guess the config filename. It is necessary to make CONFIG static,
f731ee
 	 so that it won't get broken by longjmp.  */
f731ee
       char *config;
f731ee
-      const char *prefix, *fw_path;
f731ee
-
f731ee
-      prefix = fw_path = grub_env_get ("fw_path");
f731ee
-      if (fw_path)
f731ee
-	{
f731ee
-	  config = grub_xasprintf ("%s/grub.cfg", fw_path);
f731ee
-	  if (config)
f731ee
-	    {
f731ee
-	      grub_file_t file;
f731ee
-
f731ee
-	      file = grub_file_open (config);
f731ee
-	      if (file)
f731ee
-		{
f731ee
-		  grub_file_close (file);
f731ee
-		  grub_enter_normal_mode (config);
f731ee
-		}
f731ee
-              else
f731ee
-                {
f731ee
-                  /*  Ignore all errors.  */
f731ee
-                  grub_errno = 0;
f731ee
-                }
f731ee
-	      grub_free (config);
f731ee
-	    }
f731ee
-	}
f731ee
+      const char *prefix;
f731ee
 
f731ee
+      prefix = grub_env_get ("fw_path");
f731ee
       if (! prefix)
f731ee
 	      prefix = grub_env_get ("prefix");
f731ee
+
f731ee
       if (prefix)
f731ee
-        {
f731ee
-          grub_size_t config_len;
f731ee
-          config_len = grub_strlen (prefix) +
f731ee
-                      sizeof ("/grub.cfg-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX");
f731ee
-          config = grub_malloc (config_len);
f731ee
+	{
f731ee
+	  if (grub_strncmp (prefix + 1, "tftp", sizeof ("tftp") - 1) == 0)
f731ee
+	    {
f731ee
+	      grub_size_t config_len;
f731ee
+	      config_len = grub_strlen (prefix) +
f731ee
+		sizeof ("/grub.cfg-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX");
f731ee
+	      config = grub_malloc (config_len);
f731ee
 
f731ee
-          if (! config)
f731ee
-            goto quit;
f731ee
+	      if (! config)
f731ee
+		goto quit;
f731ee
 
f731ee
-          grub_snprintf (config, config_len, "%s/grub.cfg", prefix);
f731ee
+	      grub_snprintf (config, config_len, "%s/grub.cfg", prefix);
f731ee
 
f731ee
-          if (grub_strncmp (prefix + 1, "tftp", sizeof ("tftp") - 1) == 0)
f731ee
-            grub_net_search_configfile (config);
f731ee
+	      grub_net_search_configfile (config);
f731ee
 
f731ee
-	  grub_enter_normal_mode (config);
f731ee
-	  grub_free (config);
f731ee
+	      grub_enter_normal_mode (config);
f731ee
+	      grub_free (config);
f731ee
+	      config = NULL;
f731ee
+	    }
f731ee
+
f731ee
+	  if (!config)
f731ee
+	    {
f731ee
+	      config = grub_xasprintf ("%s/grub.cfg", prefix);
f731ee
+	      if (config)
f731ee
+		{
f731ee
+		  grub_file_t file;
f731ee
+
f731ee
+		  file = grub_file_open (config);
f731ee
+		  if (file)
f731ee
+		    {
f731ee
+		      grub_file_close (file);
f731ee
+		      grub_enter_normal_mode (config);
f731ee
+		    }
f731ee
+		  else
f731ee
+		    {
f731ee
+		      /*  Ignore all errors.  */
f731ee
+		      grub_errno = 0;
f731ee
+		    }
f731ee
+		  grub_free (config);
f731ee
+		}
f731ee
+	    }
f731ee
 	}
f731ee
       else
f731ee
-	grub_enter_normal_mode (0);
f731ee
+	{
f731ee
+	  grub_enter_normal_mode (0);
f731ee
+	}
f731ee
     }
f731ee
   else
f731ee
     grub_enter_normal_mode (argv[0]);