|
|
57753c |
From b83eff7520225d393dec4d656bc9cab915495a5c Mon Sep 17 00:00:00 2001
|
|
|
57753c |
From: Alex Williamson <alex.williamson@redhat.com>
|
|
|
57753c |
Date: Fri, 7 Feb 2014 17:21:17 +0100
|
|
|
57753c |
Subject: [PATCH] Use next-server from filename's settings block
|
|
|
57753c |
|
|
|
57753c |
RH-Author: Alex Williamson <alex.williamson@redhat.com>
|
|
|
57753c |
Message-id: <20140207172042.26907.16755.stgit@bling.home>
|
|
|
57753c |
Patchwork-id: 57133
|
|
|
57753c |
O-Subject: [RHEL7 ipxe PATCH] [autoboot] Use next-server from filename's settings block
|
|
|
57753c |
Bugzilla: 1062644
|
|
|
57753c |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
57753c |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
57753c |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
57753c |
|
|
|
57753c |
From: Michael Brown <mcb30@ipxe.org>
|
|
|
57753c |
|
|
|
57753c |
Bugzilla: 1062644
|
|
|
57753c |
Brew: https://brewweb.devel.redhat.com/taskinfo?taskID=7015017
|
|
|
57753c |
Upstream: 936134ed460618e18cc05d677a442d43d5e739a1
|
|
|
57753c |
|
|
|
57753c |
Locate the settings block containing the filename, and search only
|
|
|
57753c |
that settings block for the next-server address. This avoids problems
|
|
|
57753c |
caused by misconfigured DHCP servers which provide a next-server
|
|
|
57753c |
address (often defaulting to the DHCP server's own IP address) even
|
|
|
57753c |
when not providing a filename.
|
|
|
57753c |
|
|
|
57753c |
Originally-implemented-by: Alex Williamson <alex.williamson@redhat.com>
|
|
|
57753c |
Signed-off-by: Michael Brown <mcb30@ipxe.org>
|
|
|
57753c |
---
|
|
|
57753c |
src/usr/autoboot.c | 39 +++++++++++++++++++++++++--------------
|
|
|
57753c |
1 file changed, 25 insertions(+), 14 deletions(-)
|
|
|
57753c |
|
|
|
57753c |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
57753c |
---
|
|
|
57753c |
src/usr/autoboot.c | 39 +++++++++++++++++++++++++--------------
|
|
|
57753c |
1 files changed, 25 insertions(+), 14 deletions(-)
|
|
|
57753c |
|
|
|
57753c |
diff --git a/src/usr/autoboot.c b/src/usr/autoboot.c
|
|
|
57753c |
index b2d288e..70f883a 100644
|
|
|
57753c |
--- a/src/usr/autoboot.c
|
|
|
57753c |
+++ b/src/usr/autoboot.c
|
|
|
57753c |
@@ -251,31 +251,42 @@ static void close_all_netdevs ( void ) {
|
|
|
57753c |
* @ret uri URI, or NULL on failure
|
|
|
57753c |
*/
|
|
|
57753c |
struct uri * fetch_next_server_and_filename ( struct settings *settings ) {
|
|
|
57753c |
- struct in_addr next_server;
|
|
|
57753c |
- char buf[256];
|
|
|
57753c |
+ struct in_addr next_server = { 0 };
|
|
|
57753c |
+ char *raw_filename = NULL;
|
|
|
57753c |
+ struct uri *uri = NULL;
|
|
|
57753c |
char *filename;
|
|
|
57753c |
- struct uri *uri;
|
|
|
57753c |
|
|
|
57753c |
- /* Fetch next-server setting */
|
|
|
57753c |
- fetch_ipv4_setting ( settings, &next_server_setting, &next_server );
|
|
|
57753c |
- if ( next_server.s_addr )
|
|
|
57753c |
- printf ( "Next server: %s\n", inet_ntoa ( next_server ) );
|
|
|
57753c |
+ /* Determine settings block containing the filename, if any */
|
|
|
57753c |
+ settings = fetch_setting_origin ( settings, &filename_setting );
|
|
|
57753c |
|
|
|
57753c |
- /* Fetch filename setting */
|
|
|
57753c |
- fetch_string_setting ( settings, &filename_setting,
|
|
|
57753c |
- buf, sizeof ( buf ) );
|
|
|
57753c |
- if ( buf[0] )
|
|
|
57753c |
- printf ( "Filename: %s\n", buf );
|
|
|
57753c |
+ /* If we have a filename, fetch it along with next-server */
|
|
|
57753c |
+ if ( settings ) {
|
|
|
57753c |
+ fetch_ipv4_setting ( settings, &next_server_setting,
|
|
|
57753c |
+ &next_server );
|
|
|
57753c |
+ if ( fetch_string_setting_copy ( settings, &filename_setting,
|
|
|
57753c |
+ &raw_filename ) < 0 )
|
|
|
57753c |
+ goto err_fetch;
|
|
|
57753c |
+ }
|
|
|
57753c |
|
|
|
57753c |
/* Expand filename setting */
|
|
|
57753c |
- filename = expand_settings ( buf );
|
|
|
57753c |
+ filename = expand_settings ( raw_filename ? raw_filename : "" );
|
|
|
57753c |
if ( ! filename )
|
|
|
57753c |
- return NULL;
|
|
|
57753c |
+ goto err_expand;
|
|
|
57753c |
|
|
|
57753c |
/* Parse next server and filename */
|
|
|
57753c |
+ if ( next_server.s_addr )
|
|
|
57753c |
+ printf ( "Next server: %s\n", inet_ntoa ( next_server ) );
|
|
|
57753c |
+ if ( filename[0] )
|
|
|
57753c |
+ printf ( "Filename: %s\n", filename );
|
|
|
57753c |
uri = parse_next_server_and_filename ( next_server, filename );
|
|
|
57753c |
+ if ( ! uri )
|
|
|
57753c |
+ goto err_parse;
|
|
|
57753c |
|
|
|
57753c |
+ err_parse:
|
|
|
57753c |
free ( filename );
|
|
|
57753c |
+ err_expand:
|
|
|
57753c |
+ free ( raw_filename );
|
|
|
57753c |
+ err_fetch:
|
|
|
57753c |
return uri;
|
|
|
57753c |
}
|
|
|
57753c |
|
|
|
57753c |
--
|
|
|
57753c |
1.7.1
|
|
|
57753c |
|