From nobody@FreeBSD.ORG Mon Oct 25 10:34:55 1999 Return-Path: Received: by hub.freebsd.org (Postfix, from userid 32767) id F0C4B15194; Mon, 25 Oct 1999 10:34:54 -0700 (PDT) Message-Id: <19991025173454.F0C4B15194@hub.freebsd.org> Date: Mon, 25 Oct 1999 10:34:54 -0700 (PDT) From: simon.hewison@demon.net Sender: nobody@FreeBSD.ORG To: freebsd-gnats-submit@freebsd.org Subject: dhclient incorrectly reads and sets hostname as a hex string X-Send-Pr-Version: www-1.0 >Number: 14522 >Category: conf >Synopsis: dhclient incorrectly reads and sets hostname as a hex string >Confidential: no >Severity: non-critical >Priority: low >Responsible: obrien >State: closed >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Oct 25 10:40:00 PDT 1999 >Closed-Date: Fri Jul 14 10:17:03 PDT 2000 >Last-Modified: Fri Jul 14 10:19:51 PDT 2000 >Originator: Simon Hewison >Release: 3.3-RELEASE >Organization: Demon Internet >Environment: FreeBSD 67:77:2d:69:6e:64:65:78:2d:32:0 3.3-RELEASE FreeBSD 3.3-RELEASE #0: Thu Sep 16 23:40:35 GMT 1999 jkh@highwing.cdrom.com:/usr/src/sys/compile/GENERIC i386 >Description: When using the standard dhcp client configuration, and when the DHCP server sets the hostname, dhclient sets the hostname to a colon separated hexadecimal representation of the string which is the hostname finished off with the null termination byte. >How-To-Repeat: Get a Microsoft DHCP server to assign a hostname to a reserved lease. >Fix: don't assign a hostname by dhcp, set it in /etc/rc.conf :-( >Release-Note: >Audit-Trail: From: Matthew Seaman To: simon.hewison@demon.net Cc: freebsd-gnats-submit@FreeBSD.ORG, freebsd-bugs@FreeBSD.ORG Subject: Re: conf/14522: dhclient incorrectly reads and sets hostname as a hex string Date: Tue, 26 Oct 1999 09:17:40 +0000 simon.hewison@demon.net wrote: > > >Number: 14522 > >Category: conf > >Synopsis: dhclient incorrectly reads and sets hostname as a hex string > >Confidential: no > >Severity: non-critical > >Priority: low > >Responsible: freebsd-bugs > >State: open > >Quarter: > >Keywords: > >Date-Required: > >Class: sw-bug > >Submitter-Id: current-users > >Arrival-Date: Mon Oct 25 10:40:00 PDT 1999 > >Closed-Date: > >Last-Modified: > >Originator: Simon Hewison > >Release: 3.3-RELEASE > >Organization: > Demon Internet > >Environment: > FreeBSD 67:77:2d:69:6e:64:65:78:2d:32:0 3.3-RELEASE FreeBSD 3.3-RELEASE #0: Thu Sep 16 23:40:35 GMT 1999 jkh@highwing.cdrom.com:/usr/src/sys/compile/GENERIC i386 > >Description: > When using the standard dhcp client configuration, and when the DHCP server sets the hostname, dhclient sets the hostname to a colon separated hexadecimal representation of the string which is the hostname finished off with the null termination byte. > >How-To-Repeat: > Get a Microsoft DHCP server to assign a hostname to a reserved lease. > > >Fix: > don't assign a hostname by dhcp, set it in /etc/rc.conf :-( > > >Release-Note: > >Audit-Trail: > >Unformatted: > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-bugs" in the body of the message For what it's worth, here's a /etc/dhclient-enter-hooks script I kludged together to get round this problem. Not pretty, not very well tested and just one of those temporary fixes that seems to have settled in for the duration. #!/bin/sh # Local customizations for /sbin/dhclient-script Here we just setup # the hostname. This is imported into /sbin/dhclient-script via # `. /etc/dhclient-enter-hooks' # Check on the various DHCP variables we would like to see. These are # all independant of the particular interface we're managing, but as # we only have one interface per machine, here will do as well as # anywhere. if [ x$new_host_name != x ]; then # isc-dhcpd 2.0b1p26 supplies/expects the hostname as an arbitrary # hex encoded binary string `xx:xx:xx' where x are hex digits.. # isc-dhcpd 2.0b1pl4 (which we're using as the server) supplies # the hostname as an ascii string. Why the change? This kludge # converts to ascii if necessary. if echo $new_host_name | \ grep -Ex '([[:xdigit:]]{2}:)+[[:xdigit:]]{2}' >/dev/null 2>&1; then new_host_name=`perl -e 'map { print chr hex $_; } \ split /:/, $ARGV[0];' $new_host_name` fi $LOGGER "New Host Name: $new_host_name" fi if [ x$old_host_name != x ]; then # Need to decode old_host_name in the same way (?) if echo $old_host_name | \ grep -Ex '([[:xdigit:]]{2}:)+[[:xdigit:]]{2}' >/dev/null 2>&1; then old_host_name=`perl -e 'map { print chr hex $_; } \ split /:/, $ARGV[0];' $old_host_name` fi fi # Define functions to substitute DHCP data into local config files # or to set/change various system attributes. Nb. this relies on # overwriting the static values set from rc.* files on boot-up. set_host_name() { if [ x$new_host_name != x ] \ && [ x$new_host_name != x$old_host_name ] then hostname $new_host_name fi $LOGGER set hostname to $new_host_name } # Test $reason to discover why we were called and amend our # configuration appropriately. exit_status=0 case $reason in MEDIUM) # Change of interface media type ;; PREINIT) # Config. interface prior to contacting DHCP server ;; ARPSEND) # Check offered IP not already in use via arp (how?) ;; ARPCHECK) # Did we get a response to ARPSEND? ;; BOUND) # Received initial config from DHCP server set_host_name ; ;; RENEW) # Received change to configuration from DHCP server set_host_name ; ;; REBIND) # Bound to a different DHCP server set_host_name ; ;; REBOOT) # Renewed previous lease after reboot set_host_name ; ;; EXPIRE) # Can't get a new/replacement lease ;; FAIL) # Can't contact DHCP server or can't get valid lease ;; TIMEOUT) # Can't contact DHCP server, but have saved lease to reuse set_host_name ; ;; *) $LOGGER "unknown reason \"$reason\" for calling dhclient-script" exit_status=1 ;; esac # # That's All Folks! # Matthew -- Certe, Toto, sentio nos in Kansate non iam adesse. Dr. Matthew Seaman, Inpharmatica Ltd, 60 Charlotte St, London, W1P 2AX Tel: +44 171 631 4644 x229 Fax: +44 171 631 4844 Responsible-Changed-From-To: freebsd-bugs->obrien Responsible-Changed-By: nbm Responsible-Changed-When: Fri Jul 14 05:55:49 PDT 2000 Responsible-Changed-Why: Mr. O'Brien was recently accumulating dhclient PRs. http://www.freebsd.org/cgi/query-pr.cgi?pr=14522 State-Changed-From-To: open->closed State-Changed-By: obrien State-Changed-When: Fri Jul 14 10:17:03 PDT 2000 State-Changed-Why: This bug has been fixed in ISC's DHCP version 2.0. FreeBSD-3.4 should this version. If not, FreeBSD-3.5 definately does. If the user does not want to upgrade to 3.{4,5}, /sbin/dhclient could be extrated from the release distribution and used on the 3.3 machine. http://www.freebsd.org/cgi/query-pr.cgi?pr=14522 >Unformatted: