[Mailman-Users] Perl scripts to convert Listproc lists to Mailman

Michael James michael at james.st
Mon Oct 14 07:20:48 CEST 2002


Dear Mailman-users,

Here is the 3rd perl-script
 mainly aimed at porting lists from Listproc to Mailman,
 but this one makes no reference to listproc.
It just changes the settings on a number of lists.

When lists are created using "newlist"
 they come up with unacceptably loose permissions.

In descending order of disasterousness:

The list is postable-to by anybody.
	member_posting_only = 0

The list is not moderated
	moderated = 0

These 2 options mean anyone can spam the list.
And whether it's malicious, objectionable or infected; it's bad.

Other settings you might like to tighten up a bit:

The subscription list is viewable by anybody.
	private_roster = 0

The archives are public.
	archive_private = 0

There is a file Mailman/Defaults.py where you can set your own defaults
 but under member_posting_only = 1 it says "When it works".
Not encouraging!

Hence this script.

Edit the formal variables at the beginning to suit your site.
Edit the defaults after __DATA__ to suit your taste.

run:   set-list-defaults list of lists
 or:	set-list-defaults ALL

It will ask you before it changes anything, stop it there
 and look at the file tmp/defaults_for_all_lists
 to see what was about to happen.


The next installment will debrief Listproc
 and configure individual Mailman lists accordingly.
If there is enough interest, I'll look at archives.

michaelj


Perl follows:



#!/usr/local/bin/perl

$LISTPROC       = '/home/alianet/server';
$MAILMAN        = '/usr/lib/mailman';
$TMP_DIR        = 'tmp';
$DEFAULTS       = "$TMP_DIR/defaults_for_all_lists";

$VI             = '/bin/vi';
$LIST_LISTS     = "$MAILMAN/bin/list_lists";
$CONFIG_LIST    = "$MAILMAN/bin/config_list";


@ARGV or die "Usage: $0 list [list] etc...\n",
        "   or: $0 ALL [-list_to_leave_out]\n";


# Get the DATA from the end of this file
#  and cook up the defaults file to be loaded for each list.
-d $TMP_DIR or mkdir $TMP_DIR;
open(OUT, "> $DEFAULTS") or die "Can't write $DEFAULTS\n";
while (<DATA>)
{       chop;
        /^\s*$/ and next;       # ignore blank lines
        /^\s*#/ and next;       # and comments
        print OUT $_, "\n";
}
close OUT;


# Now get all the lists present into %all_lists
open(IN, "$LIST_LISTS |") or
        die "Can't list lists with $LIST_LISTS\n";
my $Name, %all_lists;
while (<IN>)
{       chop;

        s/ matching mailing lists found:/ Mailing Lists present./ and do
        {       print $_, "\n";
                next;
        };

        s/^\s+//;       # shave leading whitespace
        s/\s+-\s.*$//;  # take off description
        $Name = $_;     # keep capitalization
        tr/A-Z/a-z/;    # Canonicalize name by lowercasing it

        # My test for a valid list name:
        #       at least 2 characters
        #       begins with alpha
        #       alphanumeric, "-" and ".";
        if ( /../ and /^[a-zA-Z]/ and ! /[^-.\w\d]/ )
                { $all_lists{$_} = $Name; }
        else
        {       warn "Illegal list name $Name\n";
                next;
        }
}

# Work out from the command line which lists to do
my($count, %todo_list) = 0;
foreach (@ARGV)
{
        # Add it or delete it?
        $delete = 0;
        s/^-// and ++$delete;

        /^ALL$/ and do
        {       $delete and die "What's this '-ALL' nonsense?\n",
                        "You can only subtract lists one at a time\n";

                foreach (keys(%all_lists))
                {       ++$count;
                        $todo_list{$_} = $all_lists{$_};
                }
                next;
        };

        $Name = $_;
        tr/A-Z/a-z/;

        $all_lists{$_} or die "We don't have a list '$Name'\n";

        if ( $delete )
        {       $all_lists{$_} and delete($all_lists{$_});
                $todo_list{$_} and delete($todo_list{$_}) and --$count;
                next;
        }

        ++$count;
        $todo_list{$_} = $Name;
}

print "About to set defaults for $count lists:\n";
foreach (sort(keys(%todo_list))) { print "\t$todo_list{$_}\n"; }
print "  Procede?  ";
my $ok = <STDIN>;
$ok =~ /^y/ or die "Nothing changed.\n";

# Actually do it
print "Changing these options:\n";
my @options = ('-v', '-i');     # run verbose first time
foreach (sort(keys(%todo_list)))
{
        system $CONFIG_LIST, @options, $DEFAULTS, $_;
        @options = ('-i');      # no more -v after first run
}

__DATA__


## This is the defaults that will get set on all lists.
## captured on Mon Oct 14 10:58:19 200^2

## General options
#
# Fundamental list characteristics, including descriptive info and basic
# behaviors.

# welcome message.  The rest of the welcome message already describes
# the important addresses and URLs for the mailing list, so you don't
# need to include any of that kind of stuff here.  This should just
# contain mission-specific kinds of things, like etiquette policies or
# team orientation, or that kind of thing.
#welcome_msg = ''

# Text sent to people leaving the list.  If empty, no special text will
# be added to the unsubscribe message.
#goodbye_msg = "Trying wasn't it..."

# This option controls what Mailman does to the Reply-To:
# header in messages flowing through this mailing list.
# legal values are:
#    0 = "Poster"
#    1 = "This list"    # BAD BAD BAD
#    2 = "Explicit address"
reply_goes_to_list = 0

# This is the address set in the Reply-To: header when the
# last option is set to 2  (Explicit address).
# 
#reply_to_address = ''

# Administrivia tests will check postings to see whether it's really
# meant as an administrative request (like subscribe, unsubscribe, etc),
# and will add it to the the administrative requests queue, notifying
# the  administrator of the new request, in the process. 
#
# legal values are:
#    0 = "No"
#    1 = "Yes"
administrivia = 1

# Send monthly password reminders or no? Overrides the previous option.
#
# legal values are:
#    0 = "No"
#    1 = "Yes"
send_reminders = 1

# Turn this on only if you plan on subscribing people manually and don't
# want them to know that you did so.  This option is most useful for
# transparently migrating lists from some other mailing list manager to
# Mailman.
#
# legal values are:
#    0 = "No"
#    1 = "Yes"
send_welcome_msg = 1

# List admins are sent daily reminders of pending admin approval
# requests, like subscriptions to a moderated list or postings that are
# being held for one reason or another.  Setting this option causes
# notices to be sent immediately on the arrival of new requests, as
# well.
#
# legal values are:
#    0 = "No"
#    1 = "Yes"
admin_immed_notify = 1

# Should administrator get notices of subscribes/unsubscribes?
#
# legal values are:
#    0 = "No"
#    1 = "Yes"
admin_notify_mchanges = 1

# Approval notices are sent when mail triggers certain of the limits
# <em>except</em> routine list moderation and spam filters, for which
# notices are <em>not</em> sent.  This option overrides ever sending the
# notice.
#
# legal values are:
#    0 = "Yes"
#    1 = "No"
dont_respond_to_post_requests = 0

# Maximum length in Kb of a message body.  Use 0 for no limit.
max_message_size = 40

# The host_name is the preferred name for email to mailman-related
# addresses on this host, and generally should be the mail host's
# exchanger address, if any.  This setting can be useful for selecting
# among alternative names of a host that has multiple addresses.
host_name = 'lists.alia.org.au'

# This is the common root for all Mailman URLs referencing this
#  mailing list.  It is also used in the listinfo overview
# of mailing lists to identify whether or not this list
# resides on the virtual host identified by the overview
web_page_url = 'http://lists.alia.org.au/mailman/'

## Privacy options
#
# List access policies, including anti-spam measures, covering members
# and outsiders.  (See also the <a
# href="http://lists.alia.org.au/mailman/admin/experimental/archive">Archival 
# Options section</a> for separate archive-privacy settings.)

# Advertise this list when people ask what lists are on this machine?
#
# legal values are:
#    0 = "No"
#    1 = "Yes"
advertised = 1

# confirm (*) - email confirmation required <br>require approval -
# require list administrator approval for subscriptions
# <br>confirm+approval - both confirm and approve<p> (*) when someone
# requests a subscription, mailman sends them a notice with a unique
# subscription request number that they must reply to in order to
# subscribe.<br> This prevents mischievous (or malicious) people from
# creating subscriptions for others without their consent.
#
# legal values are:
#    1 = "confirm"
#    2 = "require approval"
#    3 = "confirm+approval"
subscribe_policy = 3

# When set, the list of subscribers is protected by member or admin
# password authentication.
#
# legal values are:
#    0 = "Anyone"
#    1 = "List members"
#    2 = "List admin only"
private_roster = 2

# Setting this option causes member email addresses to be transformed
# when they are presented on list web pages (both in text and as links),
# so they're not trivially recognizable as email addresses.  The
# intention is to to prevent the addresses from being snarfed up by
# automated web scanners for use by spammers.
#
# legal values are:
#    0 = "No"
#    1 = "Yes"
obscure_addresses = 1

# Must posts be approved by an administrator?
#
# legal values are:
#    0 = "No"
#    1 = "Yes"
moderated = 1

# Use this option if you want to restrict posting to list members. If
# you want list members to be able to post, plus a handful of other
# posters, see the <i> posters </i> setting below
#
# legal values are:
#    0 = "No"
#    1 = "Yes"
member_posting_only = 1

# Adding entries here will have one of two effects, according to whether
# another option restricts posting to members. <ul> <li> If
# <i>member_posting_only</i> is 'yes', then entries added here will have
# posting privilege in addition to list members. <li> If
# <i>member_posting_only</i> is 'no', then <em>only</em> the posters
# listed here will be able to post without admin approval. </ul>
posters = []

# Many (in fact, most) spams do not explicitly name their myriad
# destinations in the explicit destination addresses - in fact, often
# the to field has a totally bogus address for obfuscation.  The
# constraint applies only to the stuff in the address before the '@'
# sign, but still catches all such spams.<p>The cost is that the list
# will not accept unhindered any postings relayed from other addresses,
# unless <ol> <li>The relaying address has the same name, or <li>The
# relaying address name is included on the options that specifies
# acceptable aliases for the list. </ol>
#
# legal values are:
#    0 = "No"
#    1 = "Yes"
require_explicit_destination = 1

# Alternate addresses that are acceptable when
# `require_explicit_destination' is enabled.  This option takes a list
# of regular expressions, one per line, which is matched against every
# recipient address in the message.  The matching is performed with
# Python's re.match() function, meaning they are anchored to the start
# of the string. <p>For backwards compatibility with Mailman 1.1, if the
# regexp does not contain an `@', then the pattern is matched against
# just the local part of the recipient address.  If that match fails, or
# if the pattern does contain an `@', then the pattern is matched
# against the entire recipient address.  <p>Matching against the local
# part is deprecated; in a future release, the pattern will always be
# matched against the  entire recipient address.
acceptable_aliases = ''

# If a posting has this number, or more, of recipients, it is held for
# admin approval.  Use 0 for no ceiling.
max_num_recipients = 10

# Email addresses whose posts should always be held for approval, no
# matter what other options you have set. See also the subsequent option
# which applies to arbitrary content of arbitrary headers.
forbidden_posters = ['virus.scan']

# Use this option to prohibit posts according to specific header values.
# The target value is a regular-expression for matching against the
# specified header.  The match is done disregarding letter case.  Lines
# beginning with '#' are ignored as comments.<p>For example:<pre>to:
# .*@public.com </pre> says to hold all postings with a <em>to</em> mail
# header containing '@public.com' anywhere among the addresses.<p>Note
# that leading whitespace is trimmed from the regexp.  This can be
# circumvented in a number of ways, eg by escaping or bracketing it.<p>
# See also the <em>forbidden_posters</em> option for a related
# mechanism.
#bounce_matching_headers ="""# Lines that *start* with a '#' are comments.
#to: friend at public.com
#message-id: relay.comanche.denmark.eu
#from: list at listme.com
#from: .*@uplinkpro.com
#"""

# Hide the sender of a message, replacing it with the list address
# (Removes From, Sender and Reply-To fields)
#
# legal values are:
#    0 = "No"
#    1 = "Yes"
anonymous_list = 0

## Nondigest options
#
# Policies concerning immediately delivered list traffic.

# Can subscribers choose to receive mail immediately, rather than in
# batched digests?
#
# legal values are:
#    0 = "No"
#    1 = "Yes"
nondigestable = 1

# Text prepended to the top of every immediately-delivery message. This
# text can include <b><code>%(attribute)s</code></b> format strings
# which are resolved against the list's attributes.  For details, see <a
# href="http://www.python.org/doc/current/lib/typesseq-strings.html">Python's 
# string formatting rules</a>.  Some useful attributes are:
# 
# <ul>
#     <li><b><code>real_name</code></b> - The `pretty' name of the list;
# usually
#     the list name with capitalization.
# 
#     <li><b><code>_internal_name</code></b> - The name by which the
# list is
#     identified in URLs, where case is significant.
# 
#     <li><b><code>host_name</code></b> - The fully qualified domain
# name
#     that the list server runs on.
# 
#     <li><b><code>web_page_url</code></b> - The base URL for Mailman.
# This
#     can be appended with,
#     e.g. <em><code>listinfo/%(_internal_name)s</code></em> to yield
# the
#     listinfo page for the mailing list.
# 
#     <li><b><code>description</code></b> - The brief description of the
#     mailing list.
# 
#     <li><b><code>info</code></b> - The full description of the mailing
#     list.
# </ul>
# 
#msg_header = ''

# Text appended to the bottom of every immediately-delivery message.
# This text can include <b><code>%(attribute)s</code></b> format strings
# which are resolved against the list's attributes.  For details, see <a
# href="http://www.python.org/doc/current/lib/typesseq-strings.html">Python's 
# string formatting rules</a>.  Some useful attributes are:
# 
# <ul>
#     <li><b><code>real_name</code></b> - The `pretty' name of the list;
# usually
#     the list name with capitalization.
# 
#     <li><b><code>_internal_name</code></b> - The name by which the
# list is
#     identified in URLs, where case is significant.
# 
#     <li><b><code>host_name</code></b> - The fully qualified domain
# name
#     that the list server runs on.
# 
#     <li><b><code>web_page_url</code></b> - The base URL for Mailman.
# This
#     can be appended with,
#     e.g. <em><code>listinfo/%(_internal_name)s</code></em> to yield
# the
#     listinfo page for the mailing list.
# 
#     <li><b><code>description</code></b> - The brief description of the
#     mailing list.
# 
#     <li><b><code>info</code></b> - The full description of the mailing
#     list.
# </ul>
# 
#msg_footer ="""_______________________________________________
#%(real_name)s mailing list
#%(real_name)s@%(host_name)s
#%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
#"""

## Digest options
#
# Batched-delivery digest characteristics.

# Can list members choose to receive list traffic bunched in digests?
#
# legal values are:
#    0 = "No"
#    1 = "Yes"
digestable = 1

# Which delivery mode is the default for new users?
#
# legal values are:
#    0 = "Regular"
#    1 = "Digest"
digest_is_default = 0

# When receiving digests, which format is default?
#
# legal values are:
#    0 = "Plain"
#    1 = "Mime"
mime_is_default_digest = 0

# How big in Kb should a digest be before it gets sent out?
digest_size_threshhold = 30

# Should a digest be dispatched daily when the size threshold isn't
# reached?
#
# legal values are:
#    0 = "No"
#    1 = "Yes"
digest_send_periodic = 1

# Text attached (as an initial message, before the table of contents) to
# the top of digests. This text can include
# <b><code>%(attribute)s</code></b> format strings which are resolved
# against the list's attributes.  For details, see <a
# href="http://www.python.org/doc/current/lib/typesseq-strings.html">Python's 
# string formatting rules</a>.  Some useful attributes are:
# 
# <ul>
#     <li><b><code>real_name</code></b> - The `pretty' name of the list;
# usually
#     the list name with capitalization.
# 
#     <li><b><code>_internal_name</code></b> - The name by which the
# list is
#     identified in URLs, where case is significant.
# 
#     <li><b><code>host_name</code></b> - The fully qualified domain
# name
#     that the list server runs on.
# 
#     <li><b><code>web_page_url</code></b> - The base URL for Mailman.
# This
#     can be appended with,
#     e.g. <em><code>listinfo/%(_internal_name)s</code></em> to yield
# the
#     listinfo page for the mailing list.
# 
#     <li><b><code>description</code></b> - The brief description of the
#     mailing list.
# 
#     <li><b><code>info</code></b> - The full description of the mailing
#     list.
# </ul>
# 
#digest_header = ''

# Text attached (as a final message) to the bottom of digests. This text
# can include <b><code>%(attribute)s</code></b> format strings which are
# resolved against the list's attributes.  For details, see <a
# href="http://www.python.org/doc/current/lib/typesseq-strings.html">Python's 
# string formatting rules</a>.  Some useful attributes are:
# 
# <ul>
#     <li><b><code>real_name</code></b> - The `pretty' name of the list;
# usually
#     the list name with capitalization.
# 
#     <li><b><code>_internal_name</code></b> - The name by which the
# list is
#     identified in URLs, where case is significant.
# 
#     <li><b><code>host_name</code></b> - The fully qualified domain
# name
#     that the list server runs on.
# 
#     <li><b><code>web_page_url</code></b> - The base URL for Mailman.
# This
#     can be appended with,
#     e.g. <em><code>listinfo/%(_internal_name)s</code></em> to yield
# the
#     listinfo page for the mailing list.
# 
#     <li><b><code>description</code></b> - The brief description of the
#     mailing list.
# 
#     <li><b><code>info</code></b> - The full description of the mailing
#     list.
# </ul>
# 
#digest_footer ="""_______________________________________________
#%(real_name)s mailing list
#%(real_name)s@%(host_name)s
#%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
#"""

## Bounce options
#
# Policies regarding systematic processing of bounce messages, to help
# automate recognition and handling of defunct addresses.

# Try to figure out error messages automatically? 
#
# legal values are:
#    0 = "No"
#    1 = "Yes"
bounce_processing = 1

# Minimum number of days an address has been non-fatally bad before we
# take action
minimum_removal_date = 7

# Minimum number of posts to the list since members first bounce before
# we consider removing them from the list
minimum_post_count_before_bounce_action = 5

# Maximum number of messages your list gets in an hour.  (Yes, bounce
# detection finds this info useful)
max_posts_between_bounces = 5

# Action when critical or excessive bounces are detected.
#
# legal values are:
#    0 = "Do nothing"
#    1 = "Disable and notify me"
#    2 = "Disable and DON'T notify me"
#    3 = "Remove and notify me"
automatic_bounce_action = 1

## Archive options
#
# List traffic archival policies.

# Archive messages?
#
# legal values are:
#    0 = "No"
#    1 = "Yes"
archive = 1

# Is archive file source for public or private archival?
#
# legal values are:
#    0 = "public"
#    1 = "private"
archive_private = 1

# Set date in archive to when the mail is claimed to have been sent, or
# to the time we resend it?
#
# legal values are:
#    0 = "When sent"
#    1 = "When resent"
clobber_date = 0

# How often should a new archive volume be started?
#
# legal values are:
#    0 = "Yearly"
#    1 = "Monthly"
#    2 = "Quarterly"
#    3 = "Weekly"
#    4 = "Daily"
archive_volume_frequency = 1

## Gateway options
#
# Mail-to-News and News-to-Mail gateway services.

# The News server is not part of Mailman proper.  You have to already
# have access to a NNTP server, and that NNTP server has to recognize
# the machine this mailing list runs on as a machine capable of reading
# and posting news.
nntp_host = ''

# The name of the Usenet group to gateway to and/or from.
linked_newsgroup = ''

# Should new posts to the mailing list be sent to the newsgroup?
#
# legal values are:
#    0 = "No"
#    1 = "Yes"
gateway_to_news = 0

# Should new posts to the newsgroup be sent to the mailing list?
#
# legal values are:
#    0 = "No"
#    1 = "Yes"
gateway_to_mail = 0

## Autoreply options
#
# Auto-responder characteristics.<p>
# 
# In the text fields below, Python %(string)s interpolation is performed
# with the following key/value substitutions: <p><ul>
#     <li><b>%(listname)s</b> - <em>gets the name of the mailing
# list</em>
#     <li><b>%(listurl)s</b> - <em>gets the list's listinfo URL</em>
#     <li><b>%(requestemail)s</b> - <em>gets the list's -request
# address</em>
#     <li><b>%(adminemail)s</b> - <em>gets the list's -admin
# address</em>
#     <li><b>%(owneremail)s</b> - <em>gets the list's -owner
# address</em>
# </ul>
# 
# <p>For each text field, you can either enter the text directly into
# the text box, or you can specify a file on your local system to upload
# as the text.

# Should Mailman send an auto-response to mailing list posters?
#
# legal values are:
#    0 = "No"
#    1 = "Yes"
autorespond_postings = 0

# Auto-response text to send to mailing list posters.
autoresponse_postings_text = ''

# Should Mailman send an auto-response to emails sent to the -admin and
# -owner addresses?
#
# legal values are:
#    0 = "No"
#    1 = "Yes"
autorespond_admin = 0

# Auto-response text to send to -admin and -owner emails.
autoresponse_admin_text = ''

# Should Mailman send an auto-response to emails sent to the -request
# address?  If you choose yes, decide whether you want Mailman to
# discard the original email, or forward it on to the system as a normal
# mail command.
#
# legal values are:
#    0 = "No"
#    1 = "Yes, w/discard"
#    2 = "Yes, w/forward"
autorespond_requests = 0

# Auto-response text to send to -request emails.
autoresponse_request_text = ''

# Number of days between auto-responses to either the mailing list or
# -admin/-owner address from the same poster.  Set to zero (or negative)
# for no grace period (i.e. auto-respond to every message).
autoresponse_graceperiod = 90

michaelj at flat /usr/lib/mailman/                                                                     # 
-- 





More information about the Mailman-Users mailing list