aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Crispin <blogic@openwrt.org>2014-09-01 13:22:06 +0000
committerJohn Crispin <blogic@openwrt.org>2014-09-01 13:22:06 +0000
commit16ef0d21d097b1c978f913c69c6ebf5e9e37e4cd (patch)
tree74b63d6005761e6477f1ce56dd1f71e87981686b
parente92a953a03702ab2f71ed6fc9477f3971f7afda7 (diff)
downloadupstream-16ef0d21d097b1c978f913c69c6ebf5e9e37e4cd.tar.gz
upstream-16ef0d21d097b1c978f913c69c6ebf5e9e37e4cd.tar.bz2
upstream-16ef0d21d097b1c978f913c69c6ebf5e9e37e4cd.zip
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 git-svn-id: svn://svn.openwrt.org/openwrt/branches/barrier_breaker@42389 3c298f89-4303-0410-b956-a3cf2f4a3e73
-rw-r--r--package/network/services/dnsmasq/files/dnsmasq.init10
1 files changed, 5 insertions, 5 deletions
diff --git a/package/network/services/dnsmasq/files/dnsmasq.init b/package/network/services/dnsmasq/files/dnsmasq.init
index c2704e4b9a..06d8c840fb 100644
--- a/package/network/services/dnsmasq/files/dnsmasq.init
+++ b/package/network/services/dnsmasq/files/dnsmasq.init
@@ -293,6 +293,11 @@ dhcp_host_add() {
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 @@ dhcp_host_add() {
[ "$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() {