]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3477] Making socket name/address exclusive (1)
authorFrancis Dupont <fdupont@isc.org>
Tue, 23 Jul 2024 13:57:34 +0000 (15:57 +0200)
committerFrancis Dupont <fdupont@isc.org>
Thu, 1 Aug 2024 07:23:54 +0000 (09:23 +0200)
doc/examples/ddns/all-keys.json
doc/examples/kea4/all-keys.json
doc/examples/kea6/all-keys.json
src/bin/d2/d2_parser.yy
src/bin/dhcp4/dhcp4_parser.yy
src/bin/dhcp6/dhcp6_parser.yy
src/lib/config/http_command_config.cc
src/lib/config/http_command_mgr.cc
src/lib/config/tests/http_command_config_unittests.cc

index 48da3b1a7bb56a1e051f7f60dcd2c20d87fb6bbc..b9015d871366e9bcce0c8088bff658f97f6bc5b2 100644 (file)
@@ -52,8 +52,7 @@
             "socket-type": "https",
 
             // Address of the HTTPS socket the Kea DHCP-DDNS server should
-            // listen for incoming queries. In fact an alias of
-            // socket-name.
+            // listen for incoming queries.
             "socket-address": "127.0.0.1",
 
             // Port of the HTTPS socket the Kea DHCP-DDNS server
index c23b05466efe2fd7bbe2677672291a3cb34ea196..9ea1234fe8ee0a543783c4856ddb8351a912fa18 100644 (file)
                 "socket-type": "https",
 
                 // Address of the HTTPS socket the Kea DHCPv4 server should
-                // listen for incoming queries. In fact an alias of
-                // socket-name.
+                // listen for incoming queries.
                 "socket-address": "127.0.0.1",
 
                 // Port of the HTTPS socket the Kea DHCPv4 server
index 2fb754311c243b7db295bc1cbc65da820548184a..1a7cadc1c818fa9012c45b496deff3e746210cc3 100644 (file)
                 "socket-type": "https",
 
                 // Address of the HTTPS socket the Kea DHCPv6 server should
-                // listen for incoming queries. In fact an alias of
-                // socket-name.
+                // listen for incoming queries.
                 "socket-address": "::1",
 
                 // Port of the HTTPS socket the Kea DHCPv6 server
index cf8a114d90bbf4cdb41d81d35fce123957ab95d2..6a22eac112c871a7ac0f37bd2c425d7f910799cc 100644 (file)
@@ -844,6 +844,7 @@ control_socket_type_value:
 
 control_socket_name: SOCKET_NAME {
     ctx.unique("socket-name", ctx.loc2pos(@1));
+    ctx.unique("socket-address", ctx.loc2pos(@1));
     ctx.enter(ctx.NO_KEYWORD);
 } COLON STRING {
     ElementPtr name(new StringElement($4, ctx.loc2pos(@4)));
@@ -853,6 +854,7 @@ control_socket_name: SOCKET_NAME {
 
 control_socket_address: SOCKET_ADDRESS {
     ctx.unique("socket-address", ctx.loc2pos(@1));
+    ctx.unique("socket-name", ctx.loc2pos(@1));
     ctx.enter(ctx.NO_KEYWORD);
 } COLON STRING {
     ElementPtr address(new StringElement($4, ctx.loc2pos(@4)));
index d41c568694e3cd4eb7ceb0b0905ef696a1ca607a..aae280835773c5c44d6b653a11481cd45ee25056 100644 (file)
@@ -2591,6 +2591,7 @@ control_socket_type_value:
 
 control_socket_name: SOCKET_NAME {
     ctx.unique("socket-name", ctx.loc2pos(@1));
+    ctx.unique("socket-address", ctx.loc2pos(@1));
     ctx.enter(ctx.NO_KEYWORD);
 } COLON STRING {
     ElementPtr name(new StringElement($4, ctx.loc2pos(@4)));
@@ -2600,6 +2601,7 @@ control_socket_name: SOCKET_NAME {
 
 control_socket_address: SOCKET_ADDRESS {
     ctx.unique("socket-address", ctx.loc2pos(@1));
+    ctx.unique("socket-name", ctx.loc2pos(@1));
     ctx.enter(ctx.NO_KEYWORD);
 } COLON STRING {
     ElementPtr address(new StringElement($4, ctx.loc2pos(@4)));
index a4061722d68be3e1855e757635f514bd3d6bc852..a09f50cb72867aab65317e2aeae51bed95588e0f 100644 (file)
@@ -2720,6 +2720,7 @@ control_socket_type_value:
 
 control_socket_name: SOCKET_NAME {
     ctx.unique("socket-name", ctx.loc2pos(@1));
+    ctx.unique("socket-address", ctx.loc2pos(@1));
     ctx.enter(ctx.NO_KEYWORD);
 } COLON STRING {
     ElementPtr name(new StringElement($4, ctx.loc2pos(@4)));
@@ -2729,6 +2730,7 @@ control_socket_name: SOCKET_NAME {
 
 control_socket_address: SOCKET_ADDRESS {
     ctx.unique("socket-address", ctx.loc2pos(@1));
+    ctx.unique("socket-name", ctx.loc2pos(@1));
     ctx.enter(ctx.NO_KEYWORD);
 } COLON STRING {
     ElementPtr address(new StringElement($4, ctx.loc2pos(@4)));
index e9af0586642d1ba6fa9abccf70a1d21144677709..684c9dedda8c6d7dc02f703230291b3036023ae9 100644 (file)
@@ -51,24 +51,18 @@ HttpCommandConfig::HttpCommandConfig(ConstElementPtr config)
                       << socket_type_ << "' not 'http' or 'https'");
         }
     }
-
+    // Reject UNIX only socket-name.
+    if (config->contains("socket-name")) {
+        isc_throw(DhcpConfigError,
+                  "parameter 'socket-name' is not supported by HTTP "
+                  "control sockets");
+    }
     // Get socket address.
-    ConstElementPtr socket_name = config->get("socket-name");
     ConstElementPtr socket_address = config->get("socket-address");
-    if (socket_name) {
-        // socket-name is an alias of socket-address.
-        if (socket_address) {
-            isc_throw(DhcpConfigError,
-                      "specify both 'socket-name' and 'socket-address' "
-                      "is forbidden");
-        }
-        socket_address = socket_name;
-    }
     if (socket_address) {
         if (socket_address->getType() != Element::string) {
             isc_throw(DhcpConfigError,
-                      "invalid type specified for parameter 'socket-"
-                      << (socket_name ? "name" : "address") << "' ("
+                      "invalid type specified for parameter 'socket-address' ("
                       << socket_address->getPosition() << ")");
         }
         try {
index 1d860c68e75988591e421d78e23e46720a7957fa..d88f0be719f58568cd0f78e7804f2adcc958b221 100644 (file)
@@ -92,7 +92,7 @@ HttpCommandMgrImpl::configure(HttpCommandConfigPtr config) {
             (config->getCertRequired() != current_config_->getCertRequired())) {
             LOG_WARN(command_logger, HTTP_COMMAND_MGR_IGNORED_TLS_SETUP_CHANGES);
             // Overwrite the authentication setup and the emulation flag
-            //in the response creator config.
+            // in the response creator config.
             current_config_->setAuthConfig(config->getAuthConfig());
             current_config_->setEmulateAgentResponse(config->getEmulateAgentResponse());
         } else {
index afb9a755dd73ce57b23b2f6084a2dbc68256845a..dc8c09611109c91ce37c79a8c4cc0eec5dfe8c0b 100644 (file)
@@ -102,16 +102,9 @@ TEST_F(HttpCommandConfigTest, errors) {
             "unsupported 'socket-type' 'unix' not 'http' or 'https'"
         },
         {
-            "both socket-name and socket-address",
-            R"( { "socket-name": "::1", "socket-address": "::1" } )",
-            "specify both 'socket-name' and 'socket-address' "
-            "is forbidden"
-        },
-        {
-            "bad socket-name type",
-            R"( { "socket-name": 8000 } )",
-            "invalid type specified for parameter 'socket-name' "
-            "(<string>:1:19)"
+            "unsupported socket-name",
+            R"( { "socket-name": "::1" } )",
+            "parameter 'socket-name' is not supported by HTTP control sockets"
         },
         {
             "bad socket-address type",