summaryrefslogtreecommitdiff
path: root/Mailman/bin
diff options
context:
space:
mode:
authorbwarsaw2006-09-25 00:01:06 +0000
committerbwarsaw2006-09-25 00:01:06 +0000
commit8157935353a960cd03a72e403e8638b016c8e9a1 (patch)
tree00e219530cab575a9d2ec76ee9c90523d14a5275 /Mailman/bin
parent99a4f0ef16e6dfddafbd396896afb97821528f16 (diff)
downloadmailman-8157935353a960cd03a72e403e8638b016c8e9a1.tar.gz
mailman-8157935353a960cd03a72e403e8638b016c8e9a1.tar.zst
mailman-8157935353a960cd03a72e403e8638b016c8e9a1.zip
Convert genaliases to mmshell, optparse, and configuration.config
bin/withlist: If there's no '@' in the listname, append the DEFAULT_EMAIL_HOST so we always get a fully qualified list name. bin/mmsitepass: plumb through -C/--config switch and be sure to call config.load(). Convert Mailman/MTA/Postfix.py to configuration.config, and update MTA/Manual. In mailman/Cgi/create, we can't convert straight from a string to a bool, because bool('0') is True. We need to go through int first. MailList.InitTempVars(): The logic here looked weird because we could get 'name' = None and that would break. Assume name is never None.
Diffstat (limited to 'Mailman/bin')
-rwxr-xr-xMailman/bin/check_perms.py12
-rw-r--r--Mailman/bin/genaliases.py94
-rw-r--r--Mailman/bin/mmsitepass.py8
3 files changed, 101 insertions, 13 deletions
diff --git a/Mailman/bin/check_perms.py b/Mailman/bin/check_perms.py
index c56171b49..0e5124b91 100755
--- a/Mailman/bin/check_perms.py
+++ b/Mailman/bin/check_perms.py
@@ -15,15 +15,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
-"""Check the permissions for the Mailman installation.
-
-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
import sys
import pwd
@@ -359,8 +350,7 @@ def parseargs():
Check the permissions of all Mailman files. With no options, just report the
permission and ownership problems found."""))
parser.add_option('-f', '--fix',
- default=False, action='store_true',
- help=_("""\
+ default=False, action='store_true', help=_("""\
Fix all permission and ownership problems found. With this option, you must
run check_perms as root."""))
parser.add_option('-v', '--verbose',
diff --git a/Mailman/bin/genaliases.py b/Mailman/bin/genaliases.py
new file mode 100644
index 000000000..379b4bd94
--- /dev/null
+++ b/Mailman/bin/genaliases.py
@@ -0,0 +1,94 @@
+#! @PYTHON@
+#
+# Copyright (C) 2001-2006 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA.
+
+import os
+import sys
+import optparse
+
+from Mailman import MailList
+from Mailman import Utils
+from Mailman import Version
+from Mailman.configuration import config
+from Mailman.i18n import _
+
+__i18n_templates__ = True
+
+
+
+def parseargs():
+ parser = optparse.OptionParser(version=Version.MAILMAN_VERSION,
+ usage=_("""\
+%prog [options]
+
+Regenerate the Mailman specific MTA aliases from scratch. The actual output
+depends on the value of the 'MTA' variable in your etc/mailman.cfg file."""))
+ parser.add_option('-q', '--quiet',
+ default=False, action='store_true', help=_("""\
+Some MTA output can include more verbose help text. Use this to tone down the
+verbosity."""))
+ parser.add_option('-C', '--config',
+ help=_('Alternative configuration file to use'))
+ opts, args = parser.parse_args()
+ if args:
+ parser.print_help()
+ print >> sys.stderr, _('Unexpected arguments')
+ sys.exit(1)
+ return parser, opts, args
+
+
+
+def main():
+ parser, opts, args = parseargs()
+ config.load(opts.config)
+
+ # Import the MTA specific module
+ modulename = 'Mailman.MTA.' + config.MTA
+ __import__(modulename)
+ MTA = sys.modules[modulename]
+
+ # We need to acquire a lock so nobody tries to update the files while
+ # we're doing it.
+ lock = MTA.makelock()
+ lock.lock()
+ # Group lists by virtual hostname
+ mlists = {}
+ for listname in Utils.list_names():
+ mlist = MailList.MailList(listname, lock=False)
+ mlists.setdefault(mlist.host_name, []).append(mlist)
+ # Make sure the files are created rw-rw-xxx; it should be okay to be world
+ # readable.
+ omask = os.umask(002)
+ try:
+ MTA.clear()
+ if not mlists:
+ MTA.create(None, nolock=True, quiet=opts.quiet)
+ else:
+ for hostname, vlists in mlists.items():
+ for mlist in vlists:
+ MTA.create(mlist, nolock=True, quiet=opts.quiet)
+ # Be verbose for only the first printed list
+ quiet = True
+ finally:
+ os.umask(omask)
+ lock.unlock(unconditionally=True)
+
+
+
+if __name__ == '__main__':
+ main()
diff --git a/Mailman/bin/mmsitepass.py b/Mailman/bin/mmsitepass.py
index b6576c8fa..3bd2c77d7 100644
--- a/Mailman/bin/mmsitepass.py
+++ b/Mailman/bin/mmsitepass.py
@@ -20,7 +20,8 @@ import getpass
import optparse
from Mailman import Utils
-from Mailman import mm_cfg
+from Mailman import Version
+from Mailman.configuration import config
from Mailman.i18n import _
__i18n_templates__ = True
@@ -28,7 +29,7 @@ __i18n_templates__ = True
def parseargs():
- parser = optparse.OptionParser(version=mm_cfg.MAILMAN_VERSION,
+ parser = optparse.OptionParser(version=Version.MAILMAN_VERSION,
usage=_("""\
%prog [options] [password]
@@ -48,6 +49,8 @@ If password is not given on the command line, it will be prompted for.
Set the list creator password instead of the site password. The list
creator is authorized to create and remove lists, but does not have
the total power of the site administrator."""))
+ parser.add_option('-C', '--config',
+ help=_('Alternative configuration file to use'))
opts, args = parser.parse_args()
if len(args) > 1:
parser.print_help()
@@ -59,6 +62,7 @@ the total power of the site administrator."""))
def main():
parser, opts, args = parseargs()
+ config.load(opts.config)
if args:
password = args[0]
else: