Author: blogic
Date: 2014-09-01 15:22:06 +0200 (Mon, 01 Sep 2014)
New Revision: 42389

Modified:
   branches/barrier_breaker/package/network/services/dnsmasq/files/dnsmasq.init
Log:
dnsmasq: Fix hosts file format when MAC address is not specified

An entry like this in /etc/config/dhcp:

    config 'host'
        option 'name' 'pc2'
        option 'ip' '192.168.100.56'
        option 'dns' '1'

results in a /tmp/hosts/dhcp entry that looks like this:

    192.168.100.56 .lan

Obviously it should say "pc2.lan".

This happens because $name is set to "" in order to support the MAC-less
syntax: "--dhcp-host=lap,192.168.0.199".  Fix this by reordering the
operations.  Also, refuse to add a DNS entry if the hostname or IP is
missing.

Fixes #17683

Reported-by: Kostas Papadopoulos <[email protected]>
Signed-off-by: Kevin Cernekee <[email protected]>

Backport of r42319

Modified: 
branches/barrier_breaker/package/network/services/dnsmasq/files/dnsmasq.init
===================================================================
--- 
branches/barrier_breaker/package/network/services/dnsmasq/files/dnsmasq.init    
    2014-09-01 13:22:05 UTC (rev 42388)
+++ 
branches/barrier_breaker/package/network/services/dnsmasq/files/dnsmasq.init    
    2014-09-01 13:22:06 UTC (rev 42389)
@@ -293,6 +293,11 @@
        config_get ip "$cfg" ip
        [ -n "$ip" -o -n "$name" ] || return 0
 
+       config_get_bool dns "$cfg" dns 0
+       [ "$dns" = "1" -a -n "$ip" -a -n "$name" ] && {
+               echo "$ip $name${DOMAIN:+.$DOMAIN}" >> $HOSTFILE
+       }
+
        config_get mac "$cfg" mac
        [ -z "$mac" ] && {
                [ -n "$name" ] || return 0
@@ -309,11 +314,6 @@
        [ "$broadcast" = "0" ] && broadcast=
 
        xappend 
"--dhcp-host=$macs${networkid:+,net:$networkid}${broadcast:+,set:needs-broadcast}${tag:+,set:$tag}${ip:+,$ip}${name:+,$name}"
-
-       config_get_bool dns "$cfg" dns 0
-       [ "$dns" = "1" ] && {
-               echo "$ip $name${DOMAIN:+.$DOMAIN}" >> $HOSTFILE
-       }
 }
 
 dhcp_tag_add() {
_______________________________________________
openwrt-commits mailing list
[email protected]
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-commits

Reply via email to