Bug 1368929

Summary: [SPEC] systemd adds myhostname option from post script of package
Product: Red Hat Enterprise Linux 7 Reporter: Suresh <sgaikwad>
Component: systemdAssignee: systemd-maint
Status: CLOSED ERRATA QA Contact: Frantisek Sumsal <fsumsal>
Severity: high Docs Contact:
Priority: medium    
Version: 7.2CC: bblaskov, carsten.grohmann, dbodnarc, fsumsal, jruemker, jsynacek, oss-os-contact, rskvaril, sreber, s.renatscher, systemd-maint, vchepkov, wayne.johnson, ysoni
Target Milestone: rcKeywords: EasyFix, Patch
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: systemd-219-36.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-01 09:09:52 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:
Bug Depends On:    
Bug Blocks: 1298243, 1380361, 1383699, 1393867    
Attachments:
Description Flags
patch none

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 || :
fi

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:
Everytime

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]
patch

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)
iptables-1.4.21-17.el7.x86_64

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.

https://access.redhat.com/errata/RHBA-2017:2297