Subject: bin/7851: some netboot conditions set hostname(1) but not $hostname
To: None <gnats-bugs@gnats.netbsd.org>
From: None <windsor@warthog.com>
List: netbsd-bugs
Date: 06/24/1999 12:50:57
>Number:         7851
>Category:       bin
>Synopsis:       some netboot conditions set hostname(1) but not $hostname
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jun 24 12:50:01 1999
>Last-Modified:
>Originator:     Rob Windsor
>Organization:
Nose Pickers Anonymous
>Release:        19990621
>Environment:
System: NetBSD nis-build 1.4D NetBSD 1.4D (NETBOOT) #1: Fri Jun 18 16:28:41 PDT 1999 windsor@nis-build:/usr/src/sys/arch/sparc/compile/NETBOOT sparc

>Description:
	Under some netboot conditions (minimal bootparams, not using dhcp),
	hostname(1) will get set, but $hostname will not, so some parts
	of /etc/netstart and /etc/rc et.al. will not operate properly.
	Also, when running with a common /, you still have to differentiate
	certain items by $hostname (such as mounting swapfile or ssh key
	file location).  Under those conditions, it is critical to have
	$hostname functional.

	There is a condition in /etc/netstart to set hostname(1) to
	$hostname.  The opposite also needs to happen for this specific
	situation.

	This bug occurs in 1.3.x, 1.4, and -current.  The following patch
	should be applied to the 1.4 branch as well as the main trunk.

>How-To-Repeat:
	Follow the directions under NetBSD/sparc diskless(8) and Ignatios'
	notes and watch $hostname not get set.
>Fix:

--- /etc/netstart~	Wed May 26 04:15:10 1999
+++ /etc/netstart	Thu Jun 17 14:24:12 1999
@@ -21,6 +21,9 @@
 if [ -n "$hostname" ]; then
	echo "hostname: $hostname"
	hostname $hostname
+elif [ -n "`hostname`" ]; then
+	hostname=`hostname`
+	echo "hostname: $hostname"
 fi
 
 # Check $domainname first, then /etc/defaultdomain, for NIS/YP domain name

>Audit-Trail:
>Unformatted: