Article View: news.software.nntp
Article #14888Re: how to "re-inject" control messages?
From: Wolfgang Schelongowski
Date: Sun, 09 Feb 1997 00:00
Date: Sun, 09 Feb 1997 00:00
120 lines
4518 bytes
4518 bytes
In <5fk1ot.sbn.hgoldste@bbs.mpcs.com>
hgoldste@mpcs.com (Howard Goldstein) writes:
>Here's a little script I use weekly to process control messages for
>hierarchies not covered by control.ctl . It massages the control
...
I had a look at it and apart from a few minor nitpicks I found
that it always results in an article with Sender: set to the
user who runs that script, and which must have an entry in
control.ctl. That opens the server to attacks from the outside ...
So I wrote the appended Perl script and tested it under Perl 4.036.
If you can not even trust your local users to keep some things secret
(I can :-) you must take measures to allow automatic new-/rmgroups
from $i_am only when you want them to happen.
Note
# YOU MUST CHANGE the first three lines
because you wouldn't somebody calling himself "lorbass" to modify your
active / newsgroups file without your consent ;-) Utilize your
imagination.
If Dave Barr or his successor wants to add this script to his
collection of INN tools s/he is free to do so.
----------------------8<--------------------
#!/usr/bin/perl
#
# reinjectctl.pl ws (at) xivic.ruhr.de 09.02.1997 GNU-Copyleft
#
# Pipe message from nn/elm, this strips off the crap and sends
# it to rnews to do newgroup/rmgroup/whatever.
#
# If the first argument begins with [eE] it is discarded and the
# mail headers up to and including $junkelm are deleted.
# Then, if the first (remaining) argument is 1, 2, or 3, merely
# debugging data is produced.
#
# YOU MUST CHANGE the first three lines and _append_ a line like
# "all:lorbass@xivic.ruhr.de:*:doit=locctl"
# to your control.ctl.
# You may need to edit the next two lines ($gruppe/$rnews).
$host = "xivic";
$domain = "ruhr.de";
$name = "lorbass";
$gruppe = "$host.control";
$rnews = "rnews "; # maybe /usr/bin/rnews or similar
$fqhost = "$host.$domain";
$i_am = "$name@$fqhost";
$msghdr = "From: $i_am\nSender: $i_am\nApproved: $i_am\n"
. "Distribution: local\n";
$nukem = "^("
. "From|Sender|Approved|Distribution|Message-ID|Date"
. '):\s';
$junkelm = "^The original article was:";
if ($ARGV[0] =~ /^e/i){ # snipping Elm's headers
shift; # discard argv0
while (<STDIN>){
last if /$junkelm/;
};
};
$zeit = time;
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
gmtime($zeit);
$msghdr .= sprintf("Date: %d %s %4d %02d:%02d:%02d GMT\n", $mday
, (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec)[$mon]
, $year+1900, $hour, $min, $sec);
$msg1 = $msghdr . "Message-ID: <do.$zeit.$$@$fqhost>\n";
$msg2 = $msghdr . "Message-ID: <note.$zeit.$$@$fqhost>\n";
while (<STDIN>){ # Header
last if /^$/;
$msg0 .= $_;
s/$nukem/X-\1: /io;
s/^Newsgroups:\s.*$/Newsgroups: $gruppe/io;
$msg1 .= $_;
next if /^Control:\s/;
s/^Subject:\s/Subject: control msg processed: /; # to log it later
$msg2 .= $_;
};
do { # rest, begins with ^$
$msg0 .= $_;
$msg1 .= $_;
$msg2 .= $_;
} while (<STDIN>);
if ($ARGV[0]){ # == testing only
print $msg0 if $ARGV[0] == 1; # the original data after junk stripping
print $msg1 if $ARGV[0] == 2;
print $msg2 if $ARGV[0] == 3;
exit;
};
# Changes active / newsgroups:
open (RNEWS, "| $rnews") || die "Couldn't execute $rnews (1.) $!\n";
print (RNEWS "#! rnews ", length($msg1), "\n", $msg1);
close (RNEWS);
# let everybody know in a local newsgroup:
open (RNEWS, "| $rnews") || die "Couldn't execute $rnews (2.) $!\n";
print (RNEWS "#! rnews ", length($msg2), "\n", $msg2);
close (RNEWS);
exit (0);
--
Wolfgang Schelongowski Check _all_ headers for sending email.
Teifi, Teifi, Sakradie, do geht er dahin!
-- EAV, Alpenrap
Technical Details
Message-ID:
<5dl0d5$ent@xivic.ruhr.de>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mailReferences:
<32F93D78.F12@bctel.net> <5fk1ot.sbn.hgoldste@bbs.mpcs.com>Show Full Headers
Complete Article Headers
Message-ID: <5dl0d5$ent@xivic.ruhr.de> Subject: Re: how to "re-inject" control messages? Date: Sun, 09 Feb 1997 00:00:00 +0000 From: skaranyi@LOCALHOST.ruhr.de (Wolfgang Schelongowski) References: <32F93D78.F12@bctel.net> <5fk1ot.sbn.hgoldste@bbs.mpcs.com> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail X-Deja-AN: 217665761 X-gringofalle: postmaster@ftp.porn.org X-advice: Replace LOCALHOST by xivic if mail bounces. Organization: Private site in Germany Newsgroups: news.software.nntp