[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[minion-cvs] More directory work.
Update of /home/minion/cvsroot/src/minion/lib/mixminion/server
In directory moria.mit.edu:/tmp/cvs-serv18030/src/minion/lib/mixminion/server
Modified Files:
ServerConfig.py ServerMain.py
Log Message:
More directory work.
Make serverdesc publication optional.
Add a republish command.
Rewrite the directory CLI for directory automation.
Index: ServerConfig.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/server/ServerConfig.py,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- ServerConfig.py 17 May 2003 00:08:45 -0000 1.24
+++ ServerConfig.py 26 May 2003 21:08:13 -0000 1.25
@@ -266,7 +266,9 @@
'MixPoolMinSize' : ('ALLOW', C._parseInt, "5"),
'Timeout' : ('ALLOW', C._parseInterval, "5 min"),
},
- 'DirectoryServers' : { 'ServerURL' : ('ALLOW*', None, None),
+ 'DirectoryServers' : { # '__SECTION__' : ('REQUIRE', None, None),
+ 'ServerURL' : ('ALLOW*', None, None),
+ 'PublishURL' : ('ALLOW*', None, None),
'Publish' : ('ALLOW', C._parseBoolean, "no"),
'MaxSkew' : ('ALLOW', C._parseInterval,
"10 minutes",) },
Index: ServerMain.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/server/ServerMain.py,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -d -r1.55 -r1.56
--- ServerMain.py 26 May 2003 20:04:25 -0000 1.55
+++ ServerMain.py 26 May 2003 21:08:13 -0000 1.56
@@ -537,7 +537,8 @@
#XXXX004 Check whether config matches serverinfo
self.keyring = mixminion.server.ServerKeys.ServerKeyring(config)
self.keyring.createKeysAsNeeded()
- self.keyring.publishKeys()
+ if self.config['DirectoryServers'].get('Publish'):
+ self.keyring.publishKeys()
LOG.debug("Initializing packet handler")
self.packetHandler = mixminion.server.PacketHandler.PacketHandler()
@@ -600,7 +601,7 @@
# as long as it takes to generate several new RSA keys, which would
# stomp responsiveness on slow computers.
# ???? Could there be a more elegant approach to this?
- if not self.keyring.lock(1):
+ if not self.keyring.lock(0):
LOG.warn("generateKeys in progress:"
" updateKeys delaying for 2 minutes")
# This will cause getNextKeyRotation to return 2 minutes later
@@ -616,14 +617,20 @@
def generateKeys(self):
"""DOCDOC"""
def c(self=self):
- self.keyring.lock()
try:
+ self.keyring.lock()
self.keyring.createKeysAsNeeded()
- self.keyring.publishKeys()
+ finally:
+ self.keyring.unlock()
+ self.updateKeys()
+ try:
+ self.keyring.lock()
+ if self.config['DirectoryServers'].get('Publish'):
+ self.keyring.publishKeys()
finally:
self.keyring.unlock()
self.processingThread.addJob(c)
-
+
def run(self):
"""Run the server; don't return unless we hit an exception."""
global GOT_HUP
@@ -709,7 +716,7 @@
EventStats.log.save()
LOG.info("Checking for key rotation")
self.keyring.checkKeys()
- self.updateKeys()
+ self.generateKeys()
def doMix(self):
now = time.time()
@@ -1014,18 +1021,19 @@
print UIError("Couldn't send signal: %s"%e)
#----------------------------------------------------------------------
-_KEYGEN_USAGE = """\
-Usage: %s [options]
+_REPUBLISH_USAGE = """\
+Usage: mixminion server-republish [options]
Options:
-h, --help: Print this usage message and exit.
-f <file>, --config=<file> Use a configuration file other than
/etc/mixminiond.conf
- -n <n>, --keys=<n> Generate <n> new keys. (Defaults to 1.)
""".strip()
-def runKeygen(cmd, args):
- options, args = getopt.getopt(args, "hf:n:",
- ["help", "config=", "keys="])
+def runRepublish(cmd, args):
+ options, args = getopt.getopt(args, "hf:",
+ ["help", "config=",])
+
+
# FFFF password-encrypted keys
# FFFF Ability to fill gaps
# FFFF Ability to generate keys with particular start/end intervals
@@ -1037,66 +1045,30 @@
usage=1
elif opt in ('-f', '--config'):
configFile = val
- elif opt in ('-n', '--keys'):
- try:
- keys = int(val)
- except ValueError:
- print >>sys.stderr,("%s requires an integer" %opt)
- usage = 1
if usage:
- print _KEYGEN_USAGE % cmd
+ print _REPUBLISH_USAGE
sys.exit(1)
config = readConfigFile(configFile)
LOG.setMinSeverity("INFO")
mixminion.Crypto.init_crypto(config)
- keyring = mixminion.server.ServerKeys.ServerKeyring(config)
- print "Creating %s keys..." % keys
- for i in xrange(keys):
- keyring.createKeys(1)
- print ".... (%s/%s done)" % (i+1,keys)
-
-#----------------------------------------------------------------------
-_REMOVEKEYS_USAGE = """\
-Usage: %s [options]
-Options:
- -h, --help: Print this usage message and exit.
- -f <file>, --config=<file> Use a configuration file other than
- /etc/mixminiond.conf
- --remove-identity Remove the identity key as well. (DANGEROUS!)
-""".strip()
-def removeKeys(cmd, args):
- # FFFF Resist removing keys that have been published.
- # FFFF Generate 'suicide note' for removing identity key.
- options, args = getopt.getopt(args, "hf:", ["help", "config=",
- "remove-identity"])
- if args:
- print >>sys.stderr, "%s takes no arguments"%cmd
- usage = 1
- args = options = ()
- usage = 0
- removeIdentity = 0
- configFile = None
- for opt,val in options:
- if opt in ('-h', '--help'):
- usage=1
- elif opt in ('-f', '--config'):
- configFile = val
- elif opt == '--remove-identity':
- removeIdentity = 1
- if usage:
- print _REMOVEKEYS_USAGE % cmd
- sys.exit(0)
+ keydir = os.path.join(config['Server']['Homedir'], 'keys')
+ items = os.listdir(keydir)
+ items.sort()
+ for fn in items:
+ if not fn.startswith("key_"):
+ continue
+ num = fn[4:]
+ publishedFile = os.path.join(keydir, "fn", "published")
+ try:
+ LOG.info("Marking key %s unpublished", num)
+ if os.path.exists(publishedFile):
+ os.unlink(publishedFile)
+ except OSError, e:
+ LOG.warn("Couldn't mark key %s unpublished: %s",num,e)
+
+ LOG.info("Telling server to publish descriptors")
- config = readConfigFile(configFile)
- mixminion.Common.configureShredCommand(config)
- LOG.setMinSeverity("INFO")
- keyring = mixminion.server.ServerKeys.ServerKeyring(config)
- keyring.checkKeys()
- # This is impossibly far in the future.
- keyring.removeDeadKeys(now=(1L << 36))
- if removeIdentity:
- keyring.removeIdentityKey()
- LOG.info("Done removing keys")
+ _signalServer(config, reload=1)