From nobody@FreeBSD.ORG Mon Jun 14 07:17:44 1999
Return-Path: <nobody@FreeBSD.ORG>
Received: by hub.freebsd.org (Postfix, from userid 32767)
	id 3A34015349; Mon, 14 Jun 1999 07:17:44 -0700 (PDT)
Message-Id: <19990614141744.3A34015349@hub.freebsd.org>
Date: Mon, 14 Jun 1999 07:17:44 -0700 (PDT)
From: jobaldwi@vt.edu
Sender: nobody@FreeBSD.ORG
To: freebsd-gnats-submit@freebsd.org
Subject: [PATCH] DHCP client does not set hostnames, and garbles them as well
X-Send-Pr-Version: www-1.0

>Number:         12205
>Category:       bin
>Synopsis:       [PATCH] DHCP client does not set hostnames, and garbles them as well
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    obrien
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jun 14 07:20:01 PDT 1999
>Closed-Date:    Wed Aug 4 08:17:57 PDT 1999
>Last-Modified:  Wed Aug  4 08:18:11 PDT 1999
>Originator:     John Baldwin
>Release:        3.2-STABLE
>Organization:
>Environment:
FreeBSD xxxxxxx.xxxxx.vt.edu 3.2-STABLE FreeBSD 3.2-STABLE #2: Sat Jun  5 18:57:
30 EDT 1999     root@xxxxxxx.xxxxx.vt.edu:/usr/source/src/sys/compile/SNOWCOW  i
386
>Description:
The dhcp client in /usr/src/contrib/isc-dhcp does not support setting
hostnames.  Also, it currently sets the hostname to a hexadecimal
representation of the hostname instead of the actual text.  (Sigh.)
>How-To-Repeat:
Well, you need a dhcp server setup that sends hostnames, and a client
that requests hostnames.  Then, boot the system.  The hostname will not
be set.  Then, apply the first patch to /usr/src/contrib/isc-dhcp/clients/scripts/freebsd
and the hostname will be set to a long, annoying, hex string.  Finally,
apply the second patch to /usr/src/contrib/isc-dhcp/common/tables.c
and the hostname will be set properly.
>Fix:
This is a patch to /usr/src/contrib/isc-dhcp/client/scripts/freebsd:

Index: freebsd
===================================================================
RCS file: /src/cvs/src/contrib/isc-dhcp/client/scripts/freebsd,v
retrieving revision 1.1.1.2.2.3
diff -r1.1.1.2.2.3 freebsd
32a33,41
> if [ x$new_host_name != x ]; then
>     $LOGGER New Host Name: $new_host_name
>     new_host_name_arg=$new_host_name
> fi
>
> if [ x$old_host_name != x ]; then
>     old_host_name_arg=$old_host_name
> fi
>
82a92,96
>   if [ x$old_host_name = x ] || \
>                 [ x$old_host_name != x$new_host_name ] || \
>                 [ x$reason = xBOUND ] || [x$reason = xREBOOT]; then
>      hostname "$new_host_name_arg"
>   fi
159a174
>   hostname $new_host_name_arg

This is a patch to /usr/src/contrib/isc-dhcp/common/tables.c:

Index: tables.c
===================================================================
RCS file: /src/cvs/src/contrib/isc-dhcp/common/tables.c,v
retrieving revision 1.1.1.2.2.2
diff -r1.1.1.2.2.2 tables.c
81c81
<       { "host-name", "X",                             &dhcp_universe, 12 },
---
>       { "host-name", "t",                             &dhcp_universe, 12 },

>Release-Note:
>Audit-Trail:

From: Studded <Studded@gorean.org>
To: jobaldwi@vt.edu
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: bin/12205: [PATCH] DHCP client does not set hostnames, and garbles 
 them as well
Date: Sat, 19 Jun 1999 02:16:02 -0700

 jobaldwi@vt.edu wrote:
 
 > >Description:
 > The dhcp client in /usr/src/contrib/isc-dhcp does not support setting
 > hostnames.  Also, it currently sets the hostname to a hexadecimal
 > representation of the hostname instead of the actual text.  (Sigh.)
 
 	This is really interesting. I've used my own version of the script to set
 my hostname for years and it's never done this. How are you requesting the
 hostname in your dhcp conf file?  I use the following:
 
 interface "ep0" {
  request subnet-mask, broadcast-address, routers, domain-name-servers,
          domain-name, host-name;
  require domain-name-servers;
 }
 
 
 > >How-To-Repeat:
 > Well, you need a dhcp server setup that sends hostnames, and a client
 > that requests hostnames.  Then, boot the system.  The hostname will not
 > be set.  Then, apply the first patch to /usr/src/contrib/isc-dhcp/clients/scripts/freebsd
 > and the hostname will be set to a long, annoying, hex string. 
 
 	With respect, an approach like this takes into account a wider variety of
 dhcp server implementations:
 
   if [ x$new_host_name != x ]; then 
     if [ x$new_domain_name != x ]; then 
       hostname $new_host_name.$new_domain_name 
       echo New Hostname: $new_host_name.$new_domain_name 
     else 
       hostname $new_host_name 
       echo New Hostname: $new_host_name
     fi
   fi
 
 Doug
 

From: John Baldwin <jobaldwi@vt.edu>
To: Studded <Studded@gorean.org>
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: bin/12205: [PATCH] DHCP client does not set hostnames, and g
Date: Sat, 19 Jun 1999 10:06:37 -0400 (EDT)

 On 19-Jun-99 Studded wrote:
 > jobaldwi@vt.edu wrote:
 > 
 >> >Description:
 >> The dhcp client in /usr/src/contrib/isc-dhcp does not support setting
 >> hostnames.  Also, it currently sets the hostname to a hexadecimal
 >> representation of the hostname instead of the actual text.  (Sigh.)
 > 
 >       This is really interesting. I've used my own version of the script to
 set
 > my hostname for years and it's never done this. How are you requesting the
 > hostname in your dhcp conf file?  I use the following:
 > 
 > interface "ep0" {
 >  request subnet-mask, broadcast-address, routers, domain-name-servers,
 >          domain-name, host-name;
 >  require domain-name-servers;
 > }
 
 Here's my .conf file:
 
 retry 60;
 select-timeout 5;
 initial-interval 2;
 request subnet-mask, broadcast-address, time-offset, routers,
         domain-name, domain-name-servers, host-name;
 require subnet-mask, domain-name-servers;
 
 This worked fine with older versions of the client.. it wasn't until I tried to
 use the built in dhclient in /sbin that things broke.  The real "bug" in this
 PR is the change to tables.c.
 
 >> >How-To-Repeat:
 >> Well, you need a dhcp server setup that sends hostnames, and a client
 >> that requests hostnames.  Then, boot the system.  The hostname will not
 >> be set.  Then, apply the first patch to
 >> /usr/src/contrib/isc-dhcp/clients/scripts/freebsd
 >> and the hostname will be set to a long, annoying, hex string. 
 > 
 >       With respect, an approach like this takes into account a wider variety
 of
 > dhcp server implementations:
 > 
 >   if [ x$new_host_name != x ]; then 
 >     if [ x$new_domain_name != x ]; then 
 >       hostname $new_host_name.$new_domain_name 
 >       echo New Hostname: $new_host_name.$new_domain_name 
 >     else 
 >       hostname $new_host_name 
 >       echo New Hostname: $new_host_name
 >     fi
 >   fi
 
 Great..  I'm not a DHCP genius, I just copied over all the hostname parts from
 the script we ran with the older client/server port that was installed over a
 year ago on a 2.2.7 server, so if that will work better, than by all means,
 commit that sequence for setting hostnames than what I have.  Thanks.
 
 > Doug
 
 ---
 
 John Baldwin <jobaldwi@vt.edu> -- http://members.freedomnet.com/~jbaldwin/
 PGP Key: http://members.freedomnet.com/~jbaldwin/pgpkey.asc
 "Power Users Use the Power to Serve!"  -  http://www.freebsd.org
 
Responsible-Changed-From-To: freebsd-bugs->obrien 
Responsible-Changed-By: msmith 
Responsible-Changed-When: Wed Jun 23 20:11:13 PDT 1999 
Responsible-Changed-Why:  
David is Mr DHCP 
State-Changed-From-To: open->closed 
State-Changed-By: obrien 
State-Changed-When: Wed Aug 4 08:17:57 PDT 1999 
State-Changed-Why:  
problems fixed. 
>Unformatted:
