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: 802539 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-83326-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="bOMHOIoF"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xY4KP6fRwz9t2x for ; Thu, 17 Aug 2017 21:50:33 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; q=dns; s=default; b=PiSz/UtE8TxSRsa0cDxJ0jUUFC01g c7NxfMe/SItRd3akw4p1SZqUQVGrjHflQ6vTdw9iX/blDCAE2N8rOJLIFTZKUZQl DLM7r/0445aad+cu1CNTCfkIMP79YH14jaR066ctSFg75K32vc5jEhzBL8hlj3sD avVr6CYKsPlric= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; s=default; bh=L2X8Jb3dtVwBI/5+z8Y1glyKypM=; b=bOM HOIoFIr980LCBKzjvD7FiA/bYLcMeOr9X1CmuW3Yd7zruqo3Z+kZa2UsHUt+alxW paz9Qs1Vka3zjeC5oYRVsOcUFoZfAT1XhXTAvNB5ggvfYI+StAgWiWwPCqxvdGi7 aU3BKDfKGq2eeVsDFRKntrGrZhf7nZDia8xfe7H0= 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 {