resolve: refuse to resolve empty hostname
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 20 Jan 2022 18:03:45 +0000 (03:03 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 21 Jan 2022 00:45:29 +0000 (09:45 +0900)
commit6e8ecb8974db74eba716bfd75231987172e10d83
tree260addb81d6d153dcde915e3ea88f5563c1f1e0a
parent9969c901d3fe7af5cfcd4ca4236946915140b457
resolve: refuse to resolve empty hostname

Previously, varlink or dbus methods return
io.systemd.Resolve.NoNameServers or BUS_ERROR_NO_NAME_SERVERS if an
empty hostname is provided, and thus nss-resolve returns NSS_STATUS_TRYAGAIN.

That causes getaddrinfo() returns 'Temporary failure in name resolution'
instead of 'Name or service not known'.

This makes calling varlink or dbus method with an empty hostname result
-EINVAL, and hence nss-resolve returns NSS_STATUS_NOTFOUND.

Fixes RHBZ#2039854 (https://bugzilla.redhat.com/show_bug.cgi?id=2039854).
src/resolve/resolved-bus.c
src/resolve/resolved-varlink.c
src/shared/dns-domain.h