[glibc] resolv: Run tst-getaddrinfo-eai-again in a network namespace

Florian Weimer via Glibc-cvs <[email protected]>
Newsgroups gmane.comp.lib.glibc.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=1b2f868fb4958fd59875695c1828d9804b116dc2

commit 1b2f868fb4958fd59875695c1828d9804b116dc2
Author: Florian Weimer <[email protected]>
Date:   Tue Apr 7 10:49:13 2026 +0200

    resolv: Run tst-getaddrinfo-eai-again in a network namespace
    
    This ensures that the test does not accidentally use a name server
    running on 127.0.0.1.
    
    Tested-by:  Frédéric Bérat <[email protected]>
    Reviewed-by: Frédéric Bérat <[email protected]>

Diff:
---
 resolv/tst-getaddrinfo-eai-again.c                                    | 4 ++++
 .../tst-getaddrinfo-eai-again.root/tst-getaddrinfo-eai-again.script   | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/resolv/tst-getaddrinfo-eai-again.c b/resolv/tst-getaddrinfo-eai-again.c
index f035d694e8..43505818b6 100644
--- a/resolv/tst-getaddrinfo-eai-again.c
+++ b/resolv/tst-getaddrinfo-eai-again.c
@@ -20,6 +20,7 @@
 
 #include <netdb.h>
 #include <support/check.h>
+#include <support/namespace.h>
 
 /* Query getaddrinfo with various address families and verify that
    it returns EAI_AGAIN when DNS resolution fails.  */
@@ -49,6 +50,9 @@ query_host (const char *host_name)
 static int
 do_test (void)
 {
+  /* Hide any name server that might be running on 127.0.0.1.  */
+  support_enter_network_namespace ();
+
   query_host ("site.example");
   return 0;
 }
diff --git a/resolv/tst-getaddrinfo-eai-again.root/tst-getaddrinfo-eai-again.script b/resolv/tst-getaddrinfo-eai-again.root/tst-getaddrinfo-eai-again.script
new file mode 100644
index 0000000000..383f92b5b0
--- /dev/null
+++ b/resolv/tst-getaddrinfo-eai-again.root/tst-getaddrinfo-eai-again.script
@@ -0,0 +1,2 @@
+# Enable entering a network namespace.
+su
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.