From 2ac21bd793946a214295b760cd652b4150d3dc07 Mon Sep 17 00:00:00 2001 From: Daniel Dickinson Date: Wed, 16 Dec 2015 21:23:03 -0500 Subject: [PATCH] dnsmasq: Set the default dhcp lease file and resolv file Instead of making assumptions about the leasefile and resolv file make sure we use what the user configures, but fall back to defaults if no configuration is specified Signed-off-by: Daniel Dickinson --- .../network/services/dnsmasq/files/dnsmasq.init | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/package/network/services/dnsmasq/files/dnsmasq.init b/package/network/services/dnsmasq/files/dnsmasq.init index bb675ad73f..0360548e0d 100644 --- a/package/network/services/dnsmasq/files/dnsmasq.init +++ b/package/network/services/dnsmasq/files/dnsmasq.init @@ -72,8 +72,9 @@ append_parm() { local section="$1" local option="$2" local switch="$3" + local default="$4" local _loctmp - config_get _loctmp "$section" "$option" + config_get _loctmp "$section" "$option" "$default" [ -z "$_loctmp" ] && return 0 xappend "$switch=$_loctmp" } @@ -157,8 +158,8 @@ dnsmasq() { config_list_foreach "$cfg" "notinterface" append_notinterface config_list_foreach "$cfg" "addnhosts" append_addnhosts config_list_foreach "$cfg" "bogusnxdomain" append_bogusnxdomain - append_parm "$cfg" "leasefile" "--dhcp-leasefile" - append_parm "$cfg" "resolvfile" "--resolv-file" + append_parm "$cfg" "leasefile" "--dhcp-leasefile" "/tmp/dhcp.leases" + append_parm "$cfg" "resolvfile" "--resolv-file" "/tmp/resolv.conf.auto" append_parm "$cfg" "serversfile" "--servers-file" append_parm "$cfg" "tftp_root" "--tftp-root" append_parm "$cfg" "dhcp_boot" "--dhcp-boot" @@ -173,10 +174,17 @@ dnsmasq() { config_get_bool readethers "$cfg" readethers [ "$readethers" = "1" -a \! -e "/etc/ethers" ] && touch /etc/ethers - config_get leasefile $cfg leasefile + config_get leasefile $cfg leasefile "/tmp/dhcp.leases" [ -n "$leasefile" -a \! -e "$leasefile" ] && touch "$leasefile" config_get_bool cachelocal "$cfg" cachelocal 1 + config_get_bool noresolv "$cfg" noresolv 0 + if [ "$noresolv" != "1" ]; then + config_get resolvfile "$cfg" resolvfile "/tmp/resolv.conf.auto" + # So jail doesn't complain if file missing + [ -n "$resolvfile" -a \! -e "$resolvfile" ] && touch "$resolvfile" + fi + config_get hostsfile "$cfg" dhcphostsfile [ -e "$hostsfile" ] && xappend "--dhcp-hostsfile=$hostsfile" -- 2.25.1