]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - config/urlfilter/redirect_wrapper
Fixed authentication not working when using proxy
[people/pmueller/ipfire-2.x.git] / config / urlfilter / redirect_wrapper
1 #!/usr/bin/perl
2 ###############################################################################
3 # #
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007 Michael Tremer & Christian Schmidt #
6 # #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
11 # #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
16 # #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
19 # #
20 # Based on Steffen Schoch (sschoch@users.sourceforge.net) #
21 # #
22 ###############################################################################
23
24 use strict;
25 use IPC::Open2;
26 use IO::Handle;
27 require '/var/ipfire/general-functions.pl';
28
29 my %proxysettings=();
30 &General::readhash("${General::swroot}/proxy/settings", \%proxysettings);
31
32 # define here your redirectors (use a comma sperated list)
33 my @redirectors = "";
34 if ( $proxysettings{'ENABLE_FILTER'} eq 'on' && -e '/usr/bin/squidGuard' ){push(@redirectors,"/usr/bin/squidGuard"); }
35 if ( $proxysettings{'ENABLE_CLAMAV'} eq 'on' && -e '/usr/bin/squidclamav' ){ push(@redirectors,"/usr/bin/squidclamav"); }
36 if ( $proxysettings{'ENABLE_UPDXLRATOR'} eq 'on' && -e '/usr/sbin/updxlrator' ) { push(@redirectors,"/usr/sbin/updxlrator"); }
37
38 #my $redirectors = [ '/usr/bin/squidclamav', '/usr/bin/squidGuard', '/usr/sbin/updxlrator' ];
39
40 # Attention: keep in mind that the order of your redirectors is important.
41 # It doesn't make sense to scan for viruses on pages you restrict access to...
42 # So place first your tools which restrict access, then the tools which do the
43 # content filtering!
44
45 #print "Anzahl ".$#redirectors."\n";
46
47 ##### no need to change anything below this line #####
48
49 # init
50 $| = 1;
51 STDOUT->autoflush(1);
52 my $line;
53 my $return;
54 my $i;
55
56 # open progamms
57 my $pidlist = [];
58 my $rlist = [];
59 my $wlist = [];
60 for($i = 1; $i <= $#redirectors; $i++) {
61 #print "i=".$i." redirector ".$redirectors[$i]."\n";
62 $pidlist->[$i] = open2($rlist->[$i], $wlist->[$i], $redirectors[$i] );
63 }
64
65 # wait for data...
66 while($line = <>) {
67 for($i = 1; $i <= $#redirectors; $i++) {
68 $wlist->[$i]->print($line);
69 $return = $rlist->[$i]->getline;
70 last if($return ne "\n" and $return ne $line);
71 # break if redirector changes data
72 }
73 print $return;
74 }
75 exit 0;