]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[master] Updated control socket toElement (post-merge) trac5494_base trac5496_base
authorFrancis Dupont <fdupont@isc.org>
Sun, 31 Dec 2017 13:25:23 +0000 (14:25 +0100)
committerFrancis Dupont <fdupont@isc.org>
Sun, 31 Dec 2017 13:25:23 +0000 (14:25 +0100)
src/bin/dhcp4/tests/get_config_unittest.cc
src/bin/dhcp6/tests/get_config_unittest.cc
src/lib/dhcpsrv/srv_config.cc

index e6550ee1e7f99cb7783afc601e7e93760b41afb5..06056faedb43604608b6afb669099f78dcdc59f1 100644 (file)
@@ -1659,11 +1659,9 @@ const char* EXTRACTED_CONFIGS[] = {
 "            }\n"
 "        ],\n"
 "        \"control-socket\": {\n"
+"            \"comment\": \"Indirect comment\",\n"
 "            \"socket-name\": \"/tmp/kea4-ctrl-socket\",\n"
-"            \"socket-type\": \"unix\",\n"
-"            \"user-context\": {\n"
-"                \"comment\": \"Indirect comment\"\n"
-"            }\n"
+"            \"socket-type\": \"unix\"\n"
 "        },\n"
 "        \"dhcp-ddns\": {\n"
 "            \"comment\": \"No dynamic DNS\",\n"
@@ -6404,11 +6402,9 @@ const char* UNPARSED_CONFIGS[] = {
 "            }\n"
 "        ],\n"
 "        \"control-socket\": {\n"
+"            \"comment\": \"Indirect comment\",\n"
 "            \"socket-name\": \"/tmp/kea4-ctrl-socket\",\n"
-"            \"socket-type\": \"unix\",\n"
-"            \"user-context\": {\n"
-"                \"comment\": \"Indirect comment\"\n"
-"            }\n"
+"            \"socket-type\": \"unix\"\n"
 "        },\n"
 "        \"decline-probation-period\": 86400,\n"
 "        \"dhcp-ddns\": {\n"
index 19286b5ed0f90608d669585c6d03273d5dcbfd72..24b3529bfc65195187fcd38999d1bcd5fb3c971c 100644 (file)
@@ -1529,11 +1529,9 @@ const char* EXTRACTED_CONFIGS[] = {
 "            }\n"
 "        ],\n"
 "        \"control-socket\": {\n"
+"            \"comment\": \"Indirect comment\",\n"
 "            \"socket-name\": \"/tmp/kea6-ctrl-socket\",\n"
-"            \"socket-type\": \"unix\",\n"
-"            \"user-context\": {\n"
-"                \"comment\": \"Indirect comment\"\n"
-"            }\n"
+"            \"socket-type\": \"unix\"\n"
 "        },\n"
 "        \"dhcp-ddns\": {\n"
 "            \"comment\": \"No dynamic DNS\",\n"
@@ -6002,11 +6000,9 @@ const char* UNPARSED_CONFIGS[] = {
 "            }\n"
 "        ],\n"
 "        \"control-socket\": {\n"
+"            \"comment\": \"Indirect comment\",\n"
 "            \"socket-name\": \"/tmp/kea6-ctrl-socket\",\n"
-"            \"socket-type\": \"unix\",\n"
-"            \"user-context\": {\n"
-"                \"comment\": \"Indirect comment\"\n"
-"            }\n"
+"            \"socket-type\": \"unix\"\n"
 "        },\n"
 "        \"decline-probation-period\": 86400,\n"
 "        \"dhcp-ddns\": {\n"
index 0f17fcf5ed0dcc28c7a22ef49abb65382be46729..fef466d19f10b215038168592036440c05370e12 100644 (file)
@@ -363,7 +363,23 @@ SrvConfig::toElement() const {
     }
     // Set control-socket (skip if null as empty is not legal)
     if (!isNull(control_socket_)) {
-        dhcp->set("control-socket", control_socket_);
+        ElementPtr csocket = isc::data::copy(control_socket_);
+        ConstElementPtr ctx = csocket->get("user-context");
+        // Protect against not map
+        if (ctx && (ctx->getType() != Element::map)) {
+            ctx.reset();
+        }
+        // Extract comment
+        if (ctx && ctx->contains("comment")) {
+            ElementPtr ctx_copy = isc::data::copy(ctx);
+            csocket->set("comment", ctx_copy->get("comment"));
+            ctx_copy->remove("comment");
+            csocket->remove("user-context");
+            if (ctx_copy->size() > 0) {
+                csocket->set("user-context", ctx_copy);
+            }
+        }
+        dhcp->set("control-socket", csocket);
     }
     // Set client-classes
     ConstElementPtr client_classes = class_dictionary_->toElement();