]> git.deb.at Git - pkg/t-prot.git/blobdiff - contrib/filter_innd.pl
Imported Upstream version 1.99.1+2.0-rc2
[pkg/t-prot.git] / contrib / filter_innd.pl
index dd6985a6d541a9fd33938e5727bf25c429b0f74a..4df4bb9130b8a0ca7b5b3b6a9db24fb1e478808a 100644 (file)
@@ -1,5 +1,5 @@
-# $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;
@@ -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 = <IN>;
                close IN;
 
-               FINISH: system('/bin/rm', $f);
+               FINISH: unlink($f);
        }
 
        $rval ;