public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: libc-alpha@sourceware.org
Subject: [PATCH 2/2] nss: Fix tst-nss-files-hosts-long on single-stack hosts (bug 24816)
Date: Tue, 13 Sep 2022 16:35:48 +0200	[thread overview]
Message-ID: <468dff5f8914e9db91785b32683ac0af1f4c731b.1663079342.git.fweimer@redhat.com> (raw)
In-Reply-To: <cover.1663079342.git.fweimer@redhat.com>

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.
---
 nss/tst-nss-files-hosts-long.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/nss/tst-nss-files-hosts-long.c b/nss/tst-nss-files-hosts-long.c
index 3942cf5fca..a7697e3143 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");
 
-- 
2.37.2


  parent reply	other threads:[~2022-09-13 14:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-13 14:35 [PATCH 0/2] Fix nss/tst-nss-files-hosts-long " Florian Weimer
2022-09-13 14:35 ` [PATCH 1/2] nss: Implement --no-addrconfig option for getent Florian Weimer
2022-09-14 22:34   ` Carlos O'Donell
2022-09-15 12:11     ` Florian Weimer
2022-09-13 14:35 ` Florian Weimer [this message]
2022-09-14 22:35   ` [PATCH 2/2] nss: Fix tst-nss-files-hosts-long on single-stack hosts (bug 24816) Carlos O'Donell
2022-09-14  9:42 ` [PATCH 0/2] Fix nss/tst-nss-files-hosts-long " Carlos O'Donell
2022-09-14  9:54   ` Florian Weimer
2022-09-14 22:26     ` Carlos O'Donell
2022-09-15 12:37       ` Florian Weimer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=468dff5f8914e9db91785b32683ac0af1f4c731b.1663079342.git.fweimer@redhat.com \
    --to=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).