Opened 18 years ago

Closed 18 years ago

#1874 closed defect (invalid)

Can't set hostname to empty string using /etc/sysconfig/network

Reported by: joni78 Owned by: lfs-book@…
Priority: normal Milestone:
Component: Book Version: 6.2
Severity: normal Keywords:
Cc:

Description

Hi,

I've been trying all day to get my LFS dhcp clients to get the hostname from the dhcpd server. As it turns out it doesn't set this because the script checks if the hostname string is empty, which it is not because LFS sets this to "(none)", even if I set HOSTNAME="" in /etc/sysconfig/network.

At this moment I didn't find which script sets this to (none). I've looked at /etc/rc.d/init.d/localnet, which does set the hostname, but it doesn't seem to be it.

Please advice and maybe it would be nice to change the script?

Thanks! Jonathan

Change History (5)

comment:1 by joni78, 18 years ago

Ok it's not any script. It's the hostname binary in /bin/hostname:

# export $HOSTNAME="" # hostname $HOSTNAME (none)

Any thought how to solve this?

Thanks!

comment:2 by alexander@…, 18 years ago

The kernel itself sets the string to "(none)" by default (i.e., no script is involved, you can check that by booting with "init=/bin/bash" appended to the kernel command line), so it looks like a bug in dhcp client. If you insist that the bug is in LFS,

  • Paste the piece of dhcp client code that checks that the hostname is empty
  • Retitle the bug to "Can't set hostname to empty string using /etc/sysconfig/network".

comment:3 by joni78, 18 years ago

Summary: /sbin/dhclient-script doesn't set hostname because LFS sets hostname to "(none)"Can't set hostname to empty string using /etc/sysconfig/network

Hi Alexander,

Ok if the kernel itself is setting the hostname to '(none)' then IMHO the /sbin/dhclient-script should be able to handle that. This is the section of /sbin/dhclient-script where setting the hostname is being handled (/sbin/dhclient-script is invoked by dhclient) from line 109 onwards:

  current_hostname=`hostname`
  if [ x$current_hostname = x ] || \
     [ x$current_hostname = x$old_host_name ]; then
    if [ x$current_hostname = x ] || \
       [ x$new_host_name != x$old_host_name ]; then
      hostname $new_host_name
    fi
  fi

It seems to me that it should be changed to something like:

  current_hostname=`hostname`
  if [ x$current_hostname = x ] || [ $current_hostname = '(none)' ] || \
     [ x$current_hostname = x$old_host_name ]; then
    if [ x$current_hostname = x ] || [ $current_hostname = '(none)' ] || \
       [ x$new_host_name != x$old_host_name ]; then
      hostname $new_host_name
    fi
  fi

Bye, Jonathan

comment:4 by Jeremy Huntwork, 18 years ago

The problem you're encountering seems to be specific to your need, and not necessarily the fault with the LFS book or bootscripts. I would suggest that you either create a hint that shows how to setup a LFS box so that its hostname is supplied by a DHCP server, or create a patch for dhclient based on your above findings and send it to the BLFS team for optional inclusion.

Anyone mind if I close this ticket?

comment:5 by Jeremy Huntwork, 18 years ago

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.