From b132a73f15e432eaf43310fce9196ca0c0651465 Mon Sep 17 00:00:00 2001 From: <> Date: Thu, 2 Jan 2003 05:25:50 +0000 Subject: This commit was manufactured by cvs2svn to create branch 'Release_2_1-maint'. --- scripts/.cvsignore | 1 + scripts/Makefile.in | 75 ++++++++++++++++ scripts/bounces | 61 +++++++++++++ scripts/confirm | 62 ++++++++++++++ scripts/driver | 243 ++++++++++++++++++++++++++++++++++++++++++++++++++++ scripts/join | 61 +++++++++++++ scripts/leave | 61 +++++++++++++ scripts/owner | 67 +++++++++++++++ scripts/post | 69 +++++++++++++++ scripts/request | 64 ++++++++++++++ 10 files changed, 764 insertions(+) create mode 100644 scripts/.cvsignore create mode 100644 scripts/Makefile.in create mode 100644 scripts/bounces create mode 100755 scripts/confirm create mode 100644 scripts/driver create mode 100755 scripts/join create mode 100755 scripts/leave create mode 100755 scripts/owner create mode 100755 scripts/post create mode 100755 scripts/request (limited to 'scripts') diff --git a/scripts/.cvsignore b/scripts/.cvsignore new file mode 100644 index 00000000..f3c7a7c5 --- /dev/null +++ b/scripts/.cvsignore @@ -0,0 +1 @@ +Makefile diff --git a/scripts/Makefile.in b/scripts/Makefile.in new file mode 100644 index 00000000..c3971066 --- /dev/null +++ b/scripts/Makefile.in @@ -0,0 +1,75 @@ +# Copyright (C) 1998,1999,2000,2001,2002 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 +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# NOTE: Makefile.in is converted into Makefile by the configure script +# in the parent directory. Once configure has run, you can recreate +# the Makefile by running just config.status. + +# Variables set by configure + +VPATH= @srcdir@ +srcdir= @srcdir@ +bindir= @bindir@ +prefix= @prefix@ +exec_prefix= @exec_prefix@ + +CC= @CC@ +CHMOD= @CHMOD@ +INSTALL= @INSTALL@ + +DEFS= @DEFS@ + +# Customizable but not set by configure + +OPT= @OPT@ +CFLAGS= $(OPT) $(DEFS) +SCRIPTSDIR= $(prefix)/scripts + +SHELL= /bin/sh + +# Note that `admin' is a backwards compatible alias for `bounces' +# 'subscribe' is an alias for join +# 'unsubscribe' is an alias for leave +SCRIPTS= bounces confirm driver join leave owner post request + +# Modes for directories and executables created by the install +# process. Default to group-writable directories but +# user-only-writable for executables. +DIRMODE= 775 +EXEMODE= 755 +FILEMODE= 644 +INSTALL_PROGRAM=$(INSTALL) -m $(EXEMODE) + + +# Rules + +all: + +install: + for f in $(SCRIPTS); \ + do \ + $(INSTALL) -m $(FILEMODE) $(srcdir)/$$f $(SCRIPTSDIR); \ + done + $(INSTALL) -m $(FILEMODE) $(srcdir)/bounces $(SCRIPTSDIR)/admin + $(INSTALL) -m $(FILEMODE) $(srcdir)/join $(SCRIPTSDIR)/subscribe + $(INSTALL) -m $(FILEMODE) $(srcdir)/leave $(SCRIPTSDIR)/unsubscribe + +finish: + +clean: + +distclean: + -rm Makefile diff --git a/scripts/bounces b/scripts/bounces new file mode 100644 index 00000000..b93c6d60 --- /dev/null +++ b/scripts/bounces @@ -0,0 +1,61 @@ +# -*- python -*- +# +# Copyright (C) 2001 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 +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +"""Process VERP'd bounces. + +Called by the wrapper, stdin is the mail message, and argv[1] is the name +of the target mailing list. + +Errors are redirected to logs/errors. +""" + +import sys + +import paths +from Mailman import mm_cfg +from Mailman import Utils +from Mailman.i18n import _ +from Mailman.Queue.sbcache import get_switchboard +from Mailman.Logging.Utils import LogStdErr + +LogStdErr('error', 'bounces') + + + +def main(): + try: + listname = sys.argv[1] + except IndexError: + print >> sys.stderr, _('bounces script got no listname.') + sys.exit(1) + # Make sure the list exists + if not Utils.list_exists(listname): + print >> sys.stderr, _('bounces script, list not found: %(listname)s') + sys.exit(1) + # Immediately queue the message for the bounces qrunner to process. The + # advantage to this approach is that messages should never get lost -- + # some MTAs have a hard limit to the time a filter prog can run. Postfix + # is a good example; if the limit is hit, the proc is SIGKILL'd giving us + # no chance to save the message. + bounceq = get_switchboard(mm_cfg.BOUNCEQUEUE_DIR) + bounceq.enqueue(sys.stdin.read(), listname=listname, _plaintext=1) + + + +if __name__ == '__main__': + main() diff --git a/scripts/confirm b/scripts/confirm new file mode 100755 index 00000000..653940ae --- /dev/null +++ b/scripts/confirm @@ -0,0 +1,62 @@ +# -*- python -*- +# +# Copyright (C) 2002 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 +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +"""Simple confirm via VERP-ish sender. + +Called by the wrapper, stdin is the mail message, and argv[1] is the name +of the target mailing list. + +Errors are redirected to logs/errors. +""" + +import sys + +import paths +from Mailman import mm_cfg +from Mailman import Utils +from Mailman.i18n import _ +from Mailman.Queue.sbcache import get_switchboard +from Mailman.Logging.Utils import LogStdErr + +LogStdErr('error', 'confirm') + + + +def main(): + try: + listname = sys.argv[1] + except IndexError: + print >> sys.stderr, _('confirm script got no listname.') + sys.exit(1) + # Make sure the list exists + if not Utils.list_exists(listname): + print >> sys.stderr, _('confirm script, list not found: %(listname)s') + sys.exit(1) + # Immediately queue the message for the bounce/cmd qrunner to process. + # The advantage to this approach is that messages should never get lost -- + # some MTAs have a hard limit to the time a filter prog can run. Postfix + # is a good example; if the limit is hit, the proc is SIGKILL'd giving us + # no chance to save the message. + cmdq = get_switchboard(mm_cfg.CMDQUEUE_DIR) + cmdq.enqueue(sys.stdin.read(), listname=listname, toconfirm=1, + _plaintext=1) + + + +if __name__ == '__main__': + main() diff --git a/scripts/driver b/scripts/driver new file mode 100644 index 00000000..60c8c79e --- /dev/null +++ b/scripts/driver @@ -0,0 +1,243 @@ +# -*- python -*- + +# Copyright (C) 1998,1999,2000,2001,2002 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 +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# This better succeed. If this fails, Python is royally screwed so we might +# as well let the Web server give us a fatal and obtrusive error. +import sys + +# From here on we are as bulletproof as possible! + +# The driver script prints out a lot of information when a Mailman bug is +# encountered. This really helps for development, but it also reveals +# information about the host system that some administrators are not +# comfortable with. By setting STEALTH_MODE to 1, you disable the printing of +# this information to the web pages. This information is still, and always, +# printed in the error logs. +STEALTH_MODE = 0 + + + +# This standard driver script is used to run CGI programs, wrapped in code +# that catches errors, and displays them as HTML. This guarantees that +# (almost) any problem in the Mailman software doesn't result in a Web server +# error. It is much more helpful to generate and show a traceback, which the +# user could send to the administrator, than to display a server error and +# have to trudge through server logs. + +# Note: this isn't 100% perfect! Here are some things that can go wrong that +# are not caught and reported as traceback-containing HTML: +# +# - This file could contain a syntax error. In that case, you would indeed +# get a Web server error since this file wouldn't even compile, and there's +# no way to catch that. Mailman's install procedure should make this highly +# unlikely. +# +# - The sys module could be royally screwed, probably we couldn't import it. +# This would indicate a serious problem with the Python installation, so +# it's also highly unlikely to occur. + + +def run_main(): + # These will ensure that even if something between now and the + # creation of the real logger below fails, we can still get + # *something* meaningful. + logger = None + try: + import paths + # Map stderr to a logger, if possible. + from Mailman.Logging.StampedLogger import StampedLogger + logger = StampedLogger('error', + label='admin', + manual_reprime=1, + nofail=0, + immediate=1) + # Collect stdout in a cStringIO so that if /any/ errors occur during + # printing it won't mess up our diagnostics page. + from cStringIO import StringIO + tempstdout = StringIO() + # The name of the module to run is passed in argv[1]. What we + # actually do is import the module named by argv[1] that lives in the + # Mailman.Cgi package. That module must have a main() function, which + # we dig out and call. + scriptname = sys.argv[1] + # See the reference manual for why we have to do things this way. + # Note that importing should have no side-effects! + pkg = __import__('Mailman.Cgi', globals(), locals(), [scriptname]) + module = getattr(pkg, scriptname) + main = getattr(module, 'main') + try: + try: + sys.stderr = logger + sys.stdout = tempstdout + main() + sys.__stdout__.write(tempstdout.getvalue()) + finally: + sys.stderr = sys.__stderr__ + sys.stdout = sys.__stdout__ + except SystemExit: + # This is a valid way for the function to exit. + pass + except: + print_traceback(logger) + print_environment(logger) + + + +# We are printing error reporting to two places. One will always be stdout +# and the other will always be the log file. It is assumed that stdout is an +# HTML sink and the log file is a plain text sink. + +def print_traceback(logfp=None): + if logfp is None: + logfp = sys.__stderr__ + + try: + import traceback + except ImportError: + traceback = None + try: + from Mailman.mm_cfg import VERSION + except ImportError: + VERSION = '<undetermined>' + + # Write to the log file first. + print >> logfp, '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@' + print >> logfp, '[----- Mailman Version: %s -----]' % VERSION + print >> logfp, '[----- Traceback ------]' + if traceback: + traceback.print_exc(file=logfp) + else: + print >> logfp, '[failed to import module traceback]' + print >> logfp, '[exc: %s, var: %s]' % sys.exc_info()[0:2] + + # Write to the HTML sink. + print """\ +Content-type: text/html + +
If you would like to help us identify the problem, +please email a copy of this page to the webmaster for this site with +a description of what happened. Thanks! + +
''' + if traceback: + traceback.print_exc(file=sys.stdout) + else: + print '[failed to import module traceback]' + print '[exc: %s, var: %s]' % sys.exc_info()[0:2] + print '\n\n' + else: + print '''
Please inform the webmaster for this site of this +problem. Printing of traceback and other system information has been +explicitly inhibited, but the webmaster can find this information in the +Mailman error logs.''' + + + +def print_environment(logfp=None): + if logfp is None: + logfp = sys.__stderr__ + + try: + import os + except ImportError: + os = None + + # Write some information about our Python executable to the log file. + print >> logfp, '[----- Python Information -----]' + print >> logfp, 'sys.version =', sys.version + print >> logfp, 'sys.executable =', sys.executable + print >> logfp, 'sys.prefix =', sys.prefix + print >> logfp, 'sys.exec_prefix =', sys.exec_prefix + print >> logfp, 'sys.path =', sys.exec_prefix + print >> logfp, 'sys.platform =', sys.platform + + # Write the same information to the HTML sink. + if not STEALTH_MODE: + print '''\ +
Variable | Value |
---|---|
sys.version | ', \ + sys.version, ' |
sys.executable | ', \ + sys.executable, ' |
sys.prefix | ', sys.prefix, ' |
sys.exec_prefix | ', \ + sys.exec_prefix, ' |
sys.path | ', \ + sys.exec_prefix, ' |
sys.platform | ', \ + sys.platform, ' |
Variable | Value |
---|---|
', k, ' | ', v, ' |