Bug 1702218 - Resolver does not resolve host names listed in a file specified with HOSTALIASES variable
Summary: Resolver does not resolve host names listed in a file specified with HOSTALIA...
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Fedora
Classification: Fedora
Component: man-pages
Version: 29
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Nikola Forró
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-04-23 08:52 UTC by Petr Pisar
Modified: 2019-04-23 10:03 UTC (History)
13 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2019-04-23 10:03:13 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Petr Pisar 2019-04-23 08:52:42 UTC
hostname(7) manual page states:

       If the name consists of a single component, that is, contains no dot, and if the
       environment variable HOSTALIASES is set to the name of  a  file,  that  file  is
       searched for any string matching the input hostname.  The file should consist of
       lines made up of two white-space separated strings, the first of  which  is  the
       hostname  alias,  and the second of which is the complete hostname to be substi‐
       tuted for that alias.  If a case-insensitive match is found between the hostname
       to  be  resolved and the first field of a line in the file, the substituted name
       is looked up with no further processing.

This does not work for me:

$ cat /tmp/aliases 
foo localhost
$ HOSTALIASES=/tmp/aliases getent hosts foo
$ echo $?
2

It seems the file is read, but the content is not honored:

$ HOSTALIASES=/tmp/aliases strace -e openat getent hosts foo
[...]
openat(AT_FDCWD, "/lib64/libnss_files.so.2", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/etc/hosts", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/lib64/libnss_dns.so.2", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/lib64/libresolv.so.2", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/tmp/aliases", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/tmp/aliases", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/lib64/libnss_myhostname.so.2", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/lib64/librt.so.1", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/lib64/libmount.so.1", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/lib64/libgcc_s.so.1", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/lib64/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/lib64/libblkid.so.1", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/lib64/libuuid.so.1", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/lib64/libselinux.so.1", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/lib64/libpcre2-8.so.0", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/lib64/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/etc/hosts", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/tmp/aliases", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/tmp/aliases", O_RDONLY|O_CLOEXEC) = 3

My /etc/nsswitch.conf is:

hosts:      files dns myhostname

I have glibc-2.28-27.fc29.x86_64.

Comment 1 Florian Weimer 2019-04-23 08:57:53 UTC
HOSTALIASES only applies to the DNS resolver.  I assume that you have “localhost” defined in /etc/hosts, and not available in DNS.

Does this answer your question?

Comment 2 Petr Pisar 2019-04-23 09:56:28 UTC
Yes, I have localhost entry in /etc/hosts.

So is that a bug in hostname(7) documentation, or is glibc going to support HOSTALIASES processing with hosts "files" resolver?

Comment 3 Florian Weimer 2019-04-23 10:03:13 UTC
(In reply to Petr Pisar from comment #2)
> Yes, I have localhost entry in /etc/hosts.
> 
> So is that a bug in hostname(7) documentation, or is glibc going to support
> HOSTALIASES processing with hosts "files" resolver?

The documentation is misleading.  The search path processing applies to the “Internet name resolver” (which really means DNS) only, and I really don't think we can change that.  I submitted a patch here: https://marc.info/?l=linux-man&m=155601078704361&w=2


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