Changeset 42389


Ignore:
Timestamp:
2014-09-01T15:22:06+02:00 (3 years ago)
Author:
blogic
Message:

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@…>
Signed-off-by: Kevin Cernekee <cernekee@…>

Backport of r42319

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/barrier_breaker/package/network/services/dnsmasq/files/dnsmasq.init

    r42388 r42389  
    294294        [ -n "$ip" -o -n "$name" ] || return 0 
    295295 
     296        config_get_bool dns "$cfg" dns 0 
     297        [ "$dns" = "1" -a -n "$ip" -a -n "$name" ] && { 
     298                echo "$ip $name${DOMAIN:+.$DOMAIN}" >> $HOSTFILE 
     299        } 
     300 
    296301        config_get mac "$cfg" mac 
    297302        [ -z "$mac" ] && { 
     
    310315 
    311316        xappend "--dhcp-host=$macs${networkid:+,net:$networkid}${broadcast:+,set:needs-broadcast}${tag:+,set:$tag}${ip:+,$ip}${name:+,$name}" 
    312  
    313         config_get_bool dns "$cfg" dns 0 
    314         [ "$dns" = "1" ] && { 
    315                 echo "$ip $name${DOMAIN:+.$DOMAIN}" >> $HOSTFILE 
    316         } 
    317317} 
    318318 
Note: See TracChangeset for help on using the changeset viewer.