From owner-freebsd-net@FreeBSD.ORG Fri Aug 25 22:08:14 2006 Return-Path: X-Original-To: net@freebsd.org Delivered-To: freebsd-net@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 751CA16A4DA for ; Fri, 25 Aug 2006 22:08:14 +0000 (UTC) (envelope-from prvs=julian=38535a252@elischer.org) Received: from a50.ironport.com (a50.ironport.com [63.251.108.112]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3B2A54415A for ; Fri, 25 Aug 2006 22:08:14 +0000 (GMT) (envelope-from prvs=julian=38535a252@elischer.org) Received: from unknown (HELO [192.168.2.6]) ([10.251.60.50]) by a50.ironport.com with ESMTP; 25 Aug 2006 15:08:13 -0700 Message-ID: <44EF74CD.6080500@elischer.org> Date: Fri, 25 Aug 2006 15:08:13 -0700 From: Julian Elischer User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.7.13) Gecko/20060414 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Julian Elischer References: <44EF6E18.6090905@elischer.org> In-Reply-To: <44EF6E18.6090905@elischer.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: FreeBSD Net Subject: Re: possible patch for implementing split DNS X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Aug 2006 22:08:14 -0000 Julian Elischer wrote: > 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? oops patch had a bug.. here's the fixed version (permission checks were screwed up) %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 15:05:59 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 */