Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 98132 - new feature to dhcp rc scripts allows omitting hostname (patch)
Summary: new feature to dhcp rc scripts allows omitting hostname (patch)
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] baselayout (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Roy Marples (RETIRED)
URL:
Whiteboard:
Keywords: InVCS
Depends on:
Blocks:
 
Reported: 2005-07-06 09:06 UTC by nutbar
Modified: 2005-07-14 03:05 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description nutbar 2005-07-06 09:06:36 UTC
Currently the startup scripts for dhcp (dhcpcd, pump, udhcpc) force the
inclusion of the hostname when they are brought up.  AFAIK, the hostname is not
a *required* portion of establishing a dhcp connection to a dhcp server (I never
specified a hostname when using dhcpcd before and it always works).

For those who don't wish to specify a hostname to the dhcp client they use, I've
made a simple patch which allows you to include "nohost" as a dhcp option to the
interface.  For example, here is my /etc/conf.d/net file (for my dhcp'd nic):

config_eth1=( "dhcp" )
dhcpcd_eth1="-t 10"
dhcp_eth1="nodns nontp nonis nohost"

The "nohost" option basically just causes the corresponding rc script to skip
setting up the hostname option along with the other options.

The patch I'm submitting has only been tested with dhcpcd, however the patch for
the other dhcp clients is relatively identical - my only concern would be if
they *require* the hostname to be specified... that I am not sure of and would
need to be tested by someone who uses pump and udhcpc.

Reproducible: Always
Steps to Reproduce:




Here's a link to the patch in case formatting of this window breaks the patch:

http://www.hoktar.com/downloads/other/dhcp-nohost.patch

... and here's the patch itself:

--- /lib/rcscripts/net.modules.d/dhcpcd 2005-06-26 03:58:31.000000000 -0400
+++ /lib/rcscripts/net.modules.d/dhcpcd 2005-07-06 10:31:32.000000000 -0400
@@ -107,7 +107,7 @@
        [[ ${dhcp} == *' nonis '* ]] && opts="${opts} -Y"

        # We transmit the hostname by default
-       if [[ ${opts} != *'-h '* ]]; then
+       if [[ ${opts} != *'-h '* && ${dhcp} != *' nohost '* ]]; then
                hostname=$( hostname )
                [[ -n ${hostname} && ${hostname} != "(none)" && ${hostname} !=
localhost ]] \
                        && opts="-h ${hostname} ${opts}"
--- /lib/rcscripts/net.modules.d/pump   2005-06-26 03:58:31.000000000 -0400
+++ /lib/rcscripts/net.modules.d/pump   2005-07-06 10:36:55.000000000 -0400
@@ -104,7 +104,7 @@
        [[ ${dhcp} == *' nodns '* ]] && opts="${opts} --no-dns"

        # We transmit the hostname by default
-       if [[ ${opts} != *'-h '* && ${opts} != '*--hostname='* ]]; then
+       if [[ ${opts} != *'-h '* && ${opts} != '*--hostname='* && ${dhcp} != *'
nohost '* ]]; then
                hostname=$( hostname )
                [[ -n ${hostname} && ${hostname} != "(none)" && ${hostname} !=
localhost ]] \
                        && opts="--hostname=${hostname} ${opts}"
--- /lib/rcscripts/net.modules.d/udhcpc 2005-06-26 03:58:31.000000000 -0400
+++ /lib/rcscripts/net.modules.d/udhcpc 2005-07-06 10:35:28.000000000 -0400
@@ -113,8 +113,9 @@
        local ifvar=$( interface_variable ${iface} )
        local script=$( udhcpc_get_script ) opts hostname
        eval opts=\"\$\{udhcpc_${ifvar}\}\"
+       eval dhcp=\" \$\{dhcp_${ifvar}\} \"

-       if [[ ${opts} != *'--hostname='* ]]; then
+       if [[ ${opts} != *'--hostname='* && ${dhcp} != *' nohost '* ]]; then
                hostname=$( hostname )
                [[ -n ${hostname} && ${hostname} != "(none)" ]] &&
hostname="--hostname=${hostname}"
        fi
Comment 1 Roy Marples (RETIRED) gentoo-dev 2005-07-07 03:37:06 UTC
Thanks for the patch! But for future reference please attach patches to bugs
instead of posting patches in comments ;)

I've changed the "nohost" option to "nosendhost" though.

Will be in baselayout-1.11.13
Comment 2 nutbar 2005-07-07 07:47:14 UTC
Sorry about the pasting of the patch - I was looking for a file attach option on
the initial submit page of a bug but didn't see one (it was only after that I
noticed the attachment thing just above this window).  That's why I gave a URL
just in case - if the patch were any bigger I wouldn't have pasted it :)

Thanks for accepting it!

Eli.
Comment 3 Roy Marples (RETIRED) gentoo-dev 2005-07-14 03:05:24 UTC
baselayout-1.11.13 is out