Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 25 Aug 2006 14:39:36 -0700
From:      Julian Elischer <julian@elischer.org>
To:        FreeBSD Net <freebsd-net@freebsd.org>
Subject:   possible patch for implementing split DNS
Message-ID:  <44EF6E18.6090905@elischer.org>

next in thread | raw e-mail | index | archive | help
I need some processes to look elsewhere for DNS information from where 
the rest
of the system looks.. This patch seems to me a simple solution.
We over-ride where the resolver looks for resolv.conf using an 
environment variable.
This would allow me to reset this to an application specific config file 
that
specifies a different server.

Anyone got better ways fo doing this?



%diff -u ./lib/libc/net/res_init.c /tmp/res_init.c
--- ./lib/libc/net/res_init.c   Thu Sep  9 10:42:18 2004
+++ /tmp/res_init.c     Fri Aug 25 14:31:41 2006
@@ -154,6 +154,7 @@
        int nserv = 0;    /* number of nameserver records read from file */
        int haveenv = 0;
        int havesearch = 0;
+       char *conf_path;
 #ifdef RESOLVSORT
        int nsort = 0;
        char *net;
@@ -262,7 +263,10 @@
        (line[sizeof(name) - 1] == ' ' || \
         line[sizeof(name) - 1] == '\t'))
 
-       if ((fp = fopen(_PATH_RESCONF, "r")) != NULL) {
+       if (issetugid() == 0 && (res_path = getenv("RESOLV_CONF")) != NULL)
+               res_path = _PATH_RESCONF;
+
+       if ((fp = fopen(res_path, "r")) != NULL) {
            /* read the config file */
            while (fgets(buf, sizeof(buf), fp) != NULL) {
                /* skip comments */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?44EF6E18.6090905>