6ca6e8
commit 16c7ed6e68c13e5a5efd8ab464ebf9d07b4b0bb3
6ca6e8
Author: Florian Weimer <fweimer@redhat.com>
6ca6e8
Date:   Tue Sep 13 16:11:40 2022 +0200
6ca6e8
6ca6e8
    nss: Fix tst-nss-files-hosts-long on single-stack hosts (bug 24816)
6ca6e8
    
6ca6e8
    getent implicitly passes AI_ADDRCONFIG to getaddrinfo by default.
6ca6e8
    Use --no-addrconfig to suppress that, so that both IPv4 and IPv6
6ca6e8
    lookups succeed even if the address family is not supported by the
6ca6e8
    host.
6ca6e8
    
6ca6e8
    Reviewed-by: Carlos O'Donell <carlos@redhat.com>
6ca6e8
    (cherry picked from commit c75d20b5b27b0a60f0678236f51a4d3b0b058c00)
6ca6e8
6ca6e8
diff --git a/nss/tst-nss-files-hosts-long.c b/nss/tst-nss-files-hosts-long.c
6ca6e8
index 00f8bea409e0b4cb..42676ba4056dbde2 100644
6ca6e8
--- a/nss/tst-nss-files-hosts-long.c
6ca6e8
+++ b/nss/tst-nss-files-hosts-long.c
6ca6e8
@@ -28,14 +28,15 @@ do_test (void)
6ca6e8
 {
6ca6e8
   int ret;
6ca6e8
 
6ca6e8
-  /* Run getent to fetch the IPv4 address for host test4.
6ca6e8
-     This forces /etc/hosts to be parsed.  */
6ca6e8
-  ret = system("getent ahostsv4 test4");
6ca6e8
+  /* Run getent to fetch the IPv4 address for host test4.  This forces
6ca6e8
+     /etc/hosts to be parsed.  Use --no-addrconfig to return addresses
6ca6e8
+     even in an IPv6-only environment.  */
6ca6e8
+  ret = system("getent --no-addrconfig ahostsv4 test4");
6ca6e8
   if (ret != 0)
6ca6e8
     FAIL_EXIT1("ahostsv4 failed");
6ca6e8
 
6ca6e8
   /* Likewise for IPv6.  */
6ca6e8
-  ret = system("getent ahostsv6 test6");
6ca6e8
+  ret = system("getent --no-addrconfig  ahostsv6 test6");
6ca6e8
   if (ret != 0)
6ca6e8
     FAIL_EXIT1("ahostsv6 failed");
6ca6e8