dnsmasq: Fix hosts file format when MAC address is not specified
authorJohn Crispin <john@openwrt.org>
Mon, 1 Sep 2014 13:22:06 +0000 (13:22 +0000)
committerJohn Crispin <john@openwrt.org>
Mon, 1 Sep 2014 13:22:06 +0000 (13:22 +0000)
commit04fd688d54dff69e848f124ac76425da0387f1c0
tree74b63d6005761e6477f1ce56dd1f71e87981686b
parent2a510a9a94b57fd5622f1519d53df66488903016
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 <kpapad75@travelguide.gr>
Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Backport of r42319

SVN-Revision: 42389
package/network/services/dnsmasq/files/dnsmasq.init