[PATCH] resolv/resolv.h: allow alternative resolv.conf files
Renzo Davoli
renzo@cs.unibo.it
Thu Aug 17 11:50:00 GMT 2017
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 {
More information about the Libc-alpha
mailing list