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