Subject: Usenet Death Penalty
From: [email-masked] (Rich Salz)
Date: 18 Aug 1993 20:06:50 -0400
Newsgroups: news.admin.technical

Cancel wars seem to be on the rise.  It's too bad people aren't more
mature -- it's on the same level as urinating in the public swimming
pool.  At the risk of adding to the amount of waste, here is what some
might consider to be the final word on the matter.  It's a Perl script
intended to be run as a real-time feed by INN.  It should be able to
cancel articles within seconds after they hit your site.
	/r$

#! /usr/bin/perl
##  Usenet death penalty; Rich $alz <[email-masked]>, April 93.
##  Original name and concept by Eliot Lear, years ago.
##
##  Typical use is via this entry in newsfeeds file:
##	udp:*:Tc,WO:.../udp [flags] 'rsalz@.*.uu.net'
##  Flags are '-global' to post cancel messages (default just removes
##  articles from your local spool) and '-debug' to send cancels to
##  stdout.  First (and only) arg is Perl regexp to match against From
##  line; to kill multiple people use the | meta-char.

##  Parse JCL.
$local = 1;
$production = 1;
args: while ( $_ = $ARGV[0], /^-/ ) {
    shift;
    if ( $_ eq '-debug' ) {
	$production = 0;
	next args;
    }
    if ( $_ eq '-global' ) {
	$local = 0;
	next args;
    }
    die 'Bad flag\n';
}
$who = shift || die 'Not enough args.\n';
shift && die 'Too many args.\n';

##  Set header values if we're going to be posting.
if ( $local == 0 ) {
    $pathhost = `innconfval pathhost`;
    chop($pathhost);
    @pw = getpwuid($<);
    $canceller = $pathhost . '!' . $pw[0];
    ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = gmtime;
    $year += 1900;
    $monthname = substr('JanFebMarAprMayJunJulAugSepOctNovDec', $mon * 3, 3);
    $date = "$mday $monthname $year $hour:$min:$sec GMT";
}

##  Main loop; process each line.
line: while ( <STDIN> ) {
    next line unless ( $paths, $subj, $from, $xdate, $msgid ) = split('\t', $_);
    next line unless $from =~ /$who/io;

    if ( $local ) {
	foreach ( split(' ', $paths) ) {
	    unlink $_
		|| warn "Can't unlink $_ $!";
	}
    } else {
	open(FH, '|rnews') && select FH
	    if $production;
	$myid = $msgid;
	$myid =~ s/</<cancel-/;
	print 'Newsgroups: news.admin
Path: ', $canceller, '
Subject: cmsg cancel ', $msgid, '
Control: cancel ', $msgid, '
From: ', $from, '
Date: ', $date, '
Message-ID: ', $myid, '

';
	close(FH)
	    if $production;
    }
}
exit(0);

##  lint noise:
print $isdst + $wday + $yday + $subj + $xdate;