dnsmasq: fix backward compatibility with existing configs
authorJo-Philipp Wich <jow@openwrt.org>
Mon, 4 Nov 2013 22:40:56 +0000 (22:40 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Mon, 4 Nov 2013 22:40:56 +0000 (22:40 +0000)
Changeset r36943 ("dnsmasq: use host-record instead of address") removed
the automatic domain expansion for config domain sections, this breaks
existing setups and alters the old behaviour in unexpected ways, therfore
restore behaviour of the current stable release.

Additionally handle fully qualified hostnames properly when setting up the
own hostrecord by stripping the local domain part form the given name
instead of unconditionally appending it, so that "example.lan" results
in "example example.lan" and not "example.lan example.lan.lan".

SVN-Revision: 38648

package/network/services/dnsmasq/Makefile
package/network/services/dnsmasq/files/dnsmasq.init

index ae3662b3f592915802cf322a7974e9a8d1541819..02712bdc7d304a960f0fa586418a92bd19a97af3 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=dnsmasq
 PKG_VERSION:=2.66
-PKG_RELEASE:=4
+PKG_RELEASE:=5
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=http://thekelleys.org.uk/dnsmasq
index 561f89d33d6a779373392c41f040fe2f44a4ac9c..ca3bb5248e4803a22efa703ab6a623322d26b14a 100644 (file)
@@ -408,6 +408,9 @@ dhcp_domain_add() {
        [ -n "$ip" ] || return 0
 
        for name in $names; do
+               [ "${name%.*}" == "$name" ] && \
+                       name="$name${DOMAIN:+.$DOMAIN}"
+
                record="${record:+$record/}$name"
        done
 
@@ -531,7 +534,7 @@ start_service() {
        # add own hostname
        [ $ADD_LOCAL_HOSTNAME -eq 1 ] && [ -n "$lanaddr" ] && {
                local hostname="$(uci_get system @system[0] hostname OpenWrt)"
-               dhcp_hostrecord_add "" "$hostname${DOMAIN:+.$DOMAIN $hostname}" "$lanaddr"
+               dhcp_hostrecord_add "" "${hostname%.$DOMAIN}${DOMAIN:+.$DOMAIN ${hostname%.$DOMAIN}}" "$lanaddr"
        }
 
        echo >> $CONFIGFILE