This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] resolv/resolv.h: allow alternative resolv.conf files
- From: Renzo Davoli <renzo at cs dot unibo dot it>
- To: libc-alpha at sourceware dot org
- Date: Thu, 17 Aug 2017 13:50:13 +0200
- Subject: [PATCH] resolv/resolv.h: allow alternative resolv.conf files
- Authentication-results: sourceware.org; auth=none
In network namespaces (like vdens https://github.com/rd235/vdens) it is sometimes necessary to
define per-namespace resolver configurations.
The simple patch here attached permits the definition of an environment variabile to define the
path of the file to use instead of /etc/resolv.conf.
e.g.:
export PATH_RESCONF=/tmp/resolv.conf
2017-08-17 Renzo Davoli <renzo@cs.unibo.it>
diff --git a/resolv/resolv.h b/resolv/resolv.h
index e8c581ccd1..5e7a8143c3 100644
--- a/resolv/resolv.h
+++ b/resolv/resolv.h
@@ -91,7 +91,10 @@
*/
#ifndef _PATH_RESCONF
-#define _PATH_RESCONF "/etc/resolv.conf"
+#define _PATH_RESCONF ({ \
+ char *path_resconf = getenv("PATH_RESCONF"); \
+ path_resconf ? path_resconf : "/etc/resolv.conf"; \
+ })
#endif
struct res_sym {