[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[minion-cvs] Add testing section to server descriptor to help debugg...



Update of /home/minion/cvsroot/src/minion/lib/mixminion/server
In directory moria.mit.edu:/tmp/cvs-serv24584/minion/lib/mixminion/server

Modified Files:
	ServerConfig.py ServerKeys.py 
Log Message:
Add testing section to server descriptor to help debugging

Index: ServerConfig.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/server/ServerConfig.py,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- ServerConfig.py	26 Jun 2003 17:43:27 -0000	1.34
+++ ServerConfig.py	7 Jul 2003 16:49:25 -0000	1.35
@@ -122,10 +122,10 @@
         if server['LogLevel'] in ('TRACE', 'DEBUG'):
             reasons.append("Log is too verbose")
         if server['LogStats'] and server['StatsInterval'].getSeconds() \
-               < 24*60*60:
+               < 2*60*60:
             reasons.append("StatsInterval is too short")
-        if not server["EncryptIdentityKey"]:
-            reasons.append("Identity key is not encrypted")
+        #if not server["EncryptIdentityKey"]:
+        #    reasons.append("Identity key is not encrypted")
         # ???? Pkey lifetime, sloppiness?
         if server["MixAlgorithm"] not in _SECURE_MIX_RULES:
             reasons.append("Mix algorithm is not secure")
@@ -144,6 +144,25 @@
 
         return reasons
 
+    def getConfigurationSummary(self):
+        """DOCDOC"""
+        res = []
+        for section,entries in [
+            ("Server", ['LogLevel', 'LogStats', 'StatsInterval',
+                        'PublicKeyOverlap', 'Mode', 'MixAlgorithm',
+                        'MixInterval', 'MixPoolRate', 'MixPoolMinSize',
+                        'Timeout',]),
+            ("Outgoing/MMTP", ['Retry']),
+            ("Delivery/SMTP", ['Enabled','Retry']),
+            ("Delivery/SMTP-Via-Mixmaster", ['Enabled', 'Retry', 'Server']),
+            ]:
+            sec = self[section]
+            for k in entries:
+                v = sec.get(k, None)
+                if v:
+                    res.append("%s/%s=%r"%(section,k,v))
+        return "; ".join(res)
+    
     def validateRetrySchedule(self, sectionName, entryName='Retry'):
         """Check whether the retry schedule in self[sectionName][entryName]
            is reasonable.  Warn or raise ConfigError if it isn't.  Ignore
@@ -154,6 +173,7 @@
             return
         mixInterval = self['Server']['MixInterval'].getSeconds()
         _validateRetrySchedule(mixInterval, entry, sectionName)
+
 
 def _validateRetrySchedule(mixInterval, schedule, sectionName):
     """Backend for ServerConfig.validateRetrySchedule -- separated for testing.

Index: ServerKeys.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/server/ServerKeys.py,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- ServerKeys.py	26 Jun 2003 03:23:53 -0000	1.45
+++ ServerKeys.py	7 Jul 2003 16:49:25 -0000	1.46
@@ -771,6 +771,18 @@
         warn("(Future keys will be generated with the correct lifetime")
         warn.errors -= 2 # We can't do anything about this!
 
+    insecurities = config.getInsecurities()
+    if insecurities:
+        if (info_s['Secure-Configuration'] or
+            info_s.get('Why-Insecure',None)!=", ".join(insecurities)):
+            warn("Mismatched Secure-Configuration: %r %r %r",
+                 info_s['Secure-Configuration'],
+                 info_s.get("Why-Insecure",None),
+                 ", ".join(insecurities))
+    else:
+        if not info_s['Secure-Configuration'] or info_s.get('Why-Insecure'):
+            warn("Mismatched Secure-Configuration")
+
     info_im = info['Incoming/MMTP']
     config_im = config['Incoming/MMTP']
     if info_im['Port'] != config_im['Port']:
@@ -802,6 +814,12 @@
         if config_out and not info_out:
             warn("%s enabled, but not published.", section)
 
+    info_testing = info.get("Testing",{})
+    if info_testing.get("Platform", "") != getPlatformSummary():
+        warn("Mismatched platform summary")
+    if not warn.errors and info_testing.get("Configuration", "") != config.getConfigurationSummary():
+        warn("Mismatched configuration summary")
+
     if warn.errors:
         return "bad"
     elif warn.called:
@@ -863,7 +881,8 @@
     if not validAt:
         validAt = now
 
-    if config.getInsecurities():
+    insecurities = config.getInsecurities()
+    if insecurities:
         secure = "no"
     else:
         secure = "yes"
@@ -941,6 +960,8 @@
         Software: Mixminion %(mm_version)s
         Secure-Configuration: %(Secure)s
         """ % fields
+    if insecurities:
+        info += "Why-Insecure: %s\n"%(", ".join(insecurities))
     if contact:
         info += "Contact: %s\n"%contact
     if comments:
@@ -979,6 +1000,13 @@
     # Ask our modules for their configuration information.
     info += "".join(config.moduleManager.getServerInfoBlocks())
 
+    info += """\
+          [Testing]
+          Platform: %s
+          Configuration: %s
+          """ %(getPlatformSummary(),
+                config.getConfigurationSummary())
+    
     # Remove extra (leading or trailing) whitespace from the lines.
     lines = [ line.strip() for line in info.split("\n") ]
     # Remove empty lines
@@ -996,6 +1024,11 @@
     # FFFF Remove this once we're more confident.
     inf = ServerInfo(string=info)
     ok = checkDescriptorConsistency(inf, config, log=0, isPublished=0)
+    if ok not in ('good', 'so-so'):
+        print "========"
+        print info
+        print "======"
+        checkDescriptorConsistency(inf, config, log=1, isPublished=0)
     assert ok in ('good', 'so-so')
 
     return info
@@ -1108,3 +1141,10 @@
     identityCertText = readFile(fname)
     os.unlink(fname)
     writeFile(filename, certText+identityCertText, 0600)
+        
+def getPlatformSummary():
+    """XXXX005 move; DOCDOC"""
+    uname = " ".join(os.uname())
+    return "Mixminion %s; Python %r on %r" % (
+        mixminion.__version__, sys.version, uname)
+