X-Git-Url: https://git.deb.at/w?p=pkg%2Ft-prot.git;a=blobdiff_plain;f=contrib%2Ffilter_innd.pl;h=4df4bb9130b8a0ca7b5b3b6a9db24fb1e478808a;hp=dd6985a6d541a9fd33938e5727bf25c429b0f74a;hb=59f87ac047552c79d2885106c9dde3967563190a;hpb=ec2a805cf8dbfde9f1223a9a60eaf1bf4653d6e7 diff --git a/contrib/filter_innd.pl b/contrib/filter_innd.pl index dd6985a..4df4bb9 100644 --- a/contrib/filter_innd.pl +++ b/contrib/filter_innd.pl @@ -1,5 +1,5 @@ -# $Id: filter_innd.pl,v 1.4 2004/10/10 20:26:24 jochen Exp $ -# Copyright (c) 2004 Jochen Striepe +# $Id: filter_innd.pl,v 1.5 2005/04/15 14:07:11 jochen Exp $ +# Copyright (c) 2004-2005 Jochen Striepe # # 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. @@ -30,11 +30,18 @@ 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 = ; close TMP; @@ -44,12 +51,12 @@ sub filter_art { 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 = ; close IN; - FINISH: system('/bin/rm', $f); + FINISH: unlink($f); } $rval ;