aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Oranje <por@xs4all.nl>2017-06-09 11:30:23 +0200
committerHans Dedecker <dedeckeh@gmail.com>2017-06-12 11:08:21 +0200
commita53f8ba6771de64c9c82a2e6867791226f3003cb (patch)
treefaabb47f7b4126ee9a2e3531972279a436e99793
parent3ff31586eb0a165fb42a102101ac12c66d55652e (diff)
downloadupstream-a53f8ba6771de64c9c82a2e6867791226f3003cb.tar.gz
upstream-a53f8ba6771de64c9c82a2e6867791226f3003cb.tar.bz2
upstream-a53f8ba6771de64c9c82a2e6867791226f3003cb.zip
dnsmasq: manage resolv.conf if when listening on 127.0.0.1#53
With this patch the dnsmasq init script manages resolv.conf if and only if when dnsmasq will listen on 127.0.0.1#53 (is main resolver instance). Also, resolvfile is now set irrespective of the value of noresolv. Fixes (partially) FS#785 Signed-off-by: Paul Oranje <por@xs4all.nl>
-rw-r--r--package/network/services/dnsmasq/Makefile2
-rw-r--r--package/network/services/dnsmasq/files/dnsmasq.init60
2 files changed, 36 insertions, 26 deletions
diff --git a/package/network/services/dnsmasq/Makefile b/package/network/services/dnsmasq/Makefile
index f9ab13aef0..35ac6b2891 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.77
-PKG_RELEASE:=3
+PKG_RELEASE:=4
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 d5177ecb0c..fda11401db 100644
--- a/package/network/services/dnsmasq/files/dnsmasq.init
+++ b/package/network/services/dnsmasq/files/dnsmasq.init
@@ -707,6 +707,21 @@ dhcp_relay_add() {
fi
}
+dnsmasq_ismain()
+{
+ local cfg="$1"
+ local port notinterfaces
+
+ config_get port "$cfg" port "53"
+ [ $port = "53" ] || return 1
+
+ config_get notinterfaces "$cfg" notinterface ""
+ [ -n $notinterfaces ] && list_contains $notinterfaces "loopback" || return 1
+
+ # dnsmasq instance is designated to listen on 127.0.0.1#53.
+ return 0
+}
+
dnsmasq_start()
{
local cfg="$1" disabled resolvfile user_dhcpscript
@@ -853,14 +868,10 @@ dnsmasq_start()
[ -n "$leasefile" -a \! -e "$leasefile" ] && touch "$leasefile"
config_get_bool cachelocal "$cfg" cachelocal 1
- config_get_bool noresolv "$cfg" noresolv 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"
- fi
-
- [ -n "$resolvfile" ] && xappend "--resolv-file=$resolvfile"
+ config_get resolvfile "$cfg" resolvfile "/tmp/resolv.conf.auto"
+ xappend "--resolv-file=$resolvfile"
+ # So jail doesn't complain if file missing
+ [ \! -e "$resolvfile" ] && touch "$resolvfile"
config_get hostsfile "$cfg" dhcphostsfile
[ -e "$hostsfile" ] && xappend "--dhcp-hostsfile=$hostsfile"
@@ -973,16 +984,6 @@ dnsmasq_start()
echo >> $CONFIGFILE_TMP
mv -f $CONFIGFILE_TMP $CONFIGFILE
- [ "$resolvfile" = "/tmp/resolv.conf.auto" ] && {
- rm -f /tmp/resolv.conf
- [ $ADD_LOCAL_DOMAIN -eq 1 ] && [ -n "$DOMAIN" ] && {
- echo "search $DOMAIN" >> /tmp/resolv.conf
- }
- DNS_SERVERS="$DNS_SERVERS 127.0.0.1"
- for DNS_SERVER in $DNS_SERVERS ; do
- echo "nameserver $DNS_SERVER" >> /tmp/resolv.conf
- done
- }
procd_open_instance $cfg
procd_set_param command $PROG -C $CONFIGFILE -k -x /var/run/dnsmasq/dnsmasq."${cfg}".pid
@@ -1000,20 +1001,29 @@ dnsmasq_start()
procd_add_jail_mount_rw /var/run/dnsmasq/ $leasefile
procd_close_instance
+
+
+ # write /tmp/resolve.conf only for main instance
+ dnsmasq_ismain $cfg && {
+ rm -f /tmp/resolv.conf
+ [ $ADD_LOCAL_DOMAIN -eq 1 ] && [ -n "$DOMAIN" ] && {
+ echo "search $DOMAIN" >> /tmp/resolv.conf
+ }
+ DNS_SERVERS="$DNS_SERVERS 127.0.0.1"
+ for DNS_SERVER in $DNS_SERVERS ; do
+ echo "nameserver $DNS_SERVER" >> /tmp/resolv.conf
+ done
+ }
}
dnsmasq_stop()
{
local cfg="$1"
- 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
- }
+ dnsmasq_ismain $cfg && {
+ [ -f /tmp/resolv.conf ] && rm -f /tmp/resolv.conf
+ ln -s /tmp/resolv.conf.auto /tmp/resolv.conf
}
rm -f ${BASEDHCPSTAMPFILE}.${cfg}.*.dhcp