Mittwoch, 27. Juni 2007

SQUID: fuer User ein Script ausfuehren

Hier im Beispeil ist es so das der SQUID_Porxy 10.11.12.12 auf Port: 3128
hinter einem AV-Proxy 10.11.12.13 Port: 8080 haengt.

Dazu muss in der /etc/init.d/squid bei

start {

noch folgende 2 Zeilen angefuegt werden!

export http_proxy=http://10.11.12.13:8080/
export ftp_proxy=http://193.11.12.13:8080/



Um z.B. einem / mehrer User etwas zu aergern kann man z.B. Bilder
unschaf machen. (blur)

Auf dem Proxy muss ein apache server instl. sein.

Im "ServerDocumentRoot" z.B: /var/www/html muss es ein verz. images geben.
In das der User der den mit dessen rechte der squid laeuft schreiben darf.

z.B:

# cd /var/www/html
# ls -la

drwxrwxr-x 3 root squid 4096 2007-06-26 14:17 images



--------------------

http_port 3128
cache_access_log none

cache_peer 10.11.12.13 parent 8080 7 no-query no-digest no-netdb-exchange

auth_param basic children 15
auth_param basic realm ourproxy.domain.tld
auth_param basic credentialsttl 2 hours
auth_param basic casesensitive off


### ADS Auth
auth_param basic program /usr/lib/squid/squid_ldap_auth -b "dc=ourdom,dc=zzz" -R -D ldapuser@ourdom.zzz -w password -f "(&(sAMAccountName=%s)(memberOf=CN=Squid-Proxy,OU=Groups,OU=NL1,DC=ourdom,DC=tld))" adssrv.ourdom.zzz


redirect_program /usr/local/bin/.pl
redirect_children 5

acl Mobbing proxy_auth user1 User2 User3
acl Mobbing proxy_auth SURFER


redirector_access allow Mobbing

http_access allow Mobbing SURFER

cache_peer_access 10.11.12.13 allow all
never_direct allow all



--------------------


Alle User aus der ADS die der Gruppe: Squid-Proxy angehoeren, koennen surfen.
Aber die User: user1 User2 User3 werden ueber das "redirect_program"
geleitet und mit den Bildern werden dann je nach Parameter bei "mogrify"
veraendert.


das PerlScript das als "redirect_program" angeben wird
muss fuer den User unter dem squid laeuft ausfuehrbar sein.

-rwxr-xr-x 1 root root 1004 2007-06-26 15:33 squid_redirection_script_blur.pl
-rwxr-xr-x 1 root root 992 2007-06-26 15:14 squid_redirection_script_flip.pl
-rwxr-xr-x 1 root root 992 2007-06-26 15:18 squid_redirection_script_flop.pl



squid_redirection_script_blur.pl

#!/usr/bin/perl

$|=1;

$count = 0;

$pid = $$;

while (<>) {

chomp $_;

if ($_ =~ /(.*\.jpg)/i) {

$url = $1;

system("/usr/bin/wget", "-q", "-O","/var/www/html/images/$pid-$count.jpg", "$url");

system("/usr/bin/mogrify", "-blur", "60","/var/www/html/images/$pid-$count.jpg");

system("/bin/chmod", "777","/var/www/html/images/$pid-$count.jpg");

print "http://193.98.77.123/images/$pid-$count.jpg\n";

}

elsif ($_ =~ /(.*\.gif)/i) {

$url = $1;

system("/usr/bin/wget", "-q", "-O","/var/www/html/images/$pid-$count.gif", "$url");

system("/usr/bin/mogrify", "-blur", "60","/var/www/html/images/$pid-$count.gif");

system("/bin/chmod", "777","/var/www/html/images/$pid-$count.gif");

print "http://193.98.77.123/images/$pid-$count.gif\n";



}

else {

print "$_\n";;

}

$count++;

}




squid_redirection_script_flip.pl


#!/usr/bin/perl

$|=1;

$count = 0;

$pid = $$;

while (<>) {

chomp $_;

if ($_ =~ /(.*\.jpg)/i) {

$url = $1;

system("/usr/bin/wget", "-q", "-O","/var/www/html/images/$pid-$count.jpg", "$url");

system("/usr/bin/mogrify", "-flip","/var/www/html/images/$pid-$count.jpg");

system("/bin/chmod", "777","/var/www/html/images/$pid-$count.jpg");

print "http://193.98.77.123/images/$pid-$count.jpg\n";

}

elsif ($_ =~ /(.*\.gif)/i) {

$url = $1;

system("/usr/bin/wget", "-q", "-O","/var/www/html/images/$pid-$count.gif", "$url");

system("/usr/bin/mogrify", "-flip","/var/www/html/images/$pid-$count.gif");

system("/bin/chmod", "777","/var/www/html/images/$pid-$count.gif");

print "http://193.98.77.123/images/$pid-$count.gif\n";



}

else {

print "$_\n";;

}

$count++;

}



squid_redirection_script_flop.pl


#!/usr/bin/perl

$|=1;

$count = 0;

$pid = $$;

while (<>) {

chomp $_;

if ($_ =~ /(.*\.jpg)/i) {

$url = $1;

system("/usr/bin/wget", "-q", "-O","/var/www/html/images/$pid-$count.jpg", "$url");

system("/usr/bin/mogrify", "-flop","/var/www/html/images/$pid-$count.jpg");

system("/bin/chmod", "777","/var/www/html/images/$pid-$count.jpg");

print "http://193.98.77.123/images/$pid-$count.jpg\n";

}

elsif ($_ =~ /(.*\.gif)/i) {

$url = $1;

system("/usr/bin/wget", "-q", "-O","/var/www/html/images/$pid-$count.gif", "$url");

system("/usr/bin/mogrify", "-flop","/var/www/html/images/$pid-$count.gif");

system("/bin/chmod", "777","/var/www/html/images/$pid-$count.gif");

print "http://193.98.77.123/images/$pid-$count.gif\n";



}

else {

print "$_\n";;

}

$count++;

}

Keine Kommentare:

Kommentar veröffentlichen