From: Florian Weimer Date: Tue, 13 Sep 2022 14:11:40 +0000 (+0200) Subject: nss: Fix tst-nss-files-hosts-long on single-stack hosts (bug 24816) X-Git-Tag: glibc-2.37~337 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c75d20b5b27b0a60f0678236f51a4d3b0b058c00;p=thirdparty%2Fglibc.git nss: Fix tst-nss-files-hosts-long on single-stack hosts (bug 24816) getent implicitly passes AI_ADDRCONFIG to getaddrinfo by default. Use --no-addrconfig to suppress that, so that both IPv4 and IPv6 lookups succeed even if the address family is not supported by the host. Reviewed-by: Carlos O'Donell --- diff --git a/nss/tst-nss-files-hosts-long.c b/nss/tst-nss-files-hosts-long.c index 3942cf5fca5..a7697e31431 100644 --- a/nss/tst-nss-files-hosts-long.c +++ b/nss/tst-nss-files-hosts-long.c @@ -28,14 +28,15 @@ do_test (void) { int ret; - /* Run getent to fetch the IPv4 address for host test4. - This forces /etc/hosts to be parsed. */ - ret = system("getent ahostsv4 test4"); + /* Run getent to fetch the IPv4 address for host test4. This forces + /etc/hosts to be parsed. Use --no-addrconfig to return addresses + even in an IPv6-only environment. */ + ret = system("getent --no-addrconfig ahostsv4 test4"); if (ret != 0) FAIL_EXIT1("ahostsv4 failed"); /* Likewise for IPv6. */ - ret = system("getent ahostsv6 test6"); + ret = system("getent --no-addrconfig ahostsv6 test6"); if (ret != 0) FAIL_EXIT1("ahostsv6 failed");