diff options
author | bwarsaw <> | 2003-03-31 20:18:44 +0000 |
---|---|---|
committer | bwarsaw <> | 2003-03-31 20:18:44 +0000 |
commit | 9f21b6e1d4b4a2604427e6b2b2346db845b020c5 (patch) | |
tree | 1837c951607869c1340b68e8cc4ba26de0969e86 | |
parent | d258eeb3b86fc7a084e68428f3354789ef8e3b4c (diff) | |
download | mailman2-9f21b6e1d4b4a2604427e6b2b2346db845b020c5.tar.gz mailman2-9f21b6e1d4b4a2604427e6b2b2346db845b020c5.tar.xz mailman2-9f21b6e1d4b4a2604427e6b2b2346db845b020c5.zip |
Backporting various fixes and improvements from the trunk.
-rw-r--r-- | contrib/check_perms_grsecurity.py | 11 | ||||
-rwxr-xr-x | cron/checkdbs | 51 |
2 files changed, 50 insertions, 12 deletions
diff --git a/contrib/check_perms_grsecurity.py b/contrib/check_perms_grsecurity.py index 7b27a19f..9a4ee997 100644 --- a/contrib/check_perms_grsecurity.py +++ b/contrib/check_perms_grsecurity.py @@ -1,6 +1,6 @@ #! @PYTHON@ # -# Copyright (C) 1998,1999,2000,2001,2002 by the Free Software Foundation, Inc. +# Copyright (C) 1998-2003 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 @@ -77,9 +77,10 @@ def main(argv): sys.exit(1) print "Making select directories owned and writable by root only" + gid = grp.getgrnam(MAILMAN_GROUP)[2] for dir in dirstochownroot: dirpath = paths.prefix + '/' + dir - os.chown(dirpath, 0, MAILMAN_GID) + os.chown(dirpath, 0, gid) os.chmod(dirpath, 02755) print dirpath @@ -162,10 +163,10 @@ class CheckFixUid: file.insert(i, object.group(1) + "CheckFixUid.CheckFixUid()\n") patched=1 - break + break if object2: print "Patching " + script - file.insert(i, + file.insert(i, object2.group(1) + "CheckFixUid.CheckFixUid()\n") patched=1 break @@ -176,5 +177,5 @@ class CheckFixUid: else: filefd=open(script, "w") filefd.writelines(file) - + main(sys.argv) diff --git a/cron/checkdbs b/cron/checkdbs index 46883cf0..ae194970 100755 --- a/cron/checkdbs +++ b/cron/checkdbs @@ -1,6 +1,6 @@ #! @PYTHON@ # -# Copyright (C) 1998,1999,2000,2001,2002 by the Free Software Foundation, Inc. +# Copyright (C) 1998-2003 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 @@ -16,12 +16,19 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -"""Invoked by cron, this checks for pending moderation requests and mails the -list moderators if necessary. +"""Check for pending admin requests and mail the list owners if necessary. + +Usage: %(PROGRAM)s [options] + +Options: + + -h/--help + Print this message and exit. """ import sys import time +import getopt from types import UnicodeType import paths @@ -40,16 +47,38 @@ import signal signal.signal(signal.SIGCHLD, signal.SIG_DFL) NL = '\n' +PROGRAM = sys.argv[0] _ = i18n._ i18n.set_language(mm_cfg.DEFAULT_SERVER_LANGUAGE) -def _isunicode(s): - return isinstance(s, UnicodeType) + + +def usage(code, msg=''): + if code: + fd = sys.stderr + else: + fd = sys.stdout + print >> fd, _(__doc__) + if msg: + print >> fd, msg + sys.exit(code) def main(): + try: + opts, args = getopt.getopt(sys.argv[1:], 'h', ['help']) + except getopt.error, msg: + usage(1, msg) + + for opt, arg in opts: + if opt in ('-h', '--help'): + usage(0) + + if args: + usage(1) + for name in Utils.list_names(): # the list must be locked in order to open the requests database mlist = MailList.MailList(name) @@ -116,15 +145,23 @@ From: %(sender)s on %(date)s Subject: %(subject)s Cause: %(reason)s""")) pending.append('') + # Coerce all items in pending to a Unicode so we can join them + upending = [] + charset = Utils.GetCharSet(mlist.preferred_language) + for s in pending: + if isinstance(s, UnicodeType): + upending.append(s) + else: + upending.append(unicode(s, charset, 'replace')) # Make sure that the text we return from here can be encoded to a byte # string in the charset of the list's language. This could fail if for # example, the request was pended while the list's language was French, # but then it was changed to English before checkdbs ran. - text = NL.join(pending) + text = u'\n'.join(upending) charset = Charset(Utils.GetCharSet(mlist.preferred_language)) incodec = charset.input_codec or 'ascii' outcodec = charset.output_codec or 'ascii' - if _isunicode(text): + if isinstance(text, UnicodeType): return text.encode(outcodec, 'replace') # Be sure this is a byte string encodeable in the list's charset utext = unicode(text, incodec, 'replace') |