Bug 647311

Summary: Can't set hostname
Product: [Fedora] Fedora Reporter: Clodoaldo Pinto Neto <clodoaldo.pinto.neto>
Component: NetworkManagerAssignee: Dan Williams <dcbw>
Status: CLOSED DUPLICATE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: 13CC: dcbw, jpopelka
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-02-25 23:24:55 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Clodoaldo Pinto Neto 2010-10-27 20:56:28 UTC
Although the hostname is set:

$ cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=d3.dkt

It is not set:

$ hostname
localhost.localdomain

$ cat /etc/hosts
127.0.0.1	localhost.localdomain	localhost
::1		localhost.localdomain	localhost6	localhost6.localdomain6	localhost
10.1.1.111	d3.dkt	d3

Comment 1 Jiri Popelka 2010-10-28 20:06:42 UTC
Do you use NetworkManager or network service ?

Comment 2 Clodoaldo Pinto Neto 2010-10-28 21:04:36 UTC
Not sure this answers it:

$ chkconfig --list | grep etwork
NetworkManager 	0:off	1:off	2:on	3:on	4:on	5:on	6:off
network        	0:off	1:off	2:off	3:off	4:off	5:off	6:off

Didn't touch these.

Comment 3 Jiri Popelka 2010-10-31 10:58:53 UTC
For me setting HOSTNAME in /etc/sysconfig/network works with NetworkManager.

Comment 4 Clodoaldo Pinto Neto 2011-02-17 15:58:44 UTC
Another machine showed the same symptoms and I posted a thread at a forum:

http://forums.fedoraforum.org/showthread.php?t=258973

The proposed solution worked in both that case and also in this one.

Comment 5 Clodoaldo Pinto Neto 2011-02-17 16:00:25 UTC
The SELinux message in that other machine:

SELinux is preventing /usr/sbin/NetworkManager from unlink access on the file /etc/hosts.

Additional Information:
Source Context                system_u:system_r:NetworkManager_t:s0
Target Context                unconfined_u:object_r:etc_t:s0
Target Objects                /etc/hosts [ file ]
Source                        NetworkManager
Source Path                   /usr/sbin/NetworkManager
Port                          <Unknown>
Host                          localhost.localdomain
Source RPM Packages           NetworkManager-0.8.1-10.git20100831.fc13
Target RPM Packages           setup-2.8.20-1.fc13
Policy RPM                    selinux-policy-3.7.19-80.fc13
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     cl.dkt
Platform                      Linux cl.dkt 2.6.34.7-66.fc13.x86_64 #1 SMP Wed
                              Dec 15 07:04:30 UTC 2010 x86_64 x86_64
Alert Count                   24
First Seen                    Mon 14 Feb 2011 07:01:43 PM BRST
Last Seen                     Tue 15 Feb 2011 12:03:32 PM BRST
Local ID                      6d5273e2-0cb1-439a-b6c4-131a768295f4

Raw Audit Messages
type=AVC msg=audit(1297778612.157:28615): avc:  denied  { unlink } for  pid=1603 comm="NetworkManager" name="hosts" dev=dm-1 ino=1968520 scontext=system_u:system_r:NetworkManager_t:s0 tcontext=unconfined_u:object_r:etc_t:s0 tclass=file


type=SYSCALL msg=audit(1297778612.157:28615): arch=x86_64 syscall=rename success=no exit=EACCES a0=1d85e00 a1=48b7b9 a2=1d5a180 a3=1 items=0 ppid=1 pid=1603 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm=NetworkManager exe=/usr/sbin/NetworkManager subj=system_u:system_r:NetworkManager_t:s0 key=(null)

Hash: NetworkManager,NetworkManager_t,etc_t,file,unlink

audit2allow

#============= NetworkManager_t ==============
allow NetworkManager_t etc_t:file unlink;

audit2allow -R

#============= NetworkManager_t ==============
allow NetworkManager_t etc_t:file unlink;

Comment 6 Dan Williams 2011-02-25 23:24:55 UTC
NM no longer touches /etc/hosts.

*** This bug has been marked as a duplicate of bug 648725 ***