BIND 10 trac925, updated. 62168918aceee04418765089cdc5fdfb34bf66a3 [trac925] TODO note

BIND 10 source code commits bind10-changes at lists.isc.org
Mon May 16 09:55:35 UTC 2011


The branch, trac925 has been updated
       via  62168918aceee04418765089cdc5fdfb34bf66a3 (commit)
       via  929a9cae2b351e67ac1953514a63b0c54095361c (commit)
      from  04ea273e2988cc405ae3ee7555a0f028258c17a5 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 62168918aceee04418765089cdc5fdfb34bf66a3
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Mon May 16 11:46:22 2011 +0200

    [trac925] TODO note

commit 929a9cae2b351e67ac1953514a63b0c54095361c
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Mon May 16 11:44:11 2011 +0200

    [trac925] Loading the key ring

-----------------------------------------------------------------------

Summary of changes:
 src/lib/server_common/keyring.cc            |   36 +++++++++++++++++++++++---
 src/lib/server_common/keyring.h             |    4 +++
 src/lib/server_common/tests/keyring_test.cc |   11 ++++---
 3 files changed, 41 insertions(+), 10 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/server_common/keyring.cc b/src/lib/server_common/keyring.cc
index d953fab..60f152e 100644
--- a/src/lib/server_common/keyring.cc
+++ b/src/lib/server_common/keyring.cc
@@ -14,21 +14,47 @@
 
 #include <server_common/keyring.h>
 
+using namespace isc::dns;
+using namespace isc::data;
+
 namespace isc {
 namespace server_common {
 
-boost::shared_ptr<dns::TSIGKeyRing> keyring;
+typedef boost::shared_ptr<TSIGKeyRing> KeyringPtr;
+
+KeyringPtr keyring;
+
+namespace {
+
+void
+updateKeyring(const std::string&, ConstElementPtr data) {
+    ConstElementPtr list(data->get("keys"));
+    KeyringPtr load(new TSIGKeyRing);
+    for (size_t i(0); i < list->size(); ++ i) {
+        load->add(TSIGKey(list->get(i)->stringValue()));
+    }
+    keyring.swap(load);
+}
+
+}
 
 void
 initKeyring(config::ModuleCCSession& session) {
-    // TODO
-    (void) session;
+    if (keyring) {
+        // We are already initialized
+        return;
+    }
+    session.addRemoteConfig("tsig_keys", updateKeyring);
 }
 
 void
 deinitKeyring(config::ModuleCCSession& session) {
-    // TODO
-    (void) session;
+    if (!keyring) {
+        // Not initialized, ignore it
+        return;
+    }
+    keyring.reset();
+    session.removeRemoteConfig("tsig_keys");
 }
 
 }
diff --git a/src/lib/server_common/keyring.h b/src/lib/server_common/keyring.h
index 6f80e88..8832095 100644
--- a/src/lib/server_common/keyring.h
+++ b/src/lib/server_common/keyring.h
@@ -82,6 +82,10 @@ initKeyring(config::ModuleCCSession& session);
  * This does nothing if the key ring is not loaded currently.
  *
  * \param session The configuration session used to talk to the config manager.
+ *
+ * \todo What do we do when the data that come are invalid? Should we ignore it,
+ *     as walidity should have been checked already in the config manager, or
+ *     throw? What about when we get an update and it's invalid?
  */
 void
 deinitKeyring(config::ModuleCCSession& session);
diff --git a/src/lib/server_common/tests/keyring_test.cc b/src/lib/server_common/tests/keyring_test.cc
index 075b659..6d2f226 100644
--- a/src/lib/server_common/tests/keyring_test.cc
+++ b/src/lib/server_common/tests/keyring_test.cc
@@ -51,7 +51,7 @@ public:
                                                 "/tsig_keys.spec").
                              getFullSpec()));
         session.getMessages()->add(createAnswer(0, Element::fromJSON(
-            "{\"keys\": [\"key:MTIzNAo=:sha1\"]}")));
+            "{\"keys\": [\"key:MTIzNAo=:hmac-sha1\"]}")));
         // Now load it
         EXPECT_NO_THROW(initKeyring(*mccs));
         EXPECT_NE(keyring, boost::shared_ptr<TSIGKeyRing>()) <<
@@ -74,9 +74,9 @@ TEST_F(KeyringTest, keyring) {
 
     {
         SCOPED_TRACE("Update");
-        session.getMessages()->add(createCommand("config_update",
-                                                 Element::fromJSON(
-            "{\"keys\": [\"another:MTIzNAo=:sha256\"]}")));
+        session.addMessage(createCommand("config_update", Element::fromJSON(
+            "{\"keys\": [\"another:MTIzNAo=:hmac-sha256\"]}")),
+                           "tsig_keys", "*");
         mccs->checkCommand();
 
         // Make sure it no longer contains the original key
@@ -114,12 +114,13 @@ TEST_F(KeyringTest, initTwice) {
             "it even throws at it";
     }
     EXPECT_EQ(backup, keyring) << "The second init replaced the data";
+    deinitKeyring(*mccs);
 }
 
 // deinit when not initialized
 TEST_F(KeyringTest, extraDeinit) {
     // It is NULL before
-    EXPECT_EQ(keyring, boost::shared_ptr<TSIGKeyRing>()) <<
+    EXPECT_EQ(boost::shared_ptr<TSIGKeyRing>(), keyring) <<
         "Someone forgot to deinit it before";
     // Check that it doesn't get confused when we do not have it initialized
     EXPECT_NO_THROW(deinitKeyring(*mccs));




More information about the bind10-changes mailing list