dnsmasq: switch to /tmp/resolv.conf.d/resolv.conf.auto
authorDaniel Golle <daniel@makrotopia.org>
Fri, 3 Jan 2020 11:39:06 +0000 (13:39 +0200)
committerDaniel Golle <daniel@makrotopia.org>
Tue, 7 Jan 2020 13:37:22 +0000 (15:37 +0200)
Mount-bind directory instead of resolv.conf.auto file in jail to
avoid problems when the file is deleted/replaced.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
package/network/services/dnsmasq/files/dhcp.conf
package/network/services/dnsmasq/files/dnsmasq.init

index 360c7d79eeef397d320c1942250d25e7fc125807..19052e23337e5c065b92481e184b42daa26f4491 100644 (file)
@@ -13,7 +13,7 @@ config dnsmasq
        option authoritative    1
        option readethers       1
        option leasefile        '/tmp/dhcp.leases'
-       option resolvfile       '/tmp/resolv.conf.auto'
+       option resolvfile       '/tmp/resolv.conf.d/resolv.conf.auto'
        #list server            '/mycompany.local/1.2.3.4'
        option nonwildcard      1 # bind to & keep track of interfaces
        #list interface         br-lan
index 94a069f1ac9ada63300beadf394a4ff5027fc782..ae02f322d546664893e9e2d0c24bcb0aac64bf69 100644 (file)
@@ -768,7 +768,7 @@ dnsmasq_start()
 {
        local cfg="$1"
        local disabled user_dhcpscript
-       local resolvfile localuse=0
+       local resolvfile resolvdir localuse=0
 
        config_get_bool disabled "$cfg" disabled 0
        [ "$disabled" -gt 0 ] && return 0
@@ -923,10 +923,11 @@ dnsmasq_start()
 
        config_get_bool noresolv "$cfg" noresolv 0
        if [ "$noresolv" != "1" ]; then
-               config_get resolvfile "$cfg" resolvfile /tmp/resolv.conf.auto
+               config_get resolvfile "$cfg" resolvfile /tmp/resolv.conf.d/resolv.conf.auto
                [ -n "$resolvfile" -a ! -e "$resolvfile" ] && touch "$resolvfile"
                xappend "--resolv-file=$resolvfile"
-               [ "$resolvfile" = "/tmp/resolv.conf.auto" ] && localuse=1
+               [ "$resolvfile" = "/tmp/resolv.conf.d/resolv.conf.auto" ] && localuse=1
+               resolvdir="$(dirname "$resolvfile")"
        fi
        config_get_bool localuse "$cfg" localuse "$localuse"
 
@@ -1070,7 +1071,7 @@ dnsmasq_start()
        procd_set_param respawn
 
        procd_add_jail dnsmasq ubus log
-       procd_add_jail_mount $CONFIGFILE $TRUSTANCHORSFILE $HOSTFILE $RFC6761FILE $DHCPBOGUSHOSTNAMEFILE /etc/passwd /etc/group /etc/TZ /dev/null /dev/urandom $dnsmasqconffile $dnsmasqconfdir $resolvfile $user_dhcpscript /etc/hosts /etc/ethers /sbin/hotplug-call $EXTRA_MOUNT $DHCPSCRIPT
+       procd_add_jail_mount $CONFIGFILE $TRUSTANCHORSFILE $HOSTFILE $RFC6761FILE $DHCPBOGUSHOSTNAMEFILE /etc/passwd /etc/group /etc/TZ /dev/null /dev/urandom $dnsmasqconffile $dnsmasqconfdir $resolvdir $user_dhcpscript /etc/hosts /etc/ethers /sbin/hotplug-call $EXTRA_MOUNT $DHCPSCRIPT
        procd_add_jail_mount_rw /var/run/dnsmasq/ $leasefile
 
        procd_close_instance
@@ -1084,9 +1085,9 @@ dnsmasq_stop()
        config_get_bool noresolv "$cfg" noresolv 0
        config_get resolvfile "$cfg" "resolvfile"
 
-       [ "$noresolv" = 0 -a "$resolvfile" = "/tmp/resolv.conf.auto" ] && localuse=1
+       [ "$noresolv" = 0 -a "$resolvfile" = "/tmp/resolv.conf.d/resolv.conf.auto" ] && localuse=1
        config_get_bool localuse "$cfg" localuse "$localuse"
-       [ "$localuse" -gt 0 ] && ln -sf "/tmp/resolv.conf.auto" /tmp/resolv.conf
+       [ "$localuse" -gt 0 ] && ln -sf "/tmp/resolv.conf.d/resolv.conf.auto" /tmp/resolv.conf
 
        rm -f ${BASEDHCPSTAMPFILE}.${cfg}.*.dhcp
 }