Date: Wed, 10 May 2000 13:07:59 -0700 From: Brooks Davis <brooks@one-eyed-alien.net> To: freebsd-hackers@freebsd.org Subject: Proposed fix for DHCP and hostname Message-ID: <20000510130759.A6475@orion.ac.hmc.edu>
next in thread | raw e-mail | index | archive | help
Hi,
There's a long standing issue where you can either have a hardwired
hostname and have it all the time or you can get your hostname from DHCP
and not have one unless you set it manualy while not networked. I have
hacked up a solution which I think avoids POLA violations. My only
concern with it is the new program to get variables out of
/etc/defaults/rc.conf and the like called rc_conf_var. In general the
idea of a program to do that is something we're going to need it we want
to move to a more machine editable config file format (dare I say, XML
based ;-). The following patch should work, but I've never made a patch
that added files before, so I'm not sure. Please provide feedback on
this solution. I've seen complaints about this since DHCP was added to
the base, so I'd like to get it comitted.
-- Brooks
--
Any statement of the form "X is the one, true Y" is FALSE.
--- /usr/src/etc/rc.network Tue May 9 15:00:17 2000
+++ /etc/rc.network Wed May 10 09:51:03 2000
@@ -16,8 +16,13 @@
# Set the host name if it is not already set
#
if [ -z "`hostname -s`" ]; then
- hostname ${hostname}
- echo -n ' hostname'
+ if [ -n "${hostname}" ]; then
+ hostname ${hostname}
+ echo -n ' hostname'
+ elif [ -n "${default_hostname}" ]; then
+ hostname ${default_hostname}
+ echo -n ' default_hostname'
+ fi
fi
# Set the domainname if we're using NIS
--- /usr/src/etc/defaults/rc.conf Tue May 9 15:00:17 2000
+++ /etc/defaults/rc.conf Tue May 9 21:22:16 2000
@@ -39,6 +39,7 @@
### Basic network options: ###
hostname="" # Set this!
+default_hostname="" # Set this if you get your hostname elseware.
nisdomainname="NO" # Set to NIS domain if using NIS (or NO).
dhcp_program="/sbin/dhclient" # Path to dhcp client program.
dhcp_flags="" # Additional flags to pass to dhcp client.
--- /usr/src/contrib/isc-dhcp/client/scripts/freebsd Sat Jan 15 14:46:40 2000
+++ /sbin/dhclient-script Tue May 9 21:44:59 2000
@@ -76,7 +76,7 @@
if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
[ x$reason = xREBIND ] || [ x$reason = xREBOOT ]; then
current_hostname=`/bin/hostname`
- if [ x$current_hostname = x ] || \
+ if [ x$current_hostname = x`rc_conf_var default_hostname` ] || \
[ x$current_hostname = x$old_host_name ]; then
if [ x$new_host_name != x$old_host_name ]; then
$LOGGER "New Hostname: $new_host_name"
--- /sbin/rc_conf_var.orig Wed May 10 11:19:16 2000
+++ /sbin/rc_conf_var Tue May 9 21:40:06 2000
@@ -0,0 +1,13 @@
+#!/bin/sh
+# $FreeBSD$
+
+# If there is a global system configuration file, suck it in.
+#
+if [ -r /etc/defaults/rc.conf ]; then
+ . /etc/defaults/rc.conf
+ source_rc_confs
+elif [ -r /etc/rc.conf ]; then
+ . /etc/rc.conf
+fi
+
+eval echo \$${1}
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000510130759.A6475>
