From: Marcin Siodelski Date: Tue, 25 Mar 2014 16:16:07 +0000 (+0100) Subject: [3360] Fix dbaccess parser to use "persist" value as boolean. X-Git-Tag: bind10-1.2.0rc1-release~14^2~7 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8b5ded2f871bd67584c67a380c9736baeb9c246d;p=thirdparty%2Fkea.git [3360] Fix dbaccess parser to use "persist" value as boolean. --- diff --git a/src/lib/dhcpsrv/dbaccess_parser.cc b/src/lib/dhcpsrv/dbaccess_parser.cc index 743d8a37ba..afd2c07e51 100644 --- a/src/lib/dhcpsrv/dbaccess_parser.cc +++ b/src/lib/dhcpsrv/dbaccess_parser.cc @@ -58,7 +58,15 @@ DbAccessParser::build(isc::data::ConstElementPtr config_value) { // 3. Update the copy with the passed keywords. BOOST_FOREACH(ConfigPair param, config_value->mapValue()) { - values_copy[param.first] = param.second->stringValue(); + // The persist parameter is the only boolean parameter at the + // moment. It needs special handling. + if (param.first != "persist") { + values_copy[param.first] = param.second->stringValue(); + + } else { + values_copy[param.first] = (param.second->boolValue() ? + "true" : "false"); + } } // 4. Perform validation checks on the updated set of keyword/values. diff --git a/src/lib/dhcpsrv/tests/dbaccess_parser_unittest.cc b/src/lib/dhcpsrv/tests/dbaccess_parser_unittest.cc index a9a3590d15..555b86b9a5 100644 --- a/src/lib/dhcpsrv/tests/dbaccess_parser_unittest.cc +++ b/src/lib/dhcpsrv/tests/dbaccess_parser_unittest.cc @@ -87,8 +87,14 @@ public: } // Add the keyword and value - make sure that they are quoted. - result += quote + keyval[i] + quote + colon + space + - quote + keyval[i + 1] + quote; + // The only parameter which is not quoted is persist as it + // is a boolean value. + result += quote + keyval[i] + quote + colon + space; + if (keyval[i] != "persist") { + result += quote + keyval[i + 1] + quote; + } else { + result += keyval[i + 1]; + } } // Add the terminating brace