On Friday 25 Mar 2011 18:14:11 Mike Sollanych wrote:
> I'm working on a project that aims to centralize deployment methods at a
>  university. iPXE is going to be the cornerstone of this effort.
> 
> One thing we'd like to be able to do is to allow various other IT
>  departments to use this central iPXE menu to boot to their existing PXE
>  servers (i.e. FOG, Ghost, Cobbler, etc). It seems like this should be
>  possible with chain command, and indeed it will go ahead and load a
>  PXELINUX image from another TFTP server, but when that image is launched,
>  it appears to be looking at the iPXE server to get the new pxelinux.cfg
>  file, not the newly supplied other PXE server.
> 
> Is there a good way to "bounce" off of iPXE and over to another PXE server?

You may need to override the DHCP-provided "next server" address in order to 
persude the subsequent pxelinux (or other NBP) that it should refer to a 
different server.  You can do this using the "set" command 
(http://ipxe.org/cmd/set) to set the "next-server" and/or "filename" variables, 
e.g.

  set next-server 192.168.0.1
  set filename boot/pxelinux.0
  chain tftp://${next-server}/${filename}

When the new NBP queries iPXE to establish where server it was loaded from, it 
will see the overridden values from next-server and filename, rather than the 
original DHCP-provided values.

For pxelinux (and only pxelinux), you can use DHCP options 209 and 210 to 
control the location of the pxelinux.cfg file.

> Alternately, we may be able to solve *most* of this problem if we could use
>  iPXE variables (i.e. ${hostname}, ${mac}) inside of vesamenu.c32, so that
>  pointing at things like our FOG server (which generates MAC-specific
>  pxelinux.cfg files to perform 'tasks') could be done in a dynamic fashion.
> 
> If there's a way to do either of these, please let me know.

There isn't yet, but it sounds useful.  We currently perform settings 
expansion when parsing the DHCP-provided filename and root-path.  We could 
pretty easily also expand filenames received via the PXE FILE API.  Could you 
try the attached (untested) patch, and see if it does what you need?

Michael
diff --git a/src/arch/i386/interface/pxe/pxe_file.c b/src/arch/i386/interface/pxe/pxe_file.c
index 2676256..713dbbf 100644
--- a/src/arch/i386/interface/pxe/pxe_file.c
+++ b/src/arch/i386/interface/pxe/pxe_file.c
@@ -50,25 +50,31 @@ FEATURE ( FEATURE_MISC, "PXEXT", DHCP_EB_FEATURE_PXE_EXT, 2 );
  *
  */
 PXENV_EXIT_t pxenv_file_open ( struct s_PXENV_FILE_OPEN *file_open ) {
-	userptr_t filename;
-	size_t filename_len;
+	userptr_t raw_filename;
+	size_t raw_filename_len;
+	char *filename;
 	int fd;
 
 	DBG ( "PXENV_FILE_OPEN" );
 
 	/* Copy name from external program, and open it */
-	filename = real_to_user ( file_open->FileName.segment,
-			      file_open->FileName.offset );
-	filename_len = strlen_user ( filename, 0 );
+	raw_filename = real_to_user ( file_open->FileName.segment,
+				      file_open->FileName.offset );
+	raw_filename_len = strlen_user ( raw_filename, 0 );
 	{
-		char uri_string[ filename_len + 1 ];
+		char buf[ raw_filename_len + 1 /* NUL */ ];
 
-		copy_from_user ( uri_string, filename, 0,
-				 sizeof ( uri_string ) );
-		DBG ( " %s", uri_string );
-		fd = open ( uri_string );
+		copy_from_user ( buf, raw_filename, 0, sizeof ( buf ) );
+		DBG ( " %s", buf );
+
+		filename = expand_settings ( buf );
+		if ( ! filename ) {
+			file_open->Status = PXENV_STATUS_OUT_OF_RESOURCES;
+			return PXENV_EXIT_FAILURE;
+		}
 	}
 
+	fd = open ( filename );
 	if ( fd < 0 ) {
 		file_open->Status = PXENV_STATUS ( fd );
 		return PXENV_EXIT_FAILURE;
_______________________________________________
ipxe-devel mailing list
[email protected]
https://lists.ipxe.org/mailman/listinfo/ipxe-devel

Reply via email to