Bug 1501193

Summary: hostnamectl set-hostname not working - timeout
Product: Red Hat Enterprise Linux 7 Reporter: Marian Csontos <mcsontos>
Component: redhat-releaseAssignee: Lubos Kocman <lkocman>
Status: CLOSED ERRATA QA Contact: Release Test Team <release-test-team-automation>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.5CC: arydekul, chaitu2k6, dtodorov, jlinton, jstodola, pkotvan, ssbarnea, systemd-maint-list
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: redhat-release-7.5-0.8.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-04-10 10:17:23 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Marian Csontos 2017-10-12 08:28:54 UTC
Description of problem:

[root@localhost ~]# hostnamectl set-hostname t-rhel75n1012
Could not set property: Message recipient disconnected from message bus without replying


Version-Release number of selected component (if applicable):
systemd-219-45.el7.x86_64
dbus-1.10.24-3.el7.x86_64

How reproducible:
on 1 machine: 100%

Steps to Reproduce:
I installed a latest 7.5 nightly, in %post I used workaround for Bug 1500336 (see Bug 1500336#c7)

Additional info:
[root@localhost ~]# journalctl -perr
-- Logs begin at Thu 2017-10-12 10:04:47 CEST, end at Thu 2017-10-12 10:24:47 CEST. --
Oct 12 10:04:47 localhost.localdomain kernel: ACPI PCC probe failed.
Oct 12 08:04:56 localhost.localdomain systemd-hostnamed[649]: Failed to read hostname and machine information: Permission denied
Oct 12 08:04:56 localhost.localdomain systemd[1]: Failed to start Hostname Service.
Oct 12 10:05:12 localhost.localdomain systemd-hostnamed[3982]: Failed to read hostname and machine information: Permission denied
Oct 12 10:15:02 localhost.localdomain systemd-hostnamed[11127]: Failed to read hostname and machine information: Permission denied
Oct 12 10:16:09 localhost.localdomain systemd-hostnamed[11161]: Failed to read hostname and machine information: Permission denied
Oct 12 10:18:48 localhost.localdomain systemd-hostnamed[11179]: Failed to read hostname and machine information: Permission denied
Oct 12 10:24:47 localhost.localdomain systemd-hostnamed[11197]: Failed to read hostname and machine information: Permission denied

[root@localhost ~]# systemctl status systemd-hostnamed
● systemd-hostnamed.service - Hostname Service
   Loaded: loaded (/usr/lib/systemd/system/systemd-hostnamed.service; static; vendor preset: disabled)
   Active: failed (Result: exit-code) since Thu 2017-10-12 10:24:47 CEST; 1min 15s ago
     Docs: man:systemd-hostnamed.service(8)
           man:hostname(5)
           man:machine-info(5)
           http://www.freedesktop.org/wiki/Software/systemd/hostnamed
  Process: 11197 ExecStart=/usr/lib/systemd/systemd-hostnamed (code=exited, status=1/FAILURE)
 Main PID: 11197 (code=exited, status=1/FAILURE)

Oct 12 10:24:47 localhost.localdomain systemd[1]: Starting Hostname Service...
Oct 12 10:24:47 localhost.localdomain systemd[1]: Started Hostname Service.
Oct 12 10:24:47 localhost.localdomain systemd[1]: systemd-hostnamed.service: main process exited, code=exited, status=1/FAILURE
Oct 12 10:24:47 localhost.localdomain systemd[1]: Unit systemd-hostnamed.service entered failed state.
Oct 12 10:24:47 localhost.localdomain systemd[1]: systemd-hostnamed.service failed.

Comment 2 Lukáš Nykrýn 2017-10-12 09:01:05 UTC
Missing executable bits on directory
(and the directory should not be in lib64)

drw-r--r--. 2 root root 118 12. říj 04.43 /usr/lib64/os.release.d

Comment 3 Marian Csontos 2017-10-12 09:09:07 UTC
Folks, are you running that great tool from rel-eng called rpmdiff on your packages?

Comment 5 Lubos Kocman 2017-10-13 06:06:23 UTC
Default dir permissions for redhat-release are now set to 0755

Lubos

Comment 7 Michal Sekletar 2017-10-28 17:09:43 UTC
*** Bug 1507064 has been marked as a duplicate of this bug. ***

Comment 8 Peter Kotvan 2017-12-11 08:59:00 UTC
I was able to verify this bug on RHEL-7.5-20171130.0 with redhat-release-server-7.5-3.el7.

Comment 11 errata-xmlrpc 2018-04-10 10:17:23 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2018:0700

Comment 12 smanne 2018-09-19 18:44:16 UTC
Folks,

these answers are not helpful and there are multiple other bugs opened for the same issue.

Below is the fix that worked for me.

from the below output of systemctl status command, I noticed that /tmp was not mounted with proper acls.

sudo-sh[root@myhost]# hostnamectl set-hostname --static $dnsname
Could not set property: Connection timed out
sudo-sh[root@myhost]# hostnamectl set-hostname poc-rhel-cassandra-b1
Could not set property: Failed to activate service 'org.freedesktop.hostname1': timed out



sudo-sh[root@myhost]# systemctl status systemd-hostnamed
● systemd-hostnamed.service - Hostname Service
   Loaded: loaded (/usr/lib/systemd/system/systemd-hostnamed.service; static; vendor preset: disabled)
   Active: inactive (dead)
     Docs: man:systemd-hostnamed.service(8)
           man:hostname(5)
           man:machine-info(5)
           http://www.freedesktop.org/wiki/Software/systemd/hostnamed

Sep 19 13:52:53 myhost systemd[1]: Dependency failed for Hostname Service.
Sep 19 13:52:53 myhost systemd[1]: Job systemd-hostnamed.service/start failed with result 'dependency'.
Sep 19 13:54:02 myhost systemd[1]: Dependency failed for Hostname Service.
Sep 19 13:54:02 myhost systemd[1]: Job systemd-hostnamed.service/start failed with result 'dependency'.
Sep 19 13:55:18 myhost systemd[1]: Dependency failed for Hostname Service.
Sep 19 13:55:18 myhost systemd[1]: Job systemd-hostnamed.service/start failed with result 'dependency'.

sudo-sh[root@myhost]# systemctl restart systemd-hostnamed
A dependency job for systemd-hostnamed.service failed. See 'journalctl -xe' for details.
sudo-sh[root@myhost]# journalctl -xe
-- Unit user-0.slice has finished shutting down.
Sep 19 13:56:01 myhost systemd[1]: Stopping User Slice of root.
-- Subject: Unit user-0.slice has begun shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit user-0.slice has begun shutting down.
Sep 19 13:56:03  sudo-sh[12198]: ec2-user : HOST=myhost : TTY=pts/0 ; PWD=/home/ec2-user ; USER=root ; SUDO-SH-COMMAND=systemctl
Sep 19 13:56:29  sudo-sh[12199]: ec2-user : HOST=myhost : TTY=pts/0 ; PWD=/home/ec2-user ; USER=root ; SUDO-SH-COMMAND=systemctl
Sep 19 13:56:29  polkitd[624]: Registered Authentication Agent for unix-process:12199:22680 (system bus name :1.39 [/usr/bin/pkttyagent --
Sep 19 13:56:29  systemd[1]: Mounting /var/tmp...
-- Subject: Unit var-tmp.mount has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit var-tmp.mount has begun starting up.
Sep 19 13:56:29  mount[12205]: mount:  /tmp is not a block device
Sep 19 13:56:29  systemd[1]: var-tmp.mount mount process exited, code=exited status=32
Sep 19 13:56:29  systemd[1]: Failed to mount /var/tmp.
-- Subject: Unit var-tmp.mount has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit var-tmp.mount has failed.
--
-- The result is failed.
Sep 19 13:56:29  systemd[1]: Dependency failed for Hostname Service.
-- Subject: Unit systemd-hostnamed.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit systemd-hostnamed.service has failed.
--
-- The result is dependency.
Sep 19 13:56:29  systemd[1]: Job systemd-hostnamed.service/start failed with result 'dependency'.
Sep 19 13:56:29  systemd[1]: Unit var-tmp.mount entered failed state.
Sep 19 13:56:29  polkitd[624]: Unregistered Authentication Agent for unix-process:12199:22680 (system bus name :1.39, object path /org/fre
Sep 19 13:56:36  sudo-sh[12207]: ec2-user : HOST=myhost : TTY=pts/0 ; PWD=/home/ec2-user ; USER=root ; SUDO-SH-COMMAND=journalctl



to resolve this issue, I edited /etc/fstab and changed the /tmp acls.

Before
#/tmp /var/tmp auto rw,nodev,nofail,nosuid,relatime 0 0

After
/tmp /var/tmp auto bind 0 0


make sure to make a copy of your original fstab file before editing, then restart the server.

Now hostname service started fine.

sudo-sh[root@myhost]# systemctl status systemd-hostnamed
● systemd-hostnamed.service - Hostname Service
   Loaded: loaded (/usr/lib/systemd/system/systemd-hostnamed.service; static; vendor preset: disabled)
   Active: inactive (dead)
     Docs: man:systemd-hostnamed.service(8)
           man:hostname(5)
           man:machine-info(5)
           http://www.freedesktop.org/wiki/Software/systemd/hostnamed

Sep 19 14:16:45  systemd[1]: Starting Hostname Service...
Sep 19 14:16:45  systemd[1]: Started Hostname Service.

Also hostnamectl set-hostname command worked as expected.

sudo-sh[root@myhost]# dnsname=`ifconfig eth0|grep netmask|awk '{print $2}'|while read addr; do host $addr|awk '{print $NF}'|sed 's/.$//'; done`
sudo-sh[root@myhost]# hostnamectl set-hostname --static $dnsname
sudo-sh[root@myhost]# hostnamectl status|grep Static
   Static hostname: poc-rhel-cassandra-b1

Comment 13 Sorin Sbarnea 2019-02-08 10:37:02 UTC
I faced this problem recently and my /etc/fstab didn't had any entry for /tmp, just the main xfs partition. I am almost sure that setting hostname worked before on the same host and I suspect some recent change may have introduced this issue.

I want to prevent reachign this case again and run some preparatory ansible task(s) before set-hostname is called but I am afraid that touching /etc/fstab may be too dangereus especially as user may have added some other custom /tmp config. 

Any ideas detect-and-fix scriptable approach?

Comment 14 Alexander Rydekull 2019-02-14 08:03:25 UTC
I hit what looks to be using the same origin pattern as described in this bug. It just comes down to a SElinux issue.

In my case it was:
[root@satellite2 ~]# hostnamectl set-hostname satellite2.dc2.example.com
Could not set property: Message recipient disconnected from message bus without replying
[root@satellite2 ~]# restorecon /etc/machine-info 
[root@satellite2 ~]# hostnamectl set-hostname satellite2.dc2.example.com
[root@satellite2 ~]# hostname
satellite2.dc2.example.com
[root@satellite2 ~]# uname -a
Linux satellite2.dc2.example.com 3.10.0-957.5.1.el7.x86_64 #1 SMP Wed Dec 19 10:46:58 EST 2018 x86_64 x86_64 x86_64 GNU/Linux
[root@satellite2 ~]# cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 7.6 (Maipo)
[root@satellite2 ~]# 

I dont really think its an issue in RHEL 7.6 as such, but this is a freshly installed VM from a kickstarted RHEL minimal with very little modifications (as stock as possible). But, it has had virt-sysprep run on it.