From nobody@FreeBSD.org  Sun Jan 29 15:40:03 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id EE33D106566B
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 29 Jan 2012 15:40:03 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id D73AD8FC13
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 29 Jan 2012 15:40:03 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q0TFe2sT061781
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 29 Jan 2012 15:40:02 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id q0TFe26k061780;
	Sun, 29 Jan 2012 15:40:02 GMT
	(envelope-from nobody)
Message-Id: <201201291540.q0TFe26k061780@red.freebsd.org>
Date: Sun, 29 Jan 2012 15:40:02 GMT
From: Floris Bos <bos@je-eigen-domein.nl>
To: freebsd-gnats-submit@FreeBSD.org
Subject: TFTP pxeboot: should use root-path provided by DHCP
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         164604
>Category:       bin
>Synopsis:       [patch] tftp(1): TFTP pxeboot: should use root-path provided by DHCP
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jan 29 15:40:09 UTC 2012
>Closed-Date:    
>Last-Modified:  Mon Jan 30 04:14:11 UTC 2012
>Originator:     Floris Bos
>Release:        9.0
>Organization:
>Environment:
9.0-RELEASE
>Description:
When pxeboot is compiled with LOADER_TFTP_SUPPORT it always expects to
find the boot files in the /boot folder on the TFTP server.

This hardcoded value is inflexible and does not allow the network booting
of more than one version of FreeBSD.

Instead it should fetch the files from the path specified by the root-path
value supplied by DHCP, like other operating systems do.
>How-To-Repeat:
-
>Fix:
Attached a patch that uses the root-path parameter if present.
If the parameter is not present it reverts to the old behavior, so does
not break existing setups.

Patch attached with submission follows:

--- /usr/src/lib/libstand/tftp.c.orig	2012-01-28 21:07:55.000000000 +0100
+++ /usr/src/lib/libstand/tftp.c	2012-01-28 21:41:24.000000000 +0100
@@ -413,12 +413,22 @@
 
 	io->destip = servip;
 	tftpfile->off = 0;
-	tftpfile->path = strdup(path);
-	if (tftpfile->path == NULL) {
+	
+	if (path == NULL) {
 	    free(tftpfile);
 	    return(ENOMEM);
 	}
 
+	if (rootpath != NULL) {
+	    tftpfile->path = malloc(strlen(rootpath)+strlen(path)+1);
+	    strcpy(tftpfile->path, rootpath);
+	    strcat(tftpfile->path, path);
+	}
+	else
+	{
+	    tftpfile->path = strdup(path);
+	}
+
 	res = tftp_makereq(tftpfile);
 
 	if (res) {


>Release-Note:
>Audit-Trail:
>Unformatted:
