From owner-freebsd-bugs@FreeBSD.ORG Wed Sep 3 21:20:03 2008 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 88F0D10656CC; Wed, 3 Sep 2008 21:20:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 12C658FC1D; Wed, 3 Sep 2008 21:20:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m83LK2qW064045; Wed, 3 Sep 2008 21:20:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m83LK2KT064044; Wed, 3 Sep 2008 21:20:02 GMT (envelope-from gnats) Resent-Date: Wed, 3 Sep 2008 21:20:02 GMT Resent-Message-Id: <200809032120.m83LK2KT064044@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@freebsd.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Cc: brooks@freebsd.org Resent-Reply-To: FreeBSD-gnats-submit@freebsd.org, Eygene Ryabinkin Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EEEBE1065675 for ; Wed, 3 Sep 2008 21:14:05 +0000 (UTC) (envelope-from rea-fbsd@codelabs.ru) Received: from 0.mx.codelabs.ru (0.mx.codelabs.ru [144.206.177.45]) by mx1.freebsd.org (Postfix) with ESMTP id A19008FC27 for ; Wed, 3 Sep 2008 21:14:05 +0000 (UTC) (envelope-from rea-fbsd@codelabs.ru) Received: from phoenix.codelabs.ru (ppp85-141-64-252.pppoe.mtu-net.ru [85.141.64.252]) by 0.mx.codelabs.ru with esmtps (TLSv1:CAMELLIA256-SHA:256) id 1Kazfw-000Cdj-N5 for FreeBSD-gnats-submit@freebsd.org; Thu, 04 Sep 2008 01:14:04 +0400 Message-Id: <20080903195036.2F1B6F1836@phoenix.codelabs.ru> Date: Wed, 3 Sep 2008 23:50:36 +0400 (MSD) From: Eygene Ryabinkin To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.113 X-GNATS-Notify: brooks@freebsd.org Cc: Subject: bin/127076: [patch] teach dhclient to recognize options 66 and 67 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Eygene Ryabinkin List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Sep 2008 21:20:03 -0000 >Number: 127076 >Category: bin >Synopsis: [patch] teach dhclient to recognize options 66 and 67 >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Sep 03 21:20:02 UTC 2008 >Closed-Date: >Last-Modified: >Originator: Eygene Ryabinkin >Release: FreeBSD 7.1-PRERELEASE i386 >Organization: Code Labs >Environment: System: FreeBSD XXX 7.1-PRERELEASE FreeBSD 7.1-PRERELEASE #7: Wed Sep 3 16:42:27 MSD 2008 root@XXX:/usr/src/sys/i386/compile/XXX i386 >Description: Dhclient does not pass option 66, TFTP server name, and option 67, bootfile name, to the dhclient-script, because these options are not validated in the check_option(). These options are used for PXE/diskless environments. I am using them to discover TFTP server and sysinstall configuration file template during automated PXE installation of FreeBSD. >How-To-Repeat: Set up DHCP server to give away tftp-server-name and bootfile-name. For ISC dhcpd it will look like ----- host XXX { ... option tftp-server-name "172.16.0.254"; option bootfile-name "machine.img"; } ----- Then spawn dhclient and watch for output entries like ----- unknown dhcp option value 0x42 unknown dhcp option value 0x43 ----- Also try to get the values of environment variables 'new-tftp-server-name' and 'new-bootfile-name' in /sbin/dhclient-script -- they will be unset. >Fix: The following patch adds recognition for the mentioned options. There is no real validation, since both options are strings and may have arbitrary structure. I had tested this patch with dhclient from 7-STABLE and ISC dhcpd 3.x. Works as expected. --- dhclient-options-66-and-67.patch begins here --- >From 9e60cf5c6f86ef6dfe4fa02cf5b0388f8e11004c Mon Sep 17 00:00:00 2001 From: Eygene Ryabinkin Date: Wed, 3 Sep 2008 23:31:12 +0400 Option 66, TFTP server name, and option 67, bootfile name, are often used when one wants to retrieve TFTP server name and boot file via DHCP in PXE or diskless environments. Teach dhclient to recognize these options and pass them to the dhclient-script. Signed-off-by: Eygene Ryabinkin --- sbin/dhclient/dhclient.c | 2 ++ sbin/dhclient/dhcp.h | 2 ++ 2 files changed, 4 insertions(+), 0 deletions(-) diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index a18e17c..88f0030 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -2390,6 +2390,8 @@ check_option(struct client_lease *l, int option) case DHO_DHCP_CLIENT_IDENTIFIER: case DHO_DHCP_USER_CLASS_ID: case DHO_END: + case DHO_TFTP_SERVER_NAME: + case DHO_BOOTFILE_NAME: return (1); case DHO_CLASSLESS_ROUTES: return (check_classless_option(l->options[option].data, diff --git a/sbin/dhclient/dhcp.h b/sbin/dhclient/dhcp.h index aa69930..22d698d 100644 --- a/sbin/dhclient/dhcp.h +++ b/sbin/dhclient/dhcp.h @@ -155,6 +155,8 @@ struct dhcp_packet { #define DHO_DHCP_REBINDING_TIME 59 #define DHO_DHCP_CLASS_IDENTIFIER 60 #define DHO_DHCP_CLIENT_IDENTIFIER 61 +#define DHO_TFTP_SERVER_NAME 66 +#define DHO_BOOTFILE_NAME 67 #define DHO_SMTP_SERVER 69 #define DHO_POP_SERVER 70 #define DHO_NNTP_SERVER 71 -- 1.5.6.4 --- dhclient-options-66-and-67.patch ends here --- >Release-Note: >Audit-Trail: >Unformatted: