Date: Mon, 15 May 2000 22:33:46 -0700 (PDT) From: brooks@one-eyed-alien.net To: FreeBSD-gnats-submit@freebsd.org Subject: conf/18583: [PATCH] DHCP should be able to override hostname. Message-ID: <200005160533.WAA00568@minya.sea.one-eyed-alien.net>
next in thread | raw e-mail | index | archive | help
>Number: 18583 >Category: conf >Synopsis: [PATCH] DHCP should be able to override hostname. >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Mon May 15 22:40:00 PDT 2000 >Closed-Date: >Last-Modified: >Originator: Brooks Davis >Release: FreeBSD 5.0-CURRENT i386 >Organization: The Aerospace Corporation >Environment: FreeBSD minya 5.0-CURRENT FreeBSD 5.0-CURRENT #21: Tue May 9 18:49:06 PDT 2000 root@minya:/usr/src/sys/compile/MINYA i386 >Description: 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. It's a new addition to /sbin which it bound to be touchy. OTOH, this is exactly the direction we need to move in if we ever want to make rc.conf not be a shell script. >How-To-Repeat: Try using DHCP for configuration at multiple sites and using your laptop disconnected as well. >Fix: The following patch should work, but I've never made a patch that added files before, so I'm not sure. I've seen complaints about this since DHCP was added to the base, so I'd like to get it comitted. If nothing else, it's a lot of diffs (by file count) to keep in my own tree. --- /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} >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200005160533.WAA00568>