> Op 22 feb. 2019, om 03:05 heeft Yousong Zhou <yszhou4t...@gmail.com> het
> volgende geschreven:
>
> On Tue, 19 Feb 2019 at 23:02, Paul Oranje <p...@oranjevos.nl> wrote:
>>
>> Op 18 feb. 2019, om 21:50 heeft Hans Dedecker <dedec...@gmail.com> het
>> volgende geschreven:
>>>
>>> On Mon, Feb 18, 2019 at 3:18 PM Yousong Zhou <yszhou4t...@gmail.com> wrote:
>>>>
>>>> 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
>>>>
>>>> Signed-off-by: Yousong Zhou <yszhou4t...@gmail.com>
>>> Acked-by: Hans Dedecker <dedec...@gmail.com>
>>>> ---
>>>> v2 <- v1
>>>>
>>>> - retain /tmp/resolv.conf.auto as the default value of resolvfile when
>>>> doing config_get, i.e. 2nd patch in the 1st version is now dropped
>>>> - retain the old behavior of rewriting /tmp/resolv.conf when resolvfile
>>>> is /tmp/resolv.conf.auto
>>>>
>>>> .../services/dnsmasq/files/dnsmasq.init | 30 +++++++++----------
>>>> 1 file changed, 15 insertions(+), 15 deletions(-)
>>>>
>>>> diff --git a/package/network/services/dnsmasq/files/dnsmasq.init
>>>> b/package/network/services/dnsmasq/files/dnsmasq.init
>>>> index f3066627d6..f65736e268 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
>>>> @@ -882,14 +884,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"
>>>>
>>>> @@ -1011,7 +1013,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
>>>> @@ -1037,17 +1039,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
>>>> }
>>>
>>
>> Hi,
>>
>> In 2017 I submitted a patch to deal with having resolv.conf (used by the
>> CLIB local resolver) being set correctly, see [1] and [2].
>> For the problem it sets out to solve (partially) an issue was opened [3].
>> The use-case concerned having Unbound as nameserver with dnsmasq handling
>> DNS for the local lan domain and DHCP.
>> The patch was not merged since it was deemed that setting resolv.conf
>> requires atomicity which would imply extending netifd with the functionality
>> to handle this instead as my patch could not offer this atomic setting of
>> resolv.conf.
>>
>> Currently with the use-case (Unbound with "option dhcp_link 'dnsmasq'" set)
>> still requires restarting Unbound manually after a restart of dnsmasq since
>> dnsmasq.init will reset resol.conf to /etc/resolv.conf.auto.
>>
>> I wonder, did you see that patch and could that patch still be relevant ?
>>
>> [1] http://lists.openwrt.org/pipermail/openwrt-devel/2017-June/007923.html
>> [2] https://patchwork.ozlabs.org/patch/780353/
>> [3] https://bugs.openwrt.org/index.php?do=details&task_id=785
>>
>> Regards,
>> Paul
>
> Hi, Paul
>
> I think scripting action by guessing users' intention is not a good
> approach here. dnsmasq can be very flexible and OpenWrt/Linux is a
> highly-customizable system. It's very hard to cover all cases to
> fulfill the original intention of the guess logic itself. And the
> result of that is people may find the smart thing stand in their way
> when doing customizations. That's my first impression on the "if
> dnsmasq listens on port 53 then touch /etc/resolv.conf"
> implementation.
>
> Regards,
> yousong
>
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
I agree, in the end "intelligent solutions" **alway** bite.
Paul
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel