From: Thomas Markwalder Date: Thu, 26 Jun 2014 15:58:00 +0000 (-0400) Subject: [3436] Found a couple of spots missig position info X-Git-Tag: trac3473_base~5^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c7d730d7c237022ce6c59ab2cb214bf20a1f3e20;p=thirdparty%2Fkea.git [3436] Found a couple of spots missig position info --- diff --git a/src/bin/d2/d2_cfg_mgr.cc b/src/bin/d2/d2_cfg_mgr.cc index c7571b525f..0739a0f4e4 100644 --- a/src/bin/d2/d2_cfg_mgr.cc +++ b/src/bin/d2/d2_cfg_mgr.cc @@ -206,12 +206,21 @@ D2CfgMgr::buildParams(isc::data::ConstElementPtr params_config) { // We validate them here rather than just relying on D2Param constructor // so we can spit out config text position info with errors. - // Fetch and validate io_address. + // Fetch and validate ip_address. D2CfgContextPtr context = getD2CfgContext(); isc::dhcp::StringStoragePtr strings = context->getStringStorage(); - asiolink::IOAddress ip_address(strings-> - getOptionalParam("ip_address", - D2Params::DFT_IP_ADDRESS)); + asiolink::IOAddress ip_address(D2Params::DFT_IP_ADDRESS); + + std::string ip_address_str = strings->getOptionalParam("ip_address", + D2Params:: + DFT_IP_ADDRESS); + try { + ip_address = asiolink::IOAddress(ip_address_str); + } catch (const std::exception& ex) { + isc_throw(D2CfgError, "IP address invalid : \"" + << ip_address_str << "\" : " + << strings->getPosition("ip_address")); + } if ((ip_address.toText() == "0.0.0.0") || (ip_address.toText() == "::")) { isc_throw(D2CfgError, "IP address cannot be \"" << ip_address << "\" : " diff --git a/src/bin/d2/d2_config.cc b/src/bin/d2/d2_config.cc index ddc2f84096..aeb9d69bf8 100644 --- a/src/bin/d2/d2_config.cc +++ b/src/bin/d2/d2_config.cc @@ -643,7 +643,8 @@ build(isc::data::ConstElementPtr server_list){ // Domains must have at least one server. if (parsers_.size() == 0) { - isc_throw (D2CfgError, "Server List must contain at least one server"); + isc_throw (D2CfgError, "Server List must contain at least one server" + << " : " << server_list->getPosition()); } } diff --git a/src/bin/d2/d_cfg_mgr.cc b/src/bin/d2/d_cfg_mgr.cc index a6e61bf0e2..7abc0e44c1 100644 --- a/src/bin/d2/d_cfg_mgr.cc +++ b/src/bin/d2/d_cfg_mgr.cc @@ -206,9 +206,10 @@ DCfgMgrBase::parseConfig(isc::data::ConstElementPtr config_set) { objects_map.erase(it); } else { - isc_throw(DCfgMgrBaseError, "Element:" << element_id << - " is listed in the parse order but is not " - " present in the configuration"); + isc_throw(DCfgMgrBaseError, + "Element required by parsing order is missing: " + << element_id << " : " + << config_set->getPosition()); } } diff --git a/src/bin/d2/tests/testdata/d2_cfg_tests.json b/src/bin/d2/tests/testdata/d2_cfg_tests.json index fb41102137..4a7bfbde0a 100644 --- a/src/bin/d2/tests/testdata/d2_cfg_tests.json +++ b/src/bin/d2/tests/testdata/d2_cfg_tests.json @@ -849,6 +849,33 @@ } } +#----- +,{ +"description" : "D2.forward_ddns.dhcp_ddns.dns_servers.ip_address invalid address ", +"should_fail" : true, +"data" : + { + "forward_ddns" : + { + "ddns_domains" : + [ + { + "name" : "four.example.com.", + "dns_servers" : + [ + { + "ip_address" : "bogus" + } + ] + } + ] + }, + "reverse_ddns" : {}, + "tsig_keys" : [] + } +} + + #----- ,{ "description" : "D2.forward_ddns.dhcp_ddns.dns_servers.port valid value ", @@ -1215,6 +1242,32 @@ "tsig_keys" : [] } } +#----- +,{ +"description" : "D2.reverse_ddns.dhcp_ddns.dns_servers.ip_address invalid value", +"should_fail" : true, +"data" : + { + "forward_ddns" : {}, + "reverse_ddns" : + { + "ddns_domains" : + [ + { + "name" : "2.0.192.in-addr.arpa.", + "dns_servers" : + [ + { + "ip_address" : "bogus" + } + ] + } + ] + }, + "tsig_keys" : [] + } +} + #----- ,{