dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

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

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