From patchwork Sat Feb 23 02:17:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yousong Zhou X-Patchwork-Id: 1047249 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=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="n4J+Emkl"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="qYYVm8my"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 445sM214f3z9sBR for ; Sat, 23 Feb 2019 13:18:16 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:Message-Id:Date:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=2+V6/1DAGfLqadNiL7NxNYtnwmTHfr9tdDLC/aEKw90=; b=n4J+EmklDTn0r7 5B2d2CcyRPtMQiUj414wDlKHUYv1w/0Jg8ek/RawXTHs8dhcvZTeRMi+krWtsnl0XmuSkiewjbS+5 e6OCzQ0gZrihtKSNRb+JAxeQirVVzlUgcPzoAzhtKwdrwbqeW5XprGWkDjqoubIcHztKHRCOGfP0V JgYFUFmM7gRHCIZE1MjuvaxJoPOuHR4tM4L6yhxwC9oiPE6SsmUMeN3KxSqmlEtcpFUao4LdwtAeG sX1NdYf7xZQf/Qqgcws81bMmwA38lKgUP/nZG/pycuTbIX9SKGfBhICeqRfYFO0nd3OJauRTTMRHh xM5o5bYltM/BlnpjcgYA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gxMt1-0006aP-OV; Sat, 23 Feb 2019 02:17:55 +0000 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gxMsy-0006a4-O0 for openwrt-devel@lists.openwrt.org; Sat, 23 Feb 2019 02:17:54 +0000 Received: by mail-pf1-x443.google.com with SMTP id n125so1907338pfn.5 for ; Fri, 22 Feb 2019 18:17:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=8YAZGbZpLSaMpDIc3xC9f1gIb7A63sKa1nooc45c6kw=; b=qYYVm8my4c7kh6ufRsG0stzcPjxWKTGLgveyMJ33Ncf4QFJ6biDwFcYZlMqsYGO00x 6Q3tJXaFJds25PmptISPhBp82MjbpxmI+D76dMvjYv0qmaPlxyWb8AIlvt1+bgsU/CQ2 0OnNpgpRfRjvJN9Bl7eguygdr96hHqtcRBXecmx0glPin9Fy548bRJAL+fa0NOgKdhHk ZJdioRszRjmf3mC3kKlpvJV0XoPrxuXGPrXqPh5DbZYzgeCkMBvFerEzusj/ZB7w4HYq FOHWV+aVFN4KCi2bk8q9BKNsUj2n9z6O56gkOZUyYqELtlQ8LWx3uF/XxB69CoxTHSQo v/Qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=8YAZGbZpLSaMpDIc3xC9f1gIb7A63sKa1nooc45c6kw=; b=S6cX7MU+IU6BKAVwbVSdjyH+9KLF0cK7PtHgH//ldXIJ8XkU7IkhmwxS0z0oXZ0yHG aYfeOMIv/mzpxmjUseqa+VnQG0cG7wwlh9TvUa6evKvET7mdCu58jQDubhk/cX/I6f+Q Bg+nLonPgrGfBREEzSW7gccjagyl+Xz9oHX6q9mLW8sGhYHeeadZvhThZnY8S5RVjAJk G2RO4nzALjaKWhS/x3UIfL/27a6ECZBZwbtIXoZG22a+5kTj83DDQBFLiLAQabpQDclf q2BwD+k7YrH+9MeI0i9pEPcTcvr5xtN5p4nqlwJBsW5/Vm9QCIQG7HVwgTgpZr1P1SEC Gqyw== X-Gm-Message-State: AHQUAuamjLAY0jrE3tT7AFd46GNxaDvFLMbicRtImq0q2ZtT01IkEQX/ uQESFfM5AAe39SmYsZEtZq8= X-Google-Smtp-Source: AHgI3IY17RgwADqjO9wq6+nxm8BuJK/tmNeyzHm5edV6ENQ227UI3uMb3OUBiVqiHDWxPrp1CDaguw== X-Received: by 2002:a62:1d0c:: with SMTP id d12mr7356902pfd.126.1550888271726; Fri, 22 Feb 2019 18:17:51 -0800 (PST) Received: from titan.localdomain.hq.cloud.yunionyun.com ([47.52.22.109]) by smtp.gmail.com with ESMTPSA id y22sm2577541pfn.136.2019.02.22.18.17.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Feb 2019 18:17:50 -0800 (PST) From: Yousong Zhou To: dedeckeh@gmail.com Date: Sat, 23 Feb 2019 02:17:30 +0000 Message-Id: <20190223021732.7210-1-yszhou4tech@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190222_181752_782230_7E9B09A8 X-CRM114-Status: UNSURE ( 9.89 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:443 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (yszhou4tech[at]gmail.com) -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid Subject: [OpenWrt-Devel] [PATCH 18.06 1/2] dnsmasq: allow using dnsmasq as the sole resolver X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: por@oranjevos.nl, Yousong Zhou , openwrt-devel@lists.openwrt.org, ldir@darbyshire-bryant.me.uk Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Currently it seems impossible to configure /etc/config/dhcp to achieve the following use case - run dnsmasq with no-resolv - re-generate /etc/resolv.conf with "nameserver 127.0.0.1" Before this change, we have to set resolvfile to /tmp/resolv.conf.auto to achive the 2nd effect above, but setting resolvfile requires noresolv being false. A new boolean option "localuse" is added to indicate that we intend to use dnsmasq as the local dns resolver. It's false by default and to align with old behaviour it will be true automatically if resolvfile is set to /tmp/resolv.conf.auto (cherry picked from 2aea1ada65f050d74a064e74466bbe4e8d) Signed-off-by: Yousong Zhou Acked-by: Hans Dedecker Tested-by: Paul Oranje --- package/network/services/dnsmasq/Makefile | 2 +- .../services/dnsmasq/files/dnsmasq.init | 30 +++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/package/network/services/dnsmasq/Makefile b/package/network/services/dnsmasq/Makefile index e89ad19f5c..c50717d091 100644 --- a/package/network/services/dnsmasq/Makefile +++ b/package/network/services/dnsmasq/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=dnsmasq PKG_VERSION:=2.80 -PKG_RELEASE:=1.2 +PKG_RELEASE:=1.3 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=http://thekelleys.org.uk/dnsmasq diff --git a/package/network/services/dnsmasq/files/dnsmasq.init b/package/network/services/dnsmasq/files/dnsmasq.init index 9c922eec6c..b119981cb8 100644 --- a/package/network/services/dnsmasq/files/dnsmasq.init +++ b/package/network/services/dnsmasq/files/dnsmasq.init @@ -731,7 +731,9 @@ dhcp_relay_add() { dnsmasq_start() { - local cfg="$1" disabled resolvfile user_dhcpscript + local cfg="$1" + local disabled user_dhcpscript + local resolvfile localuse config_get_bool disabled "$cfg" disabled 0 [ "$disabled" -gt 0 ] && return 0 @@ -881,14 +883,14 @@ dnsmasq_start() config_get_bool cachelocal "$cfg" cachelocal 1 config_get_bool noresolv "$cfg" noresolv 0 + config_get_bool localuse "$cfg" localuse 0 if [ "$noresolv" != "1" ]; then - config_get resolvfile "$cfg" resolvfile "/tmp/resolv.conf.auto" - # So jail doesn't complain if file missing - [ -n "$resolvfile" -a \! -e "$resolvfile" ] && touch "$resolvfile" + config_get resolvfile "$cfg" resolvfile /tmp/resolv.conf.auto + [ -n "$resolvfile" -a ! -e "$resolvfile" ] && touch "$resolvfile" + xappend "--resolv-file=$resolvfile" + [ "$resolvfile" = "/tmp/resolv.conf.auto" ] && localuse=1 fi - [ -n "$resolvfile" ] && xappend "--resolv-file=$resolvfile" - config_get hostsfile "$cfg" dhcphostsfile [ -e "$hostsfile" ] && xappend "--dhcp-hostsfile=$hostsfile" @@ -1010,7 +1012,7 @@ dnsmasq_start() mv -f $CONFIGFILE_TMP $CONFIGFILE mv -f $HOSTFILE_TMP $HOSTFILE - [ "$resolvfile" = "/tmp/resolv.conf.auto" ] && { + [ "$localuse" -gt 0 ] && { rm -f /tmp/resolv.conf [ $ADD_LOCAL_DOMAIN -eq 1 ] && [ -n "$DOMAIN" ] && { echo "search $DOMAIN" >> /tmp/resolv.conf @@ -1036,17 +1038,15 @@ dnsmasq_start() dnsmasq_stop() { - local cfg="$1" resolvfile + local cfg="$1" + local noresolv resolvfile localuse + config_get_bool noresolv "$cfg" noresolv 0 + config_get_bool localuse "$cfg" localuse 0 config_get resolvfile "$cfg" "resolvfile" - #relink /tmp/resolve.conf only for main instance - [ "$resolvfile" = "/tmp/resolv.conf.auto" ] && { - [ -f /tmp/resolv.conf ] && { - rm -f /tmp/resolv.conf - ln -s "$resolvfile" /tmp/resolv.conf - } - } + [ "$noresolv" = 0 -a "$resolvfile" = "/tmp/resolv.conf.auto" ] && localuse=1 + [ "$localuse" -gt 0 ] && ln -sf "/tmp/resolv.conf.auto" /tmp/resolv.conf rm -f ${BASEDHCPSTAMPFILE}.${cfg}.*.dhcp }