BIND 10 trac875, updated. 36af50328be059026859a09d402ff2d591789dfd [trac875] The checking function

BIND 10 source code commits bind10-changes at lists.isc.org
Wed May 11 14:52:17 UTC 2011


The branch, trac875 has been updated
       via  36af50328be059026859a09d402ff2d591789dfd (commit)
      from  f8c763ef2c9eb8343ead481093e2d0024e3f1cd2 (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 36af50328be059026859a09d402ff2d591789dfd
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Wed May 11 16:51:49 2011 +0200

    [trac875] The checking function

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

Summary of changes:
 src/bin/cfgmgr/plugins/tests/Makefile.am       |    2 +-
 src/bin/cfgmgr/plugins/tests/tsig_keys_test.py |    2 +-
 src/bin/cfgmgr/plugins/tsig_keys.py            |   21 ++++++++++++++++++++-
 3 files changed, 22 insertions(+), 3 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/cfgmgr/plugins/tests/Makefile.am b/src/bin/cfgmgr/plugins/tests/Makefile.am
index f8ed7df..5f1b770 100644
--- a/src/bin/cfgmgr/plugins/tests/Makefile.am
+++ b/src/bin/cfgmgr/plugins/tests/Makefile.am
@@ -11,7 +11,7 @@ endif
 	for pytest in $(PYTESTS) ; do \
 	echo Running test: $$pytest ; \
 	env B10_TEST_PLUGIN_DIR=$(abs_srcdir)/..:$(abs_builddir)/.. \
-	env PYTHONPATH=$(abs_top_srcdir)/src/lib/python:$(abs_top_builddir)/src/lib/python:$(abs_top_builddir)/src/bin/cfgmgr \
+	env PYTHONPATH=$(abs_top_srcdir)/src/lib/python:$(abs_top_builddir)/src/lib/python:$(abs_top_builddir)/src/bin/cfgmgr:$(abs_top_builddir)/src/lib/dns/python/.libs \
 	$(PYCOVERAGE_RUN) $(abs_builddir)/$$pytest || exit ; \
 	done
 
diff --git a/src/bin/cfgmgr/plugins/tests/tsig_keys_test.py b/src/bin/cfgmgr/plugins/tests/tsig_keys_test.py
index e6436a9..be2921c 100644
--- a/src/bin/cfgmgr/plugins/tests/tsig_keys_test.py
+++ b/src/bin/cfgmgr/plugins/tests/tsig_keys_test.py
@@ -74,7 +74,7 @@ class TSigKeysTest(unittest.TestCase):
         """
         Test we reject when we have multiple keys with the same name.
         """
-        self.assertEqual("Multiple TSIG keys with name 'test.key'",
+        self.assertEqual("Multiple TSIG keys with name 'test.key.'",
                          tsig_keys.check({'keys':
                                          ['test.key:QklORCAxMCBpcyBjb29sCg==',
                                           'test.key:b3RoZXIK']}))
diff --git a/src/bin/cfgmgr/plugins/tsig_keys.py b/src/bin/cfgmgr/plugins/tsig_keys.py
index 39058b4..7a19489 100644
--- a/src/bin/cfgmgr/plugins/tsig_keys.py
+++ b/src/bin/cfgmgr/plugins/tsig_keys.py
@@ -15,11 +15,30 @@
 
 from isc.config.module_spec import module_spec_from_file
 from isc.util.file import path_search
+from isc.dns import TSIGKey
+import pydnspp
 from bind10_config import PLUGIN_PATHS
 spec = module_spec_from_file(path_search('tsig_keys.spec', PLUGIN_PATHS))
 
 def check(config):
-    pass
+    # Check the data layout first
+    errors=[]
+    if not spec.validate_config(False, config, errors):
+        return ' '.join(errors)
+    # Get the list of keys, if any
+    keys = config.get('keys', [])
+    # Run trough them, check they can be constructed and there are no dupes
+    keyNames = set()
+    for key in keys:
+        try:
+            name = str(TSIGKey(key).get_key_name())
+        except pydnspp.InvalidParameter as e:
+            return "TSIG: " + str(e)
+        if name in keyNames:
+            return "Multiple TSIG keys with name '" + name + "'"
+        keyNames.add(name)
+    # No error found, so let's assume it's OK
+    return None
 
 def load():
     return (spec, check)




More information about the bind10-changes mailing list