From ad4b3de3843122988a9e022be941b8bc4f27a482 Mon Sep 17 00:00:00 2001 From: Alex Oprea Date: Tue, 23 Aug 2016 14:40:10 +0200 Subject: [PATCH] owsd: fix loading of dhcp entries refs #9908 - config_load dhcp was called while parsing owsd config, thus overwritting the latter. - fixed this by loading and parsing the dhcp config before loading and parsing the owsd config. - this issue resulted in owsd not loading the config for wan:80, thus no gui available, refs #9908. --- owsd/files/owsd.init | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/owsd/files/owsd.init b/owsd/files/owsd.init index 2409e5922..215e3334f 100644 --- a/owsd/files/owsd.init +++ b/owsd/files/owsd.init @@ -9,6 +9,26 @@ USE_PROCD=1 PROG=/usr/bin/owsd CONFIGFILE="/etc/config/owsd" +DHCP_DOMAINS="" + +load_dhcp_domains() { + + append_domain() { + local domain=$1 + DHCP_DOMAINS="$DHCP_DOMAINS $domain" + } + + dhcp_domain_section() { + local section=$1 + local ip + config_get ip "$section" ip + [ -z "$ip" ] && config_list_foreach "$section" "name" append_domain + } + + config_load dhcp # note: do not overload a config while parsing it + config_foreach dhcp_domain_section "domain" +} + validate_owsd() { uci_validate_section "owsd" "owsd" "global" \ 'sock:string' \ @@ -88,23 +108,19 @@ parse_owsd_iface() { config_list_foreach "$1" "origin" append_origin if [ -n "$whitelist_dhcp_domains" ]; then - append_domain() { - append_origin_parts "http${cert:+s}" "$1" "${port}" - } - - dhcp_domain_section() { - local ip - config_get ip "$1" ip - [ -z "$ip" ] && config_list_foreach "$1" "name" append_domain - } - - config_load dhcp - config_foreach dhcp_domain_section "domain" + http="http${cert:+s}" + for domain in $DHCP_DOMAINS; do + append_origin_parts "$http" "$domain" "$port" + done fi } start_service() { - config_load owsd + + # preload dhcp domains list, in case any interface config requires it + load_dhcp_domains + + config_load owsd # note: do not overload a config while parsing it procd_open_instance procd_set_param command $PROG