Bug 1368929 - [SPEC] systemd adds myhostname option from post script of package
Summary: [SPEC] systemd adds myhostname option from post script of package
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: systemd
Version: 7.2
Hardware: All
OS: Linux
Target Milestone: rc
: ---
Assignee: systemd-maint
QA Contact: Frantisek Sumsal
: 1383865 (view as bug list)
Depends On:
Blocks: 1298243 1380361 1393867 74systemd
TreeView+ depends on / blocked
Reported: 2016-08-22 07:10 UTC by Suresh
Modified: 2020-09-10 09:44 UTC (History)
14 users (show)

Fixed In Version: systemd-219-36.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Last Closed: 2017-08-01 09:09:52 UTC
Target Upstream Version:

Attachments (Terms of Use)
patch (403 bytes, patch)
2017-03-09 11:36 UTC, Jan Synacek
no flags Details | Diff

System ID Private Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 2766251 0 None None None 2016-11-14 16:19:40 UTC
Red Hat Product Errata RHBA-2017:2297 0 normal SHIPPED_LIVE systemd bug fix and enhancement update 2017-08-01 12:40:16 UTC

Description Suresh 2016-08-22 07:10:08 UTC
Description of problem:

The constant adding of it during updates is not desirable.
If it must be done as a rpm post script, then it should be aware and only
perform it once.

# sed-fu to add myhostname to the hosts line of /etc/nsswitch.conf
if [ -f /etc/nsswitch.conf ] ; then
sed -i.bak -e '
/^hosts:/ !b
/\<myhostname\>/ b
s/[[:blank:]]*$/ myhostname/
' /etc/nsswitch.conf >/dev/null 2>&1 || :

With this option, getent resolves ipv6 addresses even if mapping is present in /etc/hosts file.

[root@suresh ~]# grep hosts /etc/nsswitch.conf
#hosts:     db files nisplus nis dns
hosts:      files dns myhostname

[root@suresh ~]# getent  hosts `uname -n`               
fe80::ae16:2dff:xxxx:xxxx HOSTNAME
fe80::ae16:2dff:xxxx:xxxx HOSTNAME

Even if we remove this option from nsswitch.conf, update of systemd package inserts it again.

This can be workaround by adding [NOTFOUND=return] after dns entry. However, the constant adding of it during updates is not desirable. 

How reproducible:

Steps to Reproduce:
1. Remove myhostname from /etc/nsswitch.conf file.
2. Update systemd package and it will append myhostname in hosts line again.

Comment 3 John Ruemker 2016-12-12 20:56:15 UTC
*** Bug 1383865 has been marked as a duplicate of this bug. ***

Comment 12 Jan Synacek 2017-03-09 11:36:52 UTC
Created attachment 1261514 [details]

Comment 14 Yogita 2017-04-24 10:42:00 UTC
This issue seems to persist even when IPV6 is disabled on RHEL7.3 machine.

Steps To reproduce -
Red Hat Enterprise Linux Server release 7.3 (Maipo)

How reproducible:
1) Disable IPV6 on RHEL7.3 machine -
# vim /etc/sysctl.d/ipv6.conf
net.ipv6.conf.all.disable_ipv6 = 1

#sysctl -p /etc/sysctl.d/ipv6.conf
#dracut -f

2) Execute below command -
[root@client ~]# getent hosts `uname -n`
::1             client.example.com localhost

Any reasons why? Customer need to ascertain why is it so despite of IPV6 disabled on RHEL7.3
Although removing myhostname from nsswitch.conf like described helps.

Comment 15 Jan Synacek 2017-04-24 11:16:31 UTC
(In reply to Yogita from comment #14)
> This issue seems to persist even when IPV6 is disabled on RHEL7.3 machine.

This issue has nothing to do with system settings. It's a problem in the spec file and package update.

Comment 17 errata-xmlrpc 2017-08-01 09:09:52 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.


Note You need to log in before you can comment on or make changes to this bug.