From patchwork Thu Aug 17 11:50:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Renzo Davoli X-Patchwork-Id: 22185 Received: (qmail 59307 invoked by alias); 17 Aug 2017 11:50:26 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 58675 invoked by uid 89); 17 Aug 2017 11:50:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_NEUTRAL autolearn=ham version=3.3.2 spammy=9110, HX-HELO:sk:mail.vi, H*r:sk:mail.vi, Hx-spam-relays-external:sk:mail.vi X-HELO: mail.virtlab.unibo.it Date: Thu, 17 Aug 2017 13:50:13 +0200 From: Renzo Davoli To: libc-alpha@sourceware.org Subject: [PATCH] resolv/resolv.h: allow alternative resolv.conf files Message-ID: <20170817115013.sepjn4aqfi3dlwje@cs.unibo.it> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20170609 (1.8.3) 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 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 {