dnsmasq: add dhcp-ignore-names support - CERT VU#598349
[openwrt/openwrt.git] / package / network / services / dnsmasq / files / dnsmasq.init
index c1ae0934fd2c466687c80f7ae7f6fa567e4474fa..0c786e82c7a1dd13f3aecf65eef346a09c95a2c3 100644 (file)
@@ -16,6 +16,7 @@ BASEHOSTFILE="/tmp/hosts/dhcp"
 TRUSTANCHORSFILE="/usr/share/dnsmasq/trust-anchors.conf"
 TIMEVALIDFILE="/var/state/dnsmasqsec"
 BASEDHCPSTAMPFILE="/var/run/dnsmasq"
+DHCPBOGUSHOSTNAMEFILE="/usr/share/dnsmasq/dhcpbogushostname.conf"
 RFC6761FILE="/usr/share/dnsmasq/rfc6761.conf"
 DHCPSCRIPT="/usr/lib/dnsmasq/dhcp-script.sh"
 
@@ -813,6 +814,7 @@ dnsmasq_start()
        append_bool "$cfg" localise_queries "--localise-queries"
        append_bool "$cfg" readethers "--read-ethers"
        append_bool "$cfg" dbus "--enable-dbus"
+       append_bool "$cfg" ubus "--enable-ubus" 1
        append_bool "$cfg" expandhosts "--expand-hosts"
        config_get tftp_root "$cfg" "tftp_root"
        [ -n "$tftp_root" ] && mkdir -p "$tftp_root" && append_bool "$cfg" enable_tftp "--enable-tftp"
@@ -869,9 +871,6 @@ dnsmasq_start()
                ADD_LOCAL_FQDN="$ADD_LOCAL_HOSTNAME"
        fi
 
-       config_get_bool readethers "$cfg" readethers
-       [ "$readethers" = "1" -a \! -e "/etc/ethers" ] && touch /etc/ethers
-
        config_get user_dhcpscript $cfg dhcpscript
        if has_handler || [ -n "$user_dhcpscript" ]; then
                xappend "--dhcp-script=$DHCPSCRIPT"
@@ -958,6 +957,13 @@ dnsmasq_start()
 
        config_foreach filter_dnsmasq host dhcp_host_add "$cfg"
        echo >> $CONFIGFILE_TMP
+
+       config_get_bool dhcpbogushostname "$cfg" dhcpbogushostname 1
+       [ "$dhcpbogushostname" -gt 0 ] && {
+               xappend "--dhcp-ignore-names=tag:dhcp_bogus_hostname"
+               [ -r "$DHCPBOGUSHOSTNAMEFILE" ] && xappend "--conf-file=$DHCPBOGUSHOSTNAMEFILE"
+       }
+
        config_foreach filter_dnsmasq boot dhcp_boot_add "$cfg"
        config_foreach filter_dnsmasq mac dhcp_mac_add "$cfg"
        config_foreach filter_dnsmasq tag dhcp_tag_add "$cfg"