Update of /cvsroot/mailman/mailman/bin
In directory sc8-pr-cvs1:/tmp/cvs-serv8510

Modified Files:
        check_perms 
Log Message:
Use True/False where appropriate.

Add LOG_DIR to the list of directories to search.  This may not be
located under $PREFIX or $EXEC_PREFIX.  Closes SF bug #695526 by Luigi
Rosa.

checkwalk(): Put in a short-circuit so directories are never searched
more than once.

checkall(): Catch, warn, and ignore when directories don't exist.


Index: check_perms
===================================================================
RCS file: /cvsroot/mailman/mailman/bin/check_perms,v
retrieving revision 2.15
retrieving revision 2.16
diff -u -d -r2.15 -r2.16
--- check_perms 12 Nov 2002 21:28:32 -0000      2.15
+++ check_perms 14 Mar 2003 05:18:55 -0000      2.16
@@ -26,12 +26,12 @@
 
 """
 
-import sys
 import os
-import errno
-import getopt
+import sys
 import pwd
 import grp
+import errno
+import getopt
 from stat import *
 
 try:
@@ -55,11 +55,17 @@
 
 # Gotta check the archives/private/*/database/* files
 
+try:
+    True, False
+except NameError:
+    True = 1
+    False = 0
+
 
 
 class State:
-    FIX = 0
-    VERBOSE = 0
+    FIX = False
+    VERBOSE = False
     ERRORS = 0
 
 STATE = State()
@@ -78,7 +84,13 @@
     stat = os.stat(path)
     return stat[ST_MODE], stat[ST_GID]
 
+seen = {}
+
 def checkwalk(arg, dirname, names):
+    # Short-circuit duplicates
+    if seen.has_key(dirname):
+        return
+    seen[dirname] = True
     for name in names:
         path = os.path.join(dirname, name)
         if arg.VERBOSE:
@@ -151,10 +163,16 @@
         prefix = mm_cfg.PREFIX
         print _('checking mode for %(prefix)s')
     dirs = {}
-    for d in (mm_cfg.PREFIX, mm_cfg.EXEC_PREFIX, mm_cfg.VAR_PREFIX):
-        dirs[d] = 1
+    for d in (mm_cfg.PREFIX, mm_cfg.EXEC_PREFIX, mm_cfg.VAR_PREFIX,
+              mm_cfg.LOG_DIR):
+        dirs[d] = True
     for d in dirs.keys():
-        mode = statmode(d)
+        try:
+            mode = statmode(d)
+        except OSError, e:
+            if e.errno <> errno.ENOENT: raise
+            print _('WARNING: directory does not exist: %(d)s')
+            continue
         if (mode & DIRPERMS) <> DIRPERMS:
             STATE.ERRORS += 1
             print _('directory must be at least 02775: %(d)s'),
@@ -166,7 +184,6 @@
         # check all subdirs
         os.path.walk(d, checkwalk, STATE)
 
-
 def checkarchives():
     private = mm_cfg.PRIVATE_ARCHIVE_FILE_DIR
     if STATE.VERBOSE:
@@ -185,7 +202,6 @@
 
 MBOXPERMS = S_IRGRP | S_IWGRP | S_IRUSR | S_IWUSR
 
-
 def checkmboxfile(mboxdir):
     absdir = os.path.join(mm_cfg.PRIVATE_ARCHIVE_FILE_DIR, mboxdir)
     for f in os.listdir(absdir):
@@ -202,7 +218,6 @@
             else:
                 print
 
-
 def checkarchivedbs():
     # The archives/private/listname/database file must not be other readable
     # or executable otherwise those files will be accessible when the archives
@@ -226,7 +241,6 @@
             else:
                 print
 
-
 def checkcgi():
     cgidir = os.path.join(mm_cfg.EXEC_PREFIX, 'cgi-bin')
     if STATE.VERBOSE:
@@ -332,8 +346,7 @@
 
 if __name__ == '__main__':
     try:
-        opts, args = getopt.getopt(sys.argv[1:],
-                                   'fvh',
+        opts, args = getopt.getopt(sys.argv[1:], 'fvh',
                                    ['fix', 'verbose', 'help'])
     except getopt.error, msg:
         usage(1, msg)
@@ -342,9 +355,9 @@
         if opt in ('-h', '--help'):
             usage(0)
         elif opt in ('-f', '--fix'):
-            STATE.FIX = 1
+            STATE.FIX = True
         elif opt in ('-v', '--verbose'):
-            STATE.VERBOSE = 1
+            STATE.VERBOSE = True
 
     checkall()
     checkarchives()



_______________________________________________
Mailman-checkins mailing list
[EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/mailman-checkins

Reply via email to