-# $Id: filter_innd.pl,v 1.4 2004/10/10 20:26:24 jochen Exp $
-# Copyright (c) 2004 Jochen Striepe <t-prot@tolot.escape.de>
+# $Id: filter_innd.pl,v 1.5 2005/04/15 14:07:11 jochen Exp $
+# Copyright (c) 2004-2005 Jochen Striepe <t-prot@tolot.escape.de>
#
# This file is provided as an example how t-prot can be used for
# Perl filtering with INN2. It is NOT meant for production use.
sub filter_art {
my $rval = "" ; # Assume we'll accept. Cannot be `0'
+# Here we only filter local.* news groups. Another useful idea is to
+# filter just locally submitted articles:
+# if (index($hdr{'Path'}, '!')<0) {
if ($hdr{'Newsgroups'} =~ /^local\./) {
my $foo = $hdr{'__BODY__'};
$foo =~ s/\r\n/\n/gs;
- open(TMP, '/usr/bin/mktemp -q /tmp/INN2.tmp.XXXXXX | tr -d \'\n\'|')
+# Note that here might be a security problem lurking. The directory
+# used for temporary files should not be writable for anyone but the
+# user INN runs as. As mentioned above, this example file is NOT
+# meant for production use.
+ open(TMP, '/usr/bin/mktemp -q /tmp/INN2/tmp.XXXXXX | tr -d \'\n\'|')
|| return '';
my $f = <TMP>;
close TMP;
print OUT $foo;
close OUT;
- open(IN, "/usr/bin/t-prot -m -t -p --check -i $f|")
+ open(IN, "/usr/bin/t-prot -m -t -p --body --check -i $f|")
|| goto FINISH;
$rval = <IN>;
close IN;
- FINISH: system('/bin/rm', $f);
+ FINISH: unlink($f);
}
$rval ;