diff options
Diffstat (limited to 'bin/check_perms')
-rwxr-xr-x | bin/check_perms | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/bin/check_perms b/bin/check_perms index 4f976b06..5c8ce415 100755 --- a/bin/check_perms +++ b/bin/check_perms @@ -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 @@ Usage: %(PROGRAM)s [-f] [-v] [-h] 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 @@ def statgidmode(path): 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 @@ def checkwalk(arg, dirname, names): 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 |