[OpenWrt-Devel] [PATCH 2/2] dnsmasq: add option to avoid modifying resolv.conf

2011-09-11 Thread Linus Lüssing
Currently, dnsmasq removes /tmp/resolv.conf (which is usually a symlink
to /tmp/resolv.conf.auto) and creates its own resolv.conf with at least
a nameserver pointing to 127.0.0.1.

However, in some cases it might not be desired that the router itself
queries its own dnsmasq dns-server but should query the upstream dns
server - possibly fetched via an additional, local dhcp client -
directly instead.

With this new uci configuration option it is possible to prohibit
dnsmasq to change /tmp/resolv.conf, leaving it as provided by the
udhcpd.

Signed-off-by: Linus Lüssing linus.luess...@web.de
---
* shortened the option name
* commented this option out in the default dhcp.conf to make clear
  that it's optional and should not break any old configs

 package/dnsmasq/files/dhcp.conf|1 +
 package/dnsmasq/files/dnsmasq.init |8 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/package/dnsmasq/files/dhcp.conf b/package/dnsmasq/files/dhcp.conf
index 5ba772e..2d7f185 100644
--- a/package/dnsmasq/files/dhcp.conf
+++ b/package/dnsmasq/files/dhcp.conf
@@ -20,6 +20,7 @@ config dnsmasq
#list interface br-lan
#list notinterface  lo
#list bogusnxdomain '64.94.110.11'
+   #option keepresolvcf0
 
 config dhcp lan
option interfacelan
diff --git a/package/dnsmasq/files/dnsmasq.init 
b/package/dnsmasq/files/dnsmasq.init
index 9518df3..5570d35 100644
--- a/package/dnsmasq/files/dnsmasq.init
+++ b/package/dnsmasq/files/dnsmasq.init
@@ -114,6 +114,8 @@ dnsmasq() {
config_get hostsfile $cfg dhcphostsfile
[ -e $hostsfile ]  append args --dhcp-hostsfile=$hostsfile
 
+   config_get_bool keepresolvcf $cfg keepresolvcf
+
local rebind
config_get_bool rebind $cfg rebind_protection 1
[ $rebind -gt 0 ]  {
@@ -388,8 +390,9 @@ start() {
config_foreach dhcp_srv_add srvhost
config_foreach dhcp_add dhcp
 
-   /usr/sbin/dnsmasq $args  {
+   /usr/sbin/dnsmasq $args  [ ! $keepresolvcf = 1 ]  {
rm -f /tmp/resolv.conf
+   echo ### Created by dnsmasq.init ###  /tmp/resolv.conf
[ -n $DOMAIN ]  echo search $DOMAIN  /tmp/resolv.conf
DNS_SERVERS=$DNS_SERVERS 127.0.0.1
for DNS_SERVER in $DNS_SERVERS ; do
@@ -399,7 +402,8 @@ start() {
 }
 
 stop() {
-   [ -f /tmp/resolv.conf ]  {
+   [ -f /tmp/resolv.conf ]  \
+   [ `head -n1 /tmp/resolv.conf` = ### Created by dnsmasq.init ### ] 
 {
rm -f /tmp/resolv.conf
ln -s /tmp/resolv.conf.auto /tmp/resolv.conf
}
-- 
1.7.5.4

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 2/2] dnsmasq: add option to avoid modifying resolv.conf

2011-04-08 Thread Linus Lüssing
Currently, dnsmasq removes /tmp/resolv.conf (which is usually a symlink
to /tmp/resolv.conf.auto) and creates its own resolv.conf with at least
a nameserver pointing to 127.0.0.1.

However, in some cases it might not be desired that the router itself
queries its own dnsmasq dns-server but should query the upstream dns
server - possibly fetched via an additional, local dhcp client -
directly instead.

With this new uci configuration option it is possible to prohibit
dnsmasq to change /tmp/resolv.conf, leaving it as provided by the
udhcpd.

Signed-off-by: Linus Lüssing linus.luess...@web.de
---
 package/dnsmasq/files/dhcp.conf|1 +
 package/dnsmasq/files/dnsmasq.init |8 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/package/dnsmasq/files/dhcp.conf b/package/dnsmasq/files/dhcp.conf
index 5ba772e..aa5f703 100644
--- a/package/dnsmasq/files/dhcp.conf
+++ b/package/dnsmasq/files/dhcp.conf
@@ -20,6 +20,7 @@ config dnsmasq
#list interface br-lan
#list notinterface  lo
#list bogusnxdomain '64.94.110.11'
+   option resolvconfuntouched 0
 
 config dhcp lan
option interfacelan
diff --git a/package/dnsmasq/files/dnsmasq.init 
b/package/dnsmasq/files/dnsmasq.init
index 8334b38..a578649 100644
--- a/package/dnsmasq/files/dnsmasq.init
+++ b/package/dnsmasq/files/dnsmasq.init
@@ -114,6 +114,8 @@ dnsmasq() {
config_get hostsfile $cfg dhcphostsfile
[ -e $hostsfile ]  append args --dhcp-hostsfile=$hostsfile
 
+   config_get_bool resolvconfuntouched $cfg resolvconfuntouched
+
local rebind
config_get_bool rebind $cfg rebind_protection 1
[ $rebind -gt 0 ]  {
@@ -389,8 +391,9 @@ start() {
config_foreach dhcp_srv_add srvhost
config_foreach dhcp_add dhcp
 
-   /usr/sbin/dnsmasq $args  {
+   /usr/sbin/dnsmasq $args  [ ! $resolvconfuntouched = 1 ]  {
rm -f /tmp/resolv.conf
+   echo ### Created by dnsmasq.init ###  /tmp/resolv.conf
[ -n $DOMAIN ]  echo search $DOMAIN  /tmp/resolv.conf
DNS_SERVERS=$DNS_SERVERS 127.0.0.1
for DNS_SERVER in $DNS_SERVERS ; do
@@ -400,7 +403,8 @@ start() {
 }
 
 stop() {
-   [ -f /tmp/resolv.conf ]  {
+   [ -f /tmp/resolv.conf ]  \
+   [ `head -n1 /tmp/resolv.conf` = ### Created by dnsmasq.init ### ] 
 {
rm -f /tmp/resolv.conf
ln -s /tmp/resolv.conf.auto /tmp/resolv.conf
}
-- 
1.7.4.1

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH 2/2] dnsmasq: add option to avoid modifying resolv.conf

2011-04-08 Thread Linus Lüssing
PS: I'm not so happy with this long uci option name,
'resolvconfuntouched', but couldn't come up with anything better
yet. Something like 'upstreaminsteadoflocaldnsserver' would be
more descriptive but, well, even longer...
Suggestions (and feedback for this patch in general) welcome :).
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel