]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#642,!373] Do not allow to update the logical server 'all'.
authorMarcin Siodelski <marcin@isc.org>
Tue, 25 Jun 2019 17:10:13 +0000 (19:10 +0200)
committerMarcin Siodelski <marcin@isc.org>
Thu, 27 Jun 2019 18:51:31 +0000 (14:51 -0400)
src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.h
src/hooks/dhcp/mysql_cb/mysql_cb_dhcp6.h
src/hooks/dhcp/mysql_cb/mysql_cb_impl.cc
src/hooks/dhcp/mysql_cb/mysql_cb_impl.h
src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp4_unittest.cc
src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp6_unittest.cc

index afda51a52b8d81110422723c175ea3e76e761518..e0f9e05baf24c431368cd1e64f3abfc9d52cbbd9 100644 (file)
@@ -329,6 +329,8 @@ public:
     /// @brief Creates or updates a server.
     ///
     /// @param server Instance of the server to be stored.
+    /// @throw InvalidOperation when trying to create a duplicate or
+    /// update the logical server 'all'.
     virtual void
     createUpdateServer4(const db::ServerPtr& server);
 
index 1e8983f6e3e108c0191fa62c5472bdec103a8342..ac126d735d70adab6c6936009701496edf67fa6e 100644 (file)
@@ -344,6 +344,8 @@ public:
     /// @brief Creates or updates a server.
     ///
     /// @param server Instance of the server to be stored.
+    /// @throw InvalidOperation when trying to create a duplicate or
+    /// update the logical server 'all'.
     virtual void
     createUpdateServer6(const db::ServerPtr& server);
 
index 30301fc0dfd24f51b9bd6dbfeca647c6a617c0be..8e761e2e20aa941bba1682a3f93befcfdda723ac 100644 (file)
@@ -934,6 +934,13 @@ MySqlConfigBackendImpl::createUpdateServer(const int& create_audit_revision,
                                            const int& create_index,
                                            const int& update_index,
                                            const ServerPtr& server) {
+    // The server tag 'all' is reserved.
+    if (server->getServerTag().amAll()) {
+        isc_throw(InvalidOperation, "'all' is a name reserved for the server tag which"
+                  " associates the configuration elements with all servers connecting"
+                  " to the database and a server with this name can't be created");
+    }
+
     // Create scoped audit revision. As long as this instance exists
     // no new audit revisions are created in any subsequent calls.
     ScopedAuditRevision audit_revision(this,
index f910af865ba2b1a396e29cb153b7933921c1d92a..ad584b82c4e041ed8f20d6afb5306a41a944c932 100644 (file)
@@ -643,6 +643,8 @@ public:
     /// @param create_index Index of the INSERT query to be used.
     /// @param update_index Index of the UPDATE query to be used.
     /// @param server Pointer to the server to be inserted or updated.
+    /// @throw InvalidOperation when trying to create a duplicate or
+    /// update the logical server 'all'.
     void createUpdateServer(const int& create_audit_revision,
                             const int& create_index,
                             const int& update_index,
index 5c2d874664b3ad34c3ed09ae20bc96a4b3e58c9f..8175ad75ae7c9976c077c0141e41e1f3f95db16a 100644 (file)
@@ -468,6 +468,11 @@ TEST_F(MySqlConfigBackendDHCPv4Test, createUpdateDeleteServer) {
                           "server set");
     }
 
+    // It should not be possible to create a duplicate of the logical
+    // server 'all'.
+    auto all_server = Server::create(ServerTag("all"), "this is logical server all");
+    EXPECT_THROW(cbptr_->createUpdateServer4(all_server), isc::InvalidOperation);
+
     ServerPtr returned_server;
 
     // An attempt to fetch the server that hasn't been inserted should return
index f6636112c2709e486dbfd8b297bb4f495dbbf32f..78ac3b5012ee3749ac286a95bfc37b8bc60e9222 100644 (file)
@@ -509,6 +509,11 @@ TEST_F(MySqlConfigBackendDHCPv6Test, createUpdateDeleteServer) {
                           "server set");
     }
 
+    // It should not be possible to create a duplicate of the logical
+    // server 'all'.
+    auto all_server = Server::create(ServerTag("all"), "this is logical server all");
+    EXPECT_THROW(cbptr_->createUpdateServer6(all_server), isc::InvalidOperation);
+
     ServerPtr returned_server;
 
     // An attempt to fetch the server that hasn't been inserted should return