]> git.deb.at Git - pkg/t-prot.git/blob - contrib/filter_innd.pl
Imported Upstream version 1.99.1+2.0-rc2
[pkg/t-prot.git] / contrib / filter_innd.pl
1 # $Id: filter_innd.pl,v 1.5 2005/04/15 14:07:11 jochen Exp $
2 # Copyright (c) 2004-2005 Jochen Striepe <t-prot@tolot.escape.de>
3 #
4 # This file is provided as an example how t-prot can be used for
5 # Perl filtering with INN2. It is NOT meant for production use.
6 # Read the README.perl_hook coming with your version of INN2, and
7 # adapt the script to your needs.
8 #
9 # Please see t-prot's man page for command line parameter details.
10 #
11 # Requirements/Bugs: mktemp(1) should be quite widely spread by
12 # now -- if it is not installed on your system, get the sources
13 # from Debian Linux or OpenBSD. Of course, rm(1) is POSIX and will
14 # be present on any reasonably Unix-like system.
15 # The script should not be run on any heavy-duty machines -- the
16 # writes to /tmp will be costly when many articles are committed
17 # at the same time. Sadly, there seems to be no really clean,
18 # portable, and standard way to realize a two-way pipe with perl.
19 # Please point me to some documentation if I am wrong. Thank you. :)
20 #
21 # License: This file is part of the t-prot package and therefore
22 # available under the same conditions. See t-prot's man page for
23 # details.
24 # The whole idea is robbed from Martin Dietze -- see his version at
25 #   http://www.fh-wedel.de/pub/fh-wedel/staff/herbert/linux/
26 # Please note that there is no code copied from there, so the files
27 # in the t-prot package are *not* available under the terms of the
28 # GPL.
29
30 sub filter_art {
31         my $rval = "" ; # Assume we'll accept. Cannot be `0'
32
33 # Here we only filter local.* news groups. Another useful idea is to
34 # filter just locally submitted articles:
35 #       if (index($hdr{'Path'}, '!')<0) {
36         if ($hdr{'Newsgroups'} =~ /^local\./) {
37                 my $foo = $hdr{'__BODY__'};
38                 $foo =~ s/\r\n/\n/gs;
39
40 # Note that here might be a security problem lurking. The directory
41 # used for temporary files should not be writable for anyone but the
42 # user INN runs as. As mentioned above, this example file is NOT
43 # meant for production use.
44                 open(TMP, '/usr/bin/mktemp -q /tmp/INN2/tmp.XXXXXX | tr -d \'\n\'|')
45                         || return '';
46                 my $f = <TMP>;
47                 close TMP;
48
49                 open(OUT, ">$f")
50                         || return '';
51                 print OUT $foo;
52                 close OUT;
53
54                 open(IN, "/usr/bin/t-prot -m -t -p --body --check -i $f|")
55                         || goto FINISH;
56                 $rval = <IN>;
57                 close IN;
58
59                 FINISH: unlink($f);
60         }
61
62         $rval ;
63 }
64
65 sub filter_mode {
66 }
67
68 sub filter_messageid {
69     $rval = '';
70     $rval;
71 }
72