nmh-workers
[Top] [All Lists]

[Nmh-workers] Re: ADMINISTRIVIA: Change to mailing list policy

2006-03-06 23:08:59
Ken Hornstein <kenh@cmf.nrl.navy.mil> writes:

I am announcing a change to the nmh-workers mailing list policy.  Effective
today, I am changing the default mailing list action for posts from
non-members from "hold" (meaning: "hold for moderator approval") to
"reject" (you get a bounce message).

Ken, I got mailman-discard from SourceForge, and modified it a lot. It
discards the spam in bulk:

  mailman-discard --base http://lists.nongnu.org/mailman/admin nmh-workers

Alternatively, you can also do this:

  mailman-discard --base http://lists.nongnu.org/mailman/admin \
                  --disposition approve nmh-workers

Although I tend to use the following to let folks know they need to
subscribe (and possibly turn off mail delivery):

  mailman-discard --base http://lists.nongnu.org/mailman/admin \
                  --disposition reject nmh-workers

I just upgraded to Mailman 2.1 on mail.newt.com and discovered I need
to update the script though. I've attached it, for what's worth.

Earl Hood <earl@earlhood.com> writes:

I recommend "discard".  Spammers are known to use originating addresses
of regular people, so you can potentially be the cause of receiving
more spam due to mis-directed bounces.

Unfortunately, this is worse because legitimate posters don't get a
notification that their message didn't get through.

Josh Bressers <josh@bress.net> writes:
I'll do it, that policy is insane.

Hardly. Most mailing lists are administered that way for good reason.
You might have just earned yourself a thankless, onerous, task with
that rude response.

#!/usr/bin/perl -W
#
# mailman-discard.pl - Perform automated processing of Mailman list admin queue
# Based on code originally released in to the Public Domain by Dominic Mazzoni
# in 2003, with updates by Bruce Korb and the SourceForge.net team
# NO WARRANTY
#
# VERSION: SF.net 0.4
#
# SF.net VERSION HISTORY:
#   0.1 - Cleanup merge of two original versions; untested
#   0.2 - Fixes based on initial testing; tested
#   0.3 - Change code to clear password after each list if interactive; tested
#   0.4 - Add -k flag handling to support both old and new curl revs; tested
#
# UPDATE HISTORY:
#   Original by Dominic Mazzoni:
#     
https://sourceforge.net/tracker/index.php?func=detail&aid=762601&group_id=1&atid=200001
#   Update by Bruce Korb:
#     
https://sourceforge.net/tracker/index.php?func=detail&aid=818383&group_id=1&atid=200001
#   Updates from the SourceForge.net team may be found at:
#     https://sourceforge.net/projects/sitedocs/
#
# OBTAINING CURL:
#   'curl', used to perform the necessary web operations, may be obtained from:
#     http://curl.haxx.se/
#   'curl' is also included in most Linux distributions.
#     'apt-get install curl' for Debian GNU/Linux users.
#     'update -i curl' for Red Hat Linux or Fedora Linux users.
#   Mac OS X users may obtain curl from the Fink project:
#     http://fink.sourceforge.net
#   Tested with:
#     curl 7.10.6 (i386-redhat-linux-gnu)
#     curl 7.9.5 (i386-redhat-linux-gnu)
#
# SECURITY NOTE:
#   This script is presently set up to call 'curl' with the '-k' option
#   which permits insecure connections.  This has been done because there
#   are quite a few machines out there that have not been updated to recent
#   versions of curl which are able to cope with wildcard SSL certificates.
#   You are welcome to remove the '-k' flag from the curl call below in your
#   own copies of this script, of course, and this is recommended if you
#   are running a more modern version of 'curl'.


use Getopt::Long;
use strict;

my $disposition = "discard";
my $help = 0;
my $mailman_base = "https://lists.sourceforge.net/lists/admindb";;
my $passwd;

# Parse command line.
my %opts;
GetOptions('base=s'             => \$mailman_base,
           'disposition=s'      => \$disposition,
           'help'               => \$help,
           ) or usage();

usage() if ($help || $#ARGV < 0);

my $out=`curl --help`;
my $curl_supports_dash_k = "";
if ($out =~ /-k\/--insecure/) {
    $curl_supports_dash_k = " -k ";
}

my $optype;
if ($disposition =~ /^approve$/i) {
    $optype = 1;
} elsif ($disposition =~ /^reject$/i) {
    $optype = 2;
} elsif ($disposition =~ /^discard$/i) {
    $optype = 3;
} else {
    print "Unknown disposition $disposition.\n\n";
    usage();
}
$disposition =~ s/(\w+)/\u\L$1/; # capitalize for purge_list output

if (@ARGV) {
    foreach (@ARGV) {
        $passwd = $ENV{SF_PASSWD};
        purge_list($_);
    }
}

sub usage {
    print <<EOF;
Usage: mailman-discard.pl [options] list [list...]

--base URL
    Use this to affect other mailman servers (default:
    https://lists.sourceforge.net/lists/admindb).

--dispositon disposition
    Disposition can be one of approve, reject, or discard (default). Case is
    ignored. This disposition is applied to all messages in the admin queue.

Examples:

  mailman-discard myproject-mylist
  mailman-discard --base http://www.domain.com/mailman/admindb
                  --disp approve

The list admin password is prompted for unless given via the SF_PASSWD
environment variable. Please note that the Mailman list admin password IS NOT
the same as your user account password.

This script uses 'curl' to connect to the Mailman server.
EOF
    die "\n";
}

sub purge_list {
    my ($list) = @_;

    if (! $passwd) {
        print "Mailman admin password for list $list: ";
        $passwd = <STDIN>;
        chop $passwd;
    }

    # Retrieve the list of messages to process.
    print "Retrieving info for $list...";
    my $curlcmd = "curl --data 'adminpw=$passwd'";
    my $listurl = "$mailman_base/$list";
    my ($count, $data);
    my $out = `$curlcmd $listurl 2>/dev/null`;

    if ($out =~ / Administrative Authentication/) {
        print "password incorrect\n";
        return;
    }

    $count = 0;
    $data = "";
    my $match = 'INPUT name="([0-9]+)" type="RADIO" value="'. $optype . '"';

    foreach (split("\n", $out)) {
        # For each message to process
        if ($_ =~ $match) {
            $count++;
            # Construct the URL for response
            if ($data eq "") {
                $data = "$1=$optype";
            } else {
                $data = "$data&$1=$optype";
            }
        }

        if ($_ =~ 'no pending requests') {
            print "no pending requests\n";
            return;
        }
    }

    if ($count == 0) {
        print "unknown mailing list\n";
        return 0;
    }

    print "done\n";

    $disposition =~ s/e$//;             # delete final e before adding ing.
    print "${disposition}ing $count messages for $list...";
    $out = `$curlcmd --data "$data" $listurl 2>/dev/null`;

    foreach (split("\n", $out)) {
        if ($_ =~ 'no pending requests') {
            print "done\n";
            return;
        }

        if ($_ =~ $match) {
            print "new messages have arrived\n";
            return;
        }
    }

    print "done (possible error)\n";
}

-- 
Bill Wohler <wohler@newt.com>  http://www.newt.com/wohler/  GnuPG ID:610BD9AD
Maintainer of comp.mail.mh FAQ and MH-E. Vote Libertarian!
If you're passed on the right, you're in the wrong lane.
_______________________________________________
Nmh-workers mailing list
Nmh-workers@nongnu.org
http://lists.nongnu.org/mailman/listinfo/nmh-workers
<Prev in Thread] Current Thread [Next in Thread>