From owner-freebsd-bugs Tue Oct 26 2:17:52 1999 Delivered-To: freebsd-bugs@freebsd.org Received: from gallions-reach.inpharmatica.co.uk (gallions-reach.inpharmatica.co.uk [193.115.214.5]) by hub.freebsd.org (Postfix) with ESMTP id E883E15348; Tue, 26 Oct 1999 02:17:43 -0700 (PDT) (envelope-from m.seaman@inpharmatica.co.uk) Received: from kings-cross.inpharmatica.co.uk (euston.inpharmatica.co.uk [193.115.214.6]) by gallions-reach.inpharmatica.co.uk (8.8.8/8.8.8) with ESMTP id KAA08454; Tue, 26 Oct 1999 10:17:41 +0100 (BST) (envelope-from m.seaman@inpharmatica.co.uk) Received: from paddington.inpharmatica.co.uk (IDENT:root@paddington.inpharmatica.co.uk [192.168.122.1]) by kings-cross.inpharmatica.co.uk (8.9.3/8.9.3) with ESMTP id KAA09434; Tue, 26 Oct 1999 10:17:41 +0100 Received: from inpharmatica.co.uk (IDENT:matthew@localhost [127.0.0.1]) by paddington.inpharmatica.co.uk (8.9.3/8.9.3) with ESMTP id KAA25260; Tue, 26 Oct 1999 10:17:41 +0100 Message-ID: <381571B4.7C8E2B60@inpharmatica.co.uk> Date: Tue, 26 Oct 1999 09:17:40 +0000 From: Matthew Seaman X-Mailer: Mozilla 4.61 [en] (X11; I; Linux 2.2.4 i586) X-Accept-Language: en-GB, en MIME-Version: 1.0 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 References: <19991025173454.F0C4B15194@hub.freebsd.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org 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 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message