Update of /cvsroot/mailman/mailman/bin
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15134

Modified Files:
      Tag: Release_2_1-maint
        check_perms 
Log Message:
getgrgid(), checkwalk(): cache the results of grp.getgrgid() so things go much
faster.  (At least some) libc getgrgid() opens /etc/group for every query.


Index: check_perms
===================================================================
RCS file: /cvsroot/mailman/mailman/bin/check_perms,v
retrieving revision 2.15.2.1
retrieving revision 2.15.2.2
diff -u -d -r2.15.2.1 -r2.15.2.2
--- check_perms 31 Mar 2003 20:07:55 -0000      2.15.2.1
+++ check_perms 6 Jul 2004 01:04:29 -0000       2.15.2.2
@@ -1,6 +1,6 @@
 #! @PYTHON@
 #
-# Copyright (C) 1998,1999,2000,2001,2002 by the Free Software Foundation, Inc.
+# Copyright (C) 1998-2004 by the Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -23,7 +23,6 @@
 With no arguments, just check and report all the files that have bogus
 permissions or group ownership.  With -f (and run as root), fix all the
 permission problems found.  With -v be verbose.
-
 """
 
 import os
@@ -86,6 +85,18 @@
 
 seen = {}
 
+# libc's getgrgid re-opens /etc/group each time :(
+_gidcache = {}
+
+def getgrgid(gid):
+    data = _gidcache.get(gid)
+    if data is None:
+        data = grp.getgrgid(gid)
+        _gidcache[gid] = data
+    return data
+
+
+
 def checkwalk(arg, dirname, names):
     # Short-circuit duplicates
     if seen.has_key(dirname):
@@ -102,7 +113,7 @@
             continue
         if gid <> MAILMAN_GID:
             try:
-                groupname = grp.getgrgid(gid)[0]
+                groupname = getgrgid(gid)[0]
             except KeyError:
                 groupname = '<anon gid %d>' % gid
             arg.ERRORS += 1

_______________________________________________
Mailman-checkins mailing list
[EMAIL PROTECTED]
Unsubscribe: http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org

Reply via email to