[svn] commit: r2254 - in /branches/trac127/src/bin/cmdctl: cmdctl.py.in tests/cmdctl_test.py

BIND 10 source code commits bind10-changes at lists.isc.org
Thu Jun 24 06:24:53 UTC 2010


Author: zhanglikun
Date: Thu Jun 24 06:24:52 2010
New Revision: 2254

Log:
Add log message if key/account/certificate file can't be found when cmdctl starts. Remove the test cases which rely on the installation path of cmdctl. 

Modified:
    branches/trac127/src/bin/cmdctl/cmdctl.py.in
    branches/trac127/src/bin/cmdctl/tests/cmdctl_test.py

Modified: branches/trac127/src/bin/cmdctl/cmdctl.py.in
==============================================================================
--- branches/trac127/src/bin/cmdctl/cmdctl.py.in (original)
+++ branches/trac127/src/bin/cmdctl/cmdctl.py.in Thu Jun 24 06:24:52 2010
@@ -257,7 +257,9 @@
         not. '''
         errstr = None
         for key in new_config:
-            if key in ['key_file', 'cert_file']:
+            if key == 'version':
+                continue
+            elif key in ['key_file', 'cert_file']:
                 #TODO, only check whether the file exist,
                 # further check need to be done: eg. whether
                 # the private/certificate is valid.
@@ -469,8 +471,18 @@
         ''' Record user's id and login time. '''
         self.user_sessions[session_id] = time.time()
         
+    def _check_key_and_cert(self, key, cert):
+        # TODO, check the content of key/certificate file 
+        if not os.path.exists(key):
+            self.log_info("Deny client's connection since key file doesn't exist " + key)
+            raise socket.error
+
+        if not os.path.exists(cert):
+            self.log_info("Deny client's connection since certificate file doesn't exist " + cert)
+            raise socket.error
+
     def _wrap_socket_in_ssl_context(self, sock, key, cert):
-        # TODO, report error when key/certificate file doesn't exist
+        self._check_key_and_cert(key, cert)
         try:
             ssl_sock = ssl.wrap_socket(sock,
                                       server_side = True,
@@ -479,7 +491,7 @@
                                       ssl_version = ssl.PROTOCOL_SSLv23)
             return ssl_sock 
         except ssl.SSLError as e :
-            self.log_info("Deny client's invalid connection:%s\n" % e)
+            self.log_info("Deny client's connection:%s\n" % e)
             self.close_request(sock)
             # raise socket error to finish the request
             raise socket.error

Modified: branches/trac127/src/bin/cmdctl/tests/cmdctl_test.py
==============================================================================
--- branches/trac127/src/bin/cmdctl/tests/cmdctl_test.py (original)
+++ branches/trac127/src/bin/cmdctl/tests/cmdctl_test.py Thu Jun 24 06:24:52 2010
@@ -338,14 +338,6 @@
         old_env = os.environ
         os.environ['B10_FROM_SOURCE'] = '../'
         self._check_config(self.cmdctl)
-        answer = self.cmdctl.config_handler({'key_file' : self.cmdctl._cmdctl_config_data['key_file']})
-        self._check_answer(answer, 0, None)
-
-        answer = self.cmdctl.config_handler({'cert_file' : self.cmdctl._cmdctl_config_data['cert_file']})
-        self._check_answer(answer, 0, None)
-
-        answer = self.cmdctl.config_handler({'accounts_file' : self.cmdctl._cmdctl_config_data['accounts_file']})
-        self._check_answer(answer, 0, None)
         os.environ = old_env
 
         answer = self.cmdctl.config_handler({'key_file': '/user/non-exist_folder'})




More information about the bind10-changes mailing list