From sean@dhcp194.private.gothic.net.au  Thu Jul 14 16:18:05 2005
Return-Path: <sean@dhcp194.private.gothic.net.au>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 6742316A41C
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 14 Jul 2005 16:18:05 +0000 (GMT)
	(envelope-from sean@dhcp194.private.gothic.net.au)
Received: from dhcp194.private.gothic.net.au (home.winn.id.au [202.182.72.30])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 7544743D46
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 14 Jul 2005 16:18:03 +0000 (GMT)
	(envelope-from sean@dhcp194.private.gothic.net.au)
Received: from dhcp194.private.gothic.net.au (localhost [127.0.0.1])
	by 64:68:63:70:31:39:34:2e:70:72:69:76:61:74:65:2e:67:6f:74:68:69:63:2e:6e:65:74:2e:61:75:0 (8.13.4/8.13.4) with ESMTP id j6EGGMZg000852
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 15 Jul 2005 02:16:22 +1000 (EST)
	(envelope-from sean@dhcp194.private.gothic.net.au)
Received: (from sean@localhost)
	by dhcp194.private.gothic.net.au (8.13.4/8.13.3/Submit) id j6EGGL4S000851;
	Fri, 15 Jul 2005 02:16:21 +1000 (EST)
	(envelope-from sean)
Message-Id: <200507141616.j6EGGL4S000851@dhcp194.private.gothic.net.au>
Date: Fri, 15 Jul 2005 02:16:21 +1000 (EST)
From: Sean Winn <sean@gothic.net.au>
Reply-To: Sean Winn <sean@gothic.net.au>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: imported OpenBSD dhclient handles hostnames differently to ISC DHCP 3 - come through as hex	
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         83468
>Category:       bin
>Synopsis:       imported OpenBSD dhclient handles hostnames differently to ISC DHCP 3 - come through as hex
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    brooks
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jul 14 16:20:10 GMT 2005
>Closed-Date:    Sat Aug 20 19:17:41 GMT 2005
>Last-Modified:  Sat Aug 20 19:17:41 GMT 2005
>Originator:     Sean Winn
>Release:        FreeBSD 7.0-CURRENT i386
>Organization:
>Environment:
System: FreeBSD 64:68:63:70:31:39:34:2e:70:72:69:76:61:74:65:2e:67:6f:74:68:69:63:2e:6e:65:74:2e:61:75:0 7.0-CURRENT FreeBSD 7.0-CURRENT #0: Fri Jul 15 00:18:58 EST 2005 sean@dhcp194.private.gothic.net.au:/usr/obj/usr/src/sys/NODEBUG i386


	
>Description:
	ISC dhclient changed behaviour between 2.x and 3.x, to handle 
	receiving a hostname via DHCP correctly; OpenBSD dhclient appears
	to be based on 2.x and still displays the same behaviour as 
	ISC dhclient 2.x;

	Hostname sent via ISC dhcpd 3.x: dhcp194.private.gothic.net.au
	Used on FreeBSD 4.x, 5.x system: dhcp194.private.gothic.net.au
	Used on FreeBSD CURRENT (probably RELENG_6): 64:68:63:70:31:39:34:2e:70:72:69:76:61:74:65:2e:67:6f:74:68:69:63:2e:6e:65:74:2e:61:75:0

(DHCP server uses get-lease-hostnames true so that DNS matches hostnames 
sent absolutely, if they use it)

>How-To-Repeat:
	Install a FreeBSD current machine, setting no hostname 
	in rc.conf and configuring DHCP to provide it.

>Fix:

The fix is in sbin/dhclient/options.c pretty_print_option() - hostname is 
sent with a trailing nul, and the OpenBSD dhclient pretty_print_option() 
sees the nul as a reason to pretty-print as a series of hex characters - 
later versions of ISC dhclient have:

                /* If we found no bogus characters, or the bogus
		   character we found is a trailing NUL, it's
		      okay to print this option as text. */
											      if (k == len || (k + 1 == len && data [k] == 0)) {
		      fmtbuf [l] = 't';
		      numhunk = -2;                                   

which makes hostnames come out as text. Applying the one line change restores
FreeBSD 4.x and 5.x behaviour.

>Release-Note:
>Audit-Trail:

From: Sean Winn <sean@gothic.net.au>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/83468: imported OpenBSD dhclient handles hostnames differently to ISC DHCP 3 - come through as hex
Date: Fri, 15 Jul 2005 09:49:02 +1000

 What's missing is the patch (also on 
 http://www.gothic.net.au/~sean/dhclient-options.c.patch ) ...
 
 Index: sbin/dhclient/options.c
 ===================================================================
 RCS file: /home/ncvs/src/sbin/dhclient/options.c,v
 retrieving revision 1.1.1.1
 diff -u -u -r1.1.1.1 options.c
 --- sbin/dhclient/options.c     7 Jun 2005 04:05:08 -0000       1.1.1.1
 +++ sbin/dhclient/options.c     14 Jul 2005 16:09:27 -0000
 @@ -486,7 +486,11 @@
                                  if (!isascii(data[k]) ||
                                      !isprint(data[k]))
                                          break;
 -                       if (k == len) {
 +            /* If we found no bogus characters, or the bogus
 +               character we found is a trailing NUL, it's
 +                  okay to print this option as text. */
 +
 +                       if (k == len || (k + 1 == len && data [k] == 
 0)) {
                                  fmtbuf[i] = 't';
                                  numhunk = -2;
                          } else { 
      
 
State-Changed-From-To: open->patched 
State-Changed-By: brooks 
State-Changed-When: Mon Jul 25 22:20:40 GMT 2005 
State-Changed-Why:  
I've commited a patch changing host-name from type 'X' to type 't' since 
it's easy and seems to be the lesser of several evils.  A different 
solution may be needed should servers requiring the sending of 
NUL-terminated host-names by clients be proven to exist. 


Responsible-Changed-From-To: freebsd-bugs->brooks 
Responsible-Changed-By: brooks 
Responsible-Changed-When: Mon Jul 25 22:20:40 GMT 2005 
Responsible-Changed-Why:  
I've commited a patch changing host-name from type 'X' to type 't' since 
it's easy and seems to be the lesser of several evils.  A different 
solution may be needed should servers requiring the sending of 
NUL-terminated host-names by clients be proven to exist. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=83468 
State-Changed-From-To: patched->closed 
State-Changed-By: brooks 
State-Changed-When: Sat Aug 20 19:17:30 GMT 2005 
State-Changed-Why:  
Fix MFCd. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=83468 
>Unformatted:
