diff options
author | Hans Dedecker <dedeckeh@gmail.com> | 2017-04-26 22:37:27 +0200 |
---|---|---|
committer | Hans Dedecker <dedeckeh@gmail.com> | 2017-05-09 22:39:41 +0200 |
commit | d8cfebaa5074b66871a345386f7f49bffbad1d15 (patch) | |
tree | 03273e0b6614b88c13e9e6b63c8313153d607065 /package/network/services/dnsmasq/files/dnsmasq.init | |
parent | d1e0cc8cd5b460df47a2316653c273e27ebf93b1 (diff) | |
download | upstream-d8cfebaa5074b66871a345386f7f49bffbad1d15.tar.gz upstream-d8cfebaa5074b66871a345386f7f49bffbad1d15.tar.bz2 upstream-d8cfebaa5074b66871a345386f7f49bffbad1d15.zip |
dnsmasq: support dhcp_option config as a list
Configuring dhcp_option as an option does not allow the usage of white
spaces in the option value; fix this by supporting dhcp_option as a list
config while still supporting the option config to maintain backwards
compatibility
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Diffstat (limited to 'package/network/services/dnsmasq/files/dnsmasq.init')
-rw-r--r-- | package/network/services/dnsmasq/files/dnsmasq.init | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/package/network/services/dnsmasq/files/dnsmasq.init b/package/network/services/dnsmasq/files/dnsmasq.init index 46607dfe25..bac5fd7a88 100644 --- a/package/network/services/dnsmasq/files/dnsmasq.init +++ b/package/network/services/dnsmasq/files/dnsmasq.init @@ -392,6 +392,14 @@ dhcp_add() { dhcp_option_add "$cfg" "$networkid" } +dhcp_option_append() { + local option="$1" + local networkid="$2" + local force="$3" + + xappend "--dhcp-option${force:+-force}=${networkid:+$networkid,}$option" +} + dhcp_option_add() { local cfg="$1" local networkid="$2" @@ -399,11 +407,21 @@ dhcp_option_add() { [ "$force" = "0" ] && force= - config_get dhcp_option "$cfg" dhcp_option - for o in $dhcp_option; do - xappend "--dhcp-option${force:+-force}=${networkid:+$networkid,}$o" - done + local list_len + config_get list_len "$cfg" dhcp_option_LENGTH + if [ -n "$list_len" ]; then + config_list_foreach "$cfg" dhcp_option dhcp_option_append "$networkid" "$force" + else + config_get dhcp_option "$cfg" dhcp_option + + [ -n "$dhcp_option" ] && echo "Warning: the 'option dhcp_option' syntax is deprecated, use 'list dhcp_option'" >&2 + + local option + for option in $dhcp_option; do + dhcp_option_append "$option" "$networkid" "$force" + done + fi } dhcp_domain_add() { |