X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=config%2Furlfilter%2Fredirect_wrapper;h=ceae12b2bc97da3af78a52c6e5bb129f59cc0e30;hb=b0d9fad3f94fb73b1686c5e6a948066497638d26;hp=c9636fcf659f8c080cf0312e2c00889ea1a49704;hpb=e775d06cdb82047b95436286f1d46d783d6f58b7;p=people%2Fteissler%2Fipfire-2.x.git diff --git a/config/urlfilter/redirect_wrapper b/config/urlfilter/redirect_wrapper index c9636fcf6..ceae12b2b 100644 --- a/config/urlfilter/redirect_wrapper +++ b/config/urlfilter/redirect_wrapper @@ -2,7 +2,7 @@ ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2007 Michael Tremer & Christian Schmidt # +# Copyright (C) 2007-2012 IPFire Team # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -25,7 +25,6 @@ use strict; use IPC::Open2; use IO::Handle; -# define here your redirectors (use a comma sperated list) my $redirectors; require '/var/ipfire/general-functions.pl'; @@ -61,39 +60,63 @@ my $return; my $i; my $debug=0; # enable only for debugging -if ($debug){ - print "Urlfilter = ".$proxysettings{'ENABLE_FILTER'}."\n"; - print "Clamav = ".$proxysettings{'ENABLE_CLAMAV'}."\n"; - print "Updxlrator = ".$proxysettings{'ENABLE_UPDXLRATOR'}."\n"; - } +if ( -e "/var/ipfire/proxy/enable_redirector_debug" ){ + $debug = 1; + writetolog("Urlfilter = ".$proxysettings{'ENABLE_FILTER'}." Clamav = ".$proxysettings{'ENABLE_CLAMAV'}." Updxlrator = ".$proxysettings{'ENABLE_UPDXLRATOR'}); + } # open progamms my $pidlist = []; my $rlist = []; my $wlist = []; + for($i = 0; $i < @$redirectors; $i++) { - if ($debug){print "Current redirector is ".$redirectors->[$i]."\n";} - $pidlist->[$i] = open2($rlist->[$i], $wlist->[$i], $redirectors->[$i]); -} + $pidlist->[$i] = open2($rlist->[$i], $wlist->[$i], $redirectors->[$i]); + if ($debug){ + writetolog("Current redirector is ".$redirectors->[$i]." number ".$i." PID ".$pidlist->[$i]); + } + } # wait for data... while($line = <>) { - for($i = 0; $i < @$redirectors; $i++) { - $wlist->[$i]->print($line); - $return = $rlist->[$i]->getline; - last if($return ne "\n" and $return ne $line); - # break if redirector changes data - } - print $return; + $return = ""; + + for($i = 0; $i < @$redirectors; $i++) { + $wlist->[$i]->print($line); + $return = $rlist->[$i]->getline; + if ( $return eq "Processing file and database" ){ + system("logger -t ipfire 'Emergency - squidGuard not initialised please run squidGuard -C all'"); + } + + if ($debug){ + my $dline = $line;my $dreturn = $return;chomp $dline;chomp $dreturn; + if ( $return eq $line or $return eq "\n" or $return eq "" ){ + writetolog("Request equals result by ".$redirectors->[$i]." ".$dline); + } + else { + writetolog($redirectors->[$i]." answers ".$dreturn."\n Querried ".$dline); + } + } + + # break if redirector changes data + if($return ne "\n" and $return ne $line ){ + if ( $redirectors->[$i] ne "/usr/sbin/updxlrator"){ if ($debug){ - chomp $line; - chomp $return; - if ( $line ne $return ){ - open(DATEI, ">>/var/log/squid/redirector_debug") || die "Unable to acces file /var/log/redirector_debug"; - print DATEI "Requested ".$line."\nAnswer ".$return."\n"; - close(DATEI); - } + writetolog($redirectors->[$i]." is stopping querry because block was found."); + } + $i = @$redirectors; } -} + } + } + print $return; + } + exit 0; + +sub writetolog { + open(DATEI, ">>/var/log/squid/redirector_debug") || die "Unable to acces file /var/log/squid/redirector_debug"; + my $log = shift; + print DATEI $log."\n"; + close(DATEI); + }