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

[minion-cvs] Make directory initialization work; setup new directory...



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

Modified Files:
	DirMain.py Directory.py 
Log Message:
Make directory initialization work; setup new directory URL (again)

Index: DirMain.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/directory/DirMain.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- DirMain.py	26 May 2003 21:08:13 -0000	1.10
+++ DirMain.py	28 May 2003 05:26:48 -0000	1.11
@@ -14,26 +14,27 @@
 import stat
 import sys
 import time
-from mixminion.Common import createPrivateDir, formatTime, LOG
+from mixminion.Common import createPrivateDir, formatTime, LOG, UIError
+from mixminion.Config import ConfigError
 from mixminion.Crypto import init_crypto, pk_fingerprint, pk_generate, \
      pk_PEM_load, pk_PEM_save
 from mixminion.directory.Directory import Directory, DirectoryConfig
 
 USAGE = """\
-Usage: %s -d <directory> command
+Usage: mixminion dir <command>
    Where 'command' is one of:
-      import <serverinfo>      [Import a descriptor for a known server]
-      import-new <serverinfo>  [Import a descriptor for a new server]
+      initialize [DOCDOC]
+      import-new <nickname>  [Import a descriptor for a new server]
+      list [DOCDOC]
+      update [DOCDOC]
       generate                 [Generate and sign a new directory]
-      export <filename>        [Export the most recently generated directory]
-      remove <nickname>        [Remove a server from storage]
       fingerprint              [Return the fingerprint of this directory's pk]
 """.strip()
 
 def getDirectory():
     fn = os.environ.get('MINION_DIR_CONF')
     if not fn:
-        fn = os.expanduser("~/.mixminion_dir.cf")
+        fn = os.path.expanduser("~/.mixminion_dir.cf")
         if not os.path.exists(fn):
             fn = None
     if not fn:
@@ -46,20 +47,23 @@
     try:
         config = DirectoryConfig(filename=fn)
     except ConfigError, e:
-        raise UIError("Error in %s: %s", fn, e)
+        raise UIError("Error in %s: %s"%(fn, e))
 
     return Directory(config)
 
-def usageAndExit(cmd):
+def usageAndExit():
     """Print a usage message and exit"""
-    print USAGE%cmd
-    sys.exit
+    print USAGE
+    sys.exit(0)
 
-def cmd_init():
+def cmd_init(args):
+    if args:
+        raise UIError("mixminion dir initialize takes no arguments")
+    
     d = getDirectory()
     d.setupDirectories()
     d.getServerList()
-    d.getServerInbox()
+    d.getInbox()
 
 def cmd_update(args):
     if args:

Index: Directory.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/directory/Directory.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- Directory.py	27 May 2003 04:56:48 -0000	1.4
+++ Directory.py	28 May 2003 05:26:48 -0000	1.5
@@ -22,7 +22,7 @@
     def __init__(self, config=None, location=None):
         self.config = config
         if config and not location:
-            self.location = config['Directory-Store']['Homedir']
+            self.location = location = config['Directory-Store']['Homedir']
         else:
             self.location = location
         assert location
@@ -51,7 +51,6 @@
         dir_gid = self.config.dir_gid
         cgi_gid = self.config.cgi_gid
         
-        
         for fn, uid, gid, mode, recurse in [
             (self.location,       dir_uid, cgi_gid, 0750, 1),
             (self.directoryBase,  dir_uid, dir_gid, 0700, 0),
@@ -65,7 +64,7 @@
                     os.makedirs(fn, mode)
                 else:
                     os.mkdir(fn, mode)
-            _set_uid_gid_mode(fn, dir_uid, cgi_gid, 0640)
+            _set_uid_gid_mode(fn, dir_uid, cgi_gid, mode)
 
         if not os.path.exists(self.cacheFile):
             self.cache = IDCache(self.cacheFile)
@@ -110,16 +109,15 @@
             return key
         else:
             return pk_PEM_load(fname)
-
             
 class DirectoryConfig(C._ConfigFile):
-    _restrictFormat = 1
+    _restrictFormat = 0
     _restrictKeys = 1
     _syntax = {
         'Host' : C.ClientConfig._syntax['Host'],
         "Directory-Store" : {
-           "__SECTION__" : ( ), 
-           "Homedir" : ('REQUIRE', None, None),
+           "__SECTION__" : ("REQUIRE", None, None ), 
+           "Homedir" : ('REQUIRE', C._parseFilename, None),
            "DirUser" : ('REQUIRE', None, None),
            "CGIUser" : ('REQUIRE', None, None),
            "CGIGroup" : ('REQUIRE', None, None),
@@ -128,7 +126,8 @@
            "BadServer" : ("ALLOW*", None, None)
         },
         'Publishing' : {
-           "Location" : ('REQUIRE', None, None)
+           "__SECTION__": ('REQUIRE', None, None),
+           "Location" : ('REQUIRE', C._parseFilename, None)
         } }
     def __init__(self, filename=None, string=None):
         C._ConfigFile.__init__(self, filename, string)
@@ -137,16 +136,16 @@
         import pwd
         import grp
         ds_sec = self['Directory-Store']
-        diruser = ds_sec['DirUser'].strip()
-        cgiuser = ds_sec['CGIUser'].strip()
-        cgigrp = ds_sec['CGIGroup'].strip()
+        diruser = ds_sec['DirUser'].strip().lower()
+        cgiuser = ds_sec['CGIUser'].strip().lower()
+        cgigrp = ds_sec['CGIGroup'].strip().lower()
 
         try:
-            dir_pwent = pwd.getpwname(diruser)
+            dir_pwent = pwd.getpwnam(diruser)
         except KeyError:
             raise C.ConfigError("No such user: %r"%diruser)
         try:
-            cgi_pwent = pwd.getpwname(cgiuser)
+            cgi_pwent = pwd.getpwnam(cgiuser)
         except KeyError:
             raise C.ConfigError("No such user: %r"%cgiuser)
         try:
@@ -155,7 +154,7 @@
             raise C.ConfigError("No such group: %r"%cgigrp)
 
         self.dir_uid = dir_pwent[2]
-        self.dir_grp = dir_pwent[3]
+        self.dir_gid = dir_pwent[3]
         self.cgi_uid = cgi_pwent[2]
         self.cgi_gid = cgi_grpent[2]
 
@@ -164,10 +163,12 @@
             if pwent[3] == self.cgi_gid:
                 groupMembers.append(pwent[0])
 
-        if self.dir_uid not in groupMembers:
+        groupMembers = [ g.lower().strip() for g in groupMembers ]
+
+        if diruser not in groupMembers:
             raise C.ConfigError("User %s is not in group %s"
                                 %(diruser, cgigrp))
-        if self.cgi_uid not in groupMembers:
+        if cgiuser not in groupMembers:
             raise C.ConfigError("User %s is not in group %s"
                                 %(cgiuser, cgigrp))