|
|
5593c8 |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
5593c8 |
From: Peter Jones <pjones@redhat.com>
|
|
|
5593c8 |
Date: Mon, 8 Jul 2019 17:33:22 +0200
|
|
|
5593c8 |
Subject: [PATCH] Try mac/guid/etc before grub.cfg on tftp config files.
|
|
|
5593c8 |
|
|
|
5593c8 |
Signed-off-by: Peter Jones <pjones@redhat.com>
|
|
|
5593c8 |
---
|
|
|
5593c8 |
grub-core/normal/main.c | 97 ++++++++++++++++++++++++++-----------------------
|
|
|
5593c8 |
1 file changed, 51 insertions(+), 46 deletions(-)
|
|
|
5593c8 |
|
|
|
5593c8 |
diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c
|
|
|
d3c3ab |
index d85f7598d23..1e509fceb91 100644
|
|
|
5593c8 |
--- a/grub-core/normal/main.c
|
|
|
5593c8 |
+++ b/grub-core/normal/main.c
|
|
|
5593c8 |
@@ -347,61 +347,66 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)),
|
|
|
5593c8 |
/* Guess the config filename. It is necessary to make CONFIG static,
|
|
|
5593c8 |
so that it won't get broken by longjmp. */
|
|
|
5593c8 |
char *config;
|
|
|
5593c8 |
- const char *prefix, *fw_path;
|
|
|
5593c8 |
-
|
|
|
5593c8 |
- prefix = fw_path = grub_env_get ("fw_path");
|
|
|
5593c8 |
- if (fw_path)
|
|
|
5593c8 |
- {
|
|
|
5593c8 |
- config = grub_xasprintf ("%s/grub.cfg", fw_path);
|
|
|
5593c8 |
- if (config)
|
|
|
5593c8 |
- {
|
|
|
5593c8 |
- grub_file_t file;
|
|
|
5593c8 |
-
|
|
|
5593c8 |
- file = grub_file_open (config, GRUB_FILE_TYPE_CONFIG);
|
|
|
5593c8 |
- if (file)
|
|
|
5593c8 |
- {
|
|
|
5593c8 |
- grub_file_close (file);
|
|
|
5593c8 |
- grub_enter_normal_mode (config);
|
|
|
5593c8 |
- }
|
|
|
5593c8 |
- else
|
|
|
5593c8 |
- {
|
|
|
5593c8 |
- /* Ignore all errors. */
|
|
|
5593c8 |
- grub_errno = 0;
|
|
|
5593c8 |
- }
|
|
|
5593c8 |
- grub_free (config);
|
|
|
5593c8 |
- }
|
|
|
5593c8 |
- }
|
|
|
5593c8 |
+ const char *prefix;
|
|
|
5593c8 |
+ const char *net_search_cfg;
|
|
|
5593c8 |
+ int disable_net_search = 0;
|
|
|
5593c8 |
|
|
|
5593c8 |
+ prefix = grub_env_get ("fw_path");
|
|
|
5593c8 |
if (! prefix)
|
|
|
5593c8 |
prefix = grub_env_get ("prefix");
|
|
|
5593c8 |
+
|
|
|
5593c8 |
+ net_search_cfg = grub_env_get ("feature_net_search_cfg");
|
|
|
5593c8 |
+ if (net_search_cfg && net_search_cfg[0] == 'n')
|
|
|
5593c8 |
+ disable_net_search = 1;
|
|
|
5593c8 |
+
|
|
|
5593c8 |
if (prefix)
|
|
|
5593c8 |
{
|
|
|
5593c8 |
- grub_size_t config_len;
|
|
|
5593c8 |
- int disable_net_search = 0;
|
|
|
5593c8 |
- const char *net_search_cfg;
|
|
|
5593c8 |
-
|
|
|
5593c8 |
- config_len = grub_strlen (prefix) +
|
|
|
5593c8 |
- sizeof ("/grub.cfg-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX");
|
|
|
5593c8 |
- config = grub_malloc (config_len);
|
|
|
5593c8 |
-
|
|
|
5593c8 |
- if (!config)
|
|
|
5593c8 |
- goto quit;
|
|
|
5593c8 |
-
|
|
|
5593c8 |
- grub_snprintf (config, config_len, "%s/grub.cfg", prefix);
|
|
|
5593c8 |
-
|
|
|
5593c8 |
- net_search_cfg = grub_env_get ("feature_net_search_cfg");
|
|
|
5593c8 |
- if (net_search_cfg && net_search_cfg[0] == 'n')
|
|
|
5593c8 |
- disable_net_search = 1;
|
|
|
5593c8 |
-
|
|
|
5593c8 |
if (grub_strncmp (prefix + 1, "tftp", sizeof ("tftp") - 1) == 0 &&
|
|
|
5593c8 |
!disable_net_search)
|
|
|
5593c8 |
- grub_net_search_config_file (config);
|
|
|
5593c8 |
+ {
|
|
|
5593c8 |
+ grub_size_t config_len;
|
|
|
5593c8 |
+ config_len = grub_strlen (prefix) +
|
|
|
5593c8 |
+ sizeof ("/grub.cfg-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX");
|
|
|
5593c8 |
+ config = grub_malloc (config_len);
|
|
|
5593c8 |
|
|
|
5593c8 |
- grub_enter_normal_mode (config);
|
|
|
5593c8 |
- grub_free (config);
|
|
|
5593c8 |
- }
|
|
|
5593c8 |
+ if (! config)
|
|
|
5593c8 |
+ goto quit;
|
|
|
5593c8 |
+
|
|
|
5593c8 |
+ grub_snprintf (config, config_len, "%s/grub.cfg", prefix);
|
|
|
5593c8 |
+
|
|
|
5593c8 |
+ grub_net_search_configfile (config);
|
|
|
5593c8 |
+
|
|
|
5593c8 |
+ grub_enter_normal_mode (config);
|
|
|
5593c8 |
+ grub_free (config);
|
|
|
5593c8 |
+ config = NULL;
|
|
|
5593c8 |
+ }
|
|
|
5593c8 |
+
|
|
|
5593c8 |
+ if (!config)
|
|
|
5593c8 |
+ {
|
|
|
5593c8 |
+ config = grub_xasprintf ("%s/grub.cfg", prefix);
|
|
|
5593c8 |
+ if (config)
|
|
|
5593c8 |
+ {
|
|
|
5593c8 |
+ grub_file_t file;
|
|
|
5593c8 |
+
|
|
|
5593c8 |
+ file = grub_file_open (config, GRUB_FILE_TYPE_CONFIG);
|
|
|
5593c8 |
+ if (file)
|
|
|
5593c8 |
+ {
|
|
|
5593c8 |
+ grub_file_close (file);
|
|
|
5593c8 |
+ grub_enter_normal_mode (config);
|
|
|
5593c8 |
+ }
|
|
|
5593c8 |
+ else
|
|
|
5593c8 |
+ {
|
|
|
5593c8 |
+ /* Ignore all errors. */
|
|
|
5593c8 |
+ grub_errno = 0;
|
|
|
5593c8 |
+ }
|
|
|
5593c8 |
+ grub_free (config);
|
|
|
5593c8 |
+ }
|
|
|
5593c8 |
+ }
|
|
|
5593c8 |
+ }
|
|
|
5593c8 |
else
|
|
|
5593c8 |
- grub_enter_normal_mode (0);
|
|
|
5593c8 |
+ {
|
|
|
5593c8 |
+ grub_enter_normal_mode (0);
|
|
|
5593c8 |
+ }
|
|
|
5593c8 |
}
|
|
|
5593c8 |
else
|
|
|
5593c8 |
grub_enter_normal_mode (argv[0]);
|