diff options
Diffstat (limited to 'bin/check_perms')
-rwxr-xr-x | bin/check_perms | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/bin/check_perms b/bin/check_perms index 137ebfb9..c10e46e9 100755 --- a/bin/check_perms +++ b/bin/check_perms @@ -1,6 +1,6 @@ #! @PYTHON@ # -# Copyright (C) 1998-2009 by the Free Software Foundation, Inc. +# Copyright (C) 1998-2016 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 @@ -45,7 +45,7 @@ directory. You must run this from the installation directory instead. raise from Mailman import mm_cfg from Mailman.mm_cfg import MAILMAN_USER, MAILMAN_GROUP -from Mailman.i18n import _ +from Mailman.i18n import C_ # Let KeyErrors percolate MAILMAN_GID = grp.getgrnam(MAILMAN_GROUP)[2] @@ -107,7 +107,7 @@ def checkwalk(arg, dirname, names): for name in names: path = os.path.join(dirname, name) if arg.VERBOSE: - print _(' checking gid and mode for %(path)s') + print C_(' checking gid and mode for %(path)s') try: mode, gid = statgidmode(path) except OSError, e: @@ -119,10 +119,10 @@ def checkwalk(arg, dirname, names): except KeyError: groupname = '<anon gid %d>' % gid arg.ERRORS += 1 - print _('%(path)s bad group (has: %(groupname)s, ' - 'expected %(MAILMAN_GROUP)s)'), + print C_('%(path)s bad group (has: %(groupname)s, ' + 'expected %(MAILMAN_GROUP)s)'), if STATE.FIX: - print _('(fixing)') + print C_('(fixing)') os.chown(path, -1, MAILMAN_GID) else: print @@ -148,19 +148,19 @@ def checkwalk(arg, dirname, names): octperms = oct(targetperms) if S_ISDIR(mode) and (mode & targetperms) <> targetperms: arg.ERRORS += 1 - print _('directory permissions must be %(octperms)s: %(path)s'), + print C_('directory permissions must be %(octperms)s: %(path)s'), if STATE.FIX: - print _('(fixing)') + print C_('(fixing)') os.chmod(path, mode | targetperms) else: print elif os.path.splitext(path)[1] in ('.py', '.pyc', '.pyo'): octperms = oct(PYFILEPERMS) if mode & PYFILEPERMS <> PYFILEPERMS: - print _('source perms must be %(octperms)s: %(path)s'), + print C_('source perms must be %(octperms)s: %(path)s'), arg.ERRORS += 1 if STATE.FIX: - print _('(fixing)') + print C_('(fixing)') os.chmod(path, mode | PYFILEPERMS) else: print @@ -168,10 +168,10 @@ def checkwalk(arg, dirname, names): # Article files must be group writeable octperms = oct(ARTICLEFILEPERMS) if mode & ARTICLEFILEPERMS <> ARTICLEFILEPERMS: - print _('article db files must be %(octperms)s: %(path)s'), + print C_('article db files must be %(octperms)s: %(path)s'), arg.ERRORS += 1 if STATE.FIX: - print _('(fixing)') + print C_('(fixing)') os.chmod(path, mode | ARTICLEFILEPERMS) else: print @@ -180,7 +180,7 @@ def checkall(): # first check PREFIX if STATE.VERBOSE: prefix = mm_cfg.PREFIX - print _('checking mode for %(prefix)s') + print C_('checking mode for %(prefix)s') dirs = {} for d in (mm_cfg.PREFIX, mm_cfg.EXEC_PREFIX, mm_cfg.VAR_PREFIX, mm_cfg.LOG_DIR): @@ -190,13 +190,13 @@ def checkall(): mode = statmode(d) except OSError, e: if e.errno <> errno.ENOENT: raise - print _('WARNING: directory does not exist: %(d)s') + print C_('WARNING: directory does not exist: %(d)s') continue if (mode & DIRPERMS) <> DIRPERMS: STATE.ERRORS += 1 - print _('directory must be at least 02775: %(d)s'), + print C_('directory must be at least 02775: %(d)s'), if STATE.FIX: - print _('(fixing)') + print C_('(fixing)') os.chmod(d, mode | DIRPERMS) else: print @@ -206,21 +206,21 @@ def checkall(): def checkarchives(): private = mm_cfg.PRIVATE_ARCHIVE_FILE_DIR if STATE.VERBOSE: - print _('checking perms on %(private)s') + print C_('checking perms on %(private)s') # private archives must not be other readable mode = statmode(private) if mode & S_IROTH: STATE.ERRORS += 1 - print _('%(private)s must not be other-readable'), + print C_('%(private)s must not be other-readable'), if STATE.FIX: - print _('(fixing)') + print C_('(fixing)') os.chmod(private, mode & ~S_IROTH) else: print # In addition, on a multiuser system you may want to hide the private # archives so other users can't read them. if mode & S_IXOTH: - print _("""\ + print C_("""\ Warning: Private archive directory is other-executable (o+x). This could allow other users on your system to read private archives. If you're on a shared multiuser system, you should consult the @@ -237,9 +237,9 @@ def checkmboxfile(mboxdir): mode = statmode(mboxfile) if (mode & MBOXPERMS) <> MBOXPERMS: STATE.ERRORS = STATE.ERRORS + 1 - print _('mbox file must be at least 0660:'), mboxfile + print C_('mbox file must be at least 0660:'), mboxfile if STATE.FIX: - print _('(fixing)') + print C_('(fixing)') os.chmod(mboxfile, mode | MBOXPERMS) else: print @@ -260,9 +260,9 @@ def checkarchivedbs(): continue if mode & S_IRWXO: STATE.ERRORS += 1 - print _('%(dbdir)s "other" perms must be 000'), + print C_('%(dbdir)s "other" perms must be 000'), if STATE.FIX: - print _('(fixing)') + print C_('(fixing)') os.chmod(dbdir, mode & ~S_IRWXO) else: print @@ -270,18 +270,18 @@ def checkarchivedbs(): def checkcgi(): cgidir = os.path.join(mm_cfg.EXEC_PREFIX, 'cgi-bin') if STATE.VERBOSE: - print _('checking cgi-bin permissions') + print C_('checking cgi-bin permissions') exes = os.listdir(cgidir) for f in exes: path = os.path.join(cgidir, f) if STATE.VERBOSE: - print _(' checking set-gid for %(path)s') + print C_(' checking set-gid for %(path)s') mode = statmode(path) if mode & S_IXGRP and not mode & S_ISGID: STATE.ERRORS += 1 - print _('%(path)s must be set-gid'), + print C_('%(path)s must be set-gid'), if STATE.FIX: - print _('(fixing)') + print C_('(fixing)') os.chmod(path, mode | S_ISGID) else: print @@ -289,13 +289,13 @@ def checkcgi(): def checkmail(): wrapper = os.path.join(mm_cfg.WRAPPER_DIR, 'mailman') if STATE.VERBOSE: - print _('checking set-gid for %(wrapper)s') + print C_('checking set-gid for %(wrapper)s') mode = statmode(wrapper) if not mode & S_ISGID: STATE.ERRORS += 1 - print _('%(wrapper)s must be set-gid'), + print C_('%(wrapper)s must be set-gid'), if STATE.FIX: - print _('(fixing)') + print C_('(fixing)') os.chmod(wrapper, mode | S_ISGID) def checkadminpw(): @@ -303,7 +303,7 @@ def checkadminpw(): os.path.join(mm_cfg.DATA_DIR, 'creator.pw')): targetmode = S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP if STATE.VERBOSE: - print _('checking permissions on %(pwfile)s') + print C_('checking permissions on %(pwfile)s') try: mode = statmode(pwfile) except OSError, e: @@ -312,10 +312,10 @@ def checkadminpw(): if mode <> targetmode: STATE.ERRORS += 1 octmode = oct(mode) - print _('%(pwfile)s permissions must be exactly 0640 ' - '(got %(octmode)s)'), + print C_('%(pwfile)s permissions must be exactly 0640 ' + '(got %(octmode)s)'), if STATE.FIX: - print _('(fixing)') + print C_('(fixing)') os.chmod(pwfile, targetmode) else: print @@ -337,7 +337,7 @@ def checkdata(): 'digest.mbox', 'pending.pck', 'request.db', 'request.db.tmp') if STATE.VERBOSE: - print _('checking permissions on list data') + print C_('checking permissions on list data') # BAW: This needs to be converted to the Site module abstraction for dir in os.listdir(mm_cfg.LIST_DATA_DIR): if not os.path.isdir(os.path.join(mm_cfg.LIST_DATA_DIR, dir)): @@ -345,7 +345,7 @@ def checkdata(): for file in checkfiles: path = os.path.join(mm_cfg.LIST_DATA_DIR, dir, file) if STATE.VERBOSE: - print _(' checking permissions on: %(path)s') + print C_(' checking permissions on: %(path)s') try: mode = statmode(path) except OSError, e: @@ -353,9 +353,9 @@ def checkdata(): continue if (mode & targetmode) <> targetmode: STATE.ERRORS += 1 - print _('file permissions must be at least 660: %(path)s'), + print C_('file permissions must be at least 660: %(path)s'), if STATE.FIX: - print _('(fixing)') + print C_('(fixing)') os.chmod(path, mode | targetmode) else: print @@ -367,7 +367,7 @@ def usage(code, msg=''): fd = sys.stderr else: fd = sys.stdout - print >> fd, _(__doc__) + print >> fd, C_(__doc__) if msg: print >> fd, msg sys.exit(code) @@ -398,7 +398,7 @@ if __name__ == '__main__': checkmta() if not STATE.ERRORS: - print _('No problems found') + print C_('No problems found') else: - print _('Problems found:'), STATE.ERRORS - print _('Re-run as %(MAILMAN_USER)s (or root) with -f flag to fix') + print C_('Problems found:'), STATE.ERRORS + print C_('Re-run as %(MAILMAN_USER)s (or root) with -f flag to fix') |