Xref: feenix.metronet.com news.admin.technical:179
Path: feenix.metronet.com!news.utdallas.edu!hermes.chpc.utexas.edu!cs.utexas.edu!uunet!not-for-mail
From: [email protected] (Rich Salz)
Newsgroups: news.admin.technical
Subject: Usenet Death Penalty
Date: 18 Aug 1993 20:06:50 -0400
Organization: UUNET Communications
Lines: 85
Sender: [email protected]
Approved: [email protected]
Distribution: world
Message-ID: <[email protected]>
NNTP-Posting-Host: ftp.uu.net

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 protected]>, 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;