Bug 871521

Summary: Verify hostname configuration for /etc/sysconfig/network change
Product: [Fedora] Fedora Reporter: Daniel Drake <dsd>
Component: dhcpAssignee: Jiri Popelka <jpopelka>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 18CC: jpopelka, Marcin.Dulak, thozza
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-10-09 09:17:26 EDT Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Description Daniel Drake 2012-10-30 11:29:01 EDT
Fedora 18 has changes w.r.t. how the hostname is handled:
http://lists.fedoraproject.org/pipermail/test/2012-October/111230.html

It looks like /usr/sbin/dhclient-script is reading $HOSTNAME from /etc/sysconfig/network and then passing it to /etc/sysconfig/network-scripts/ifup-post so that it is set as the hostname.

However, this may only affect corner cases, I haven't studied the exact behaviour. At least in a trivial setup I couldn't reproduce anything bad: With the hostname already set in /etc/hostname and another one set in /etc/sysconfig/network, I connect to a DHCP network via NetworkManager; the hostname stored in /etc/sysconfig/network is not applied (good).
Comment 1 Jiri Popelka 2012-10-31 06:05:58 EDT
(In reply to comment #0)
> It looks like /usr/sbin/dhclient-script is reading $HOSTNAME from
> /etc/sysconfig/network and then passing it to
> /etc/sysconfig/network-scripts/ifup-post so that it is set as the hostname.

Daniel, I haven't been able to find the part you are talking about.
Can you direct me to it ?
Comment 2 Daniel Drake 2012-10-31 10:19:17 EDT
http://lists.freedesktop.org/archives/systemd-devel/2012-October/007241.html

At a glance: dhclient-script runs ". /etc/sysconfig/network" then executes ifup-posts which inherits the HOSTNAME variable from the environment (presumably on purpose).
Comment 3 Jiri Popelka 2012-10-31 11:16:54 EDT
(In reply to comment #2)
> then executes ifup-posts

This specifically I can't find.
Maybe I'm getting blind so can you tell me which line/part of dhclient-script executes ifup-post ? thanks
Comment 4 marcindulak 2013-01-21 10:45:23 EST
There may be a problem with handling of /etc/hostname, namely the system does not
seem to set a new hostname from dhcp, but keeps using the one originally (during installation) written into /etc/hostname.
My /etc/hostname contains XXX.YYY.ZZZ and has the same creation time as /root/anaconda-ks.cfg.
The /etc/sysconfig/network contains just NETWORKING=yes
The /etc/hostname does not get modified despite changed dhcp configuration of the host.

There was a lot of confusion about that in earlier Fedoras:
https://bugzilla.redhat.com/show_bug.cgi?id=719100
https://bugzilla.redhat.com/show_bug.cgi?id=875085
The way of "getting the hostname from dhcp" in Fedora 18 needs to be documented.
Comment 5 marcindulak 2013-01-24 04:51:20 EST
I see that simply removing /etc/hostname file results in the name set according to the dhcp.
Comment 6 Jiri Popelka 2013-01-24 05:06:24 EST
(In reply to comment #4)
> system does not
> seem to set a new hostname from dhcp, but keeps using the one originally
> (during installation) written into /etc/hostname.

(In reply to comment #5)
> I see that simply removing /etc/hostname file results in the name set
> according to the dhcp.

That corresponds with bug #719100, comment #1.
Comment 7 Jiri Popelka 2013-10-09 09:17:26 EDT
(In reply to Daniel Drake from comment #0)
> I connect to a DHCP network via NetworkManager

In that case the dhclient-script is not used at all, NM has it's own "dhclient-script". This bug seems like duplicate of bug #719100 / bug #875085.
I'm closing it as those NM bugs have already been fixed. If anybody wants to reopen it, feel free to do that and please reassign it to NM because NM handles the "reading hostname from configuration files and passing it to dhclient" part.