FS#52133 - [systemd] /etc/nsswitch.conf suggested by systemd throws "hostname: gethostbyname: Unknown host"

Attached to Project: Arch Linux
Opened by Serhat Cevikel (serhatcevikel) - Monday, 12 December 2016, 22:37 GMT
Last edited by Doug Newgard (Scimmia) - Tuesday, 13 December 2016, 17:29 GMT
Task Type Bug Report
Category Packages: Core
Status Closed
Assigned To No-one
Architecture All
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:

Latest update to systemd package on 2016-12-09 19:34 UTC changed the /etc/nsswitch.conf file as per the feature request 51709 (https://bugs.archlinux.org/task/51709) as follows (left previous, right latest):

passwd: files | passwd: compat mymachines systemd
group: files | group: compat mymachines systemd
shadow: files | shadow: compat
hosts: files dns myhostname | hosts: files mymachines resolve [!UNAVAIL=return] dns myhostname

However, the command "hostname -i" throws: "hostname: gethostbyname: Unknown host" and the error is resolved only by restoring the "hosts: *" line (however the "systemd" version of the config file is changed then).

strace output shows following "open" calls:

open("/usr/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
open("/etc/resolv.conf", O_RDONLY|O_CLOEXEC) = 3
open("/etc/nsswitch.conf", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/libnss_files.so.2", O_RDONLY|O_CLOEXEC) = 3
open("/etc/host.conf", O_RDONLY|O_CLOEXEC) = 3
open("/etc/hosts", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/libnss_mymachines.so.2", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/libresolv.so.2", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/libcap.so.2", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/librt.so.1", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/libm.so.6", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/libnss_resolve.so.2", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/libnss_dns.so.2", O_RDONLY|O_CLOEXEC) = 4

Additional info:
* package version(s): 232-6
* config and/or log files etc. : /etc/nsswitch.conf

Steps to reproduce:
hostname -i
This task depends upon

Closed by  Doug Newgard (Scimmia)
Tuesday, 13 December 2016, 17:29 GMT
Reason for closing:  None
Additional comments about closing:  See  FS#51709 
Comment by Dave Reisner (falconindy) - Tuesday, 13 December 2016, 14:14 GMT
/etc/nsswitch.conf is provided by filesystem, not by systemd...

Seems like this only fails when systemd-resolved is not running.
Comment by Dave Reisner (falconindy) - Tuesday, 13 December 2016, 15:23 GMT Comment by Serhat Cevikel (serhatcevikel) - Tuesday, 13 December 2016, 17:02 GMT
You're right. "systemctl enable systemd-resolved" solves the problem even with the new "hosts: files mymachines resolve [!UNAVAIL=return] dns myhostname" line in /etc/nsswitch.conf
Comment by Doug Newgard (Scimmia) - Tuesday, 13 December 2016, 17:28 GMT
Since the other ticket is still open, let's keep the discussion together.

Loading...