public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] resolv/resolv.h: allow alternative resolv.conf files
@ 2017-08-17 11:50 Renzo Davoli
  2017-08-17 12:41 ` Florian Weimer
  2017-09-18 15:12 ` Florian Weimer
  0 siblings, 2 replies; 17+ messages in thread
From: Renzo Davoli @ 2017-08-17 11:50 UTC (permalink / raw)
  To: libc-alpha

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 {

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2017-09-18 15:27 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-17 11:50 [PATCH] resolv/resolv.h: allow alternative resolv.conf files Renzo Davoli
2017-08-17 12:41 ` Florian Weimer
2017-08-17 13:14   ` Zack Weinberg
2017-08-17 13:59     ` Renzo Davoli
2017-08-17 14:32       ` Renzo Davoli
2017-08-17 15:21         ` Carlos O'Donell
2017-08-17 16:18           ` Renzo Davoli
2017-08-17 16:25             ` Florian Weimer
2017-08-17 16:49               ` Szabolcs Nagy
2017-08-17 16:55                 ` Florian Weimer
2017-08-17 16:13         ` Florian Weimer
2017-08-18 15:08           ` Renzo Davoli
2017-08-18 16:41             ` Carlos O'Donell
2017-08-22  9:37               ` Renzo Davoli
2017-08-23  4:07                 ` Carlos O'Donell
2017-09-18 15:12 ` Florian Weimer
2017-09-18 15:27   ` Carlos O'Donell

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).