Доброго времени суток... Помогите люди добрые. Есть апач для локалки(не для внешней) Вот конф:
NameVirtualHost 10.10.10.100
ServerAdmin valera@rs.net.ua
User www
Group www
<Directory "/home/wwwadmin">
Options Indexes FollowSymLinks ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
AddType application/x-httpd-php .phtml
AuthName "CAFE ADMIN CONTROL"
AuthUserFile /home/wwwadmin/conf/admin.passwd
AuthType Basic
require valid-user
Options +ExecCGI
AddHandler cgi-script .cgi
</Directory>
<VirtualHost 10.10.10.100>
ServerAdmin valera@rs.net.ua
DocumentRoot /home/wwwadmin/public_html
ServerName 10.10.10.100
ErrorLog /home/wwwadmin/logs/logs.log
CustomLog /home/wwwadmin/logs/access.log combined
ScriptAlias /cgi-bin/ "/home/wwwadmin/public_html/cgi-bin/"
Options +ExecCGI
AddHandler cgi-script .cgi
</VirtualHost>
Есть страничка:...
<FORM ACTION="cgi-bin/admin.cgi" METHOD="POST" TARGET="view">
...
Ксть скрипт admin.cgi:
#!/usr/bin/perl
#
# CGI
#
#---------- System depend constants (begin) --------------
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
$mon++;
$year=($year-100)+2000;
$date="$mday.$mon.$year";
$time="$hour:$min:$sec";
$admin="valera\@rs.net.ua";
$ipfw="/usr/home/wwwadmin/public_html/cgi-bin/ipfw";
$mailer="/usr/sbin/sendmail";
$logfile="/usr/home/wwwadmin/public_html/log/stat.log";
$IPfile="/usr/home/wwwadmin/public_html/set/local-ip";
#---------- System depend constants (end) --------------
open(lf, ">>$logfile") || die("Cannot write to log");
#-------- Print HTML header ------------------------------
print "Content-type:text/html\n\n";
print "<html><head><title>WEB control result</title></head><body>\n";
print "<TABLE><TABLE BORDER>\n";
print "<TR><TD>Nomer Compa</TD><TD>Razmer Sheipa (KByte/s)</TD><TD>Polucheno Bytes</TD><TD>Otpravleno Bytes</TD><TD>Vsego Bytes</TD></TR>";
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
#------------------Test mode------------------------------
#$buffer = "name=28&size=5&action=close";
# $remote = "10.0.10.3";
#---------------------------------------------------------
@pairs = split(/&/, $buffer);
foreach $pair (@pairs)
{
($names, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/~!/ ~!/g;
$FORM{$names} = $value;
}
#$test=$FORM{"name"};
#printf "$test\n";
#-------------------------------------------------------------------------
open(ipfile, "<$IPfile") || print lf "Cannot open local-ip file\n";
if ($FORM{"action"} eq "set") ########################################
{
while ($ipf=<ipfile>)
{
$ipf =~ tr/\n//d; # Cut ending <LF>
($name, $IP)=split(/:/,$ipf);
if ( $FORM{"name"} eq $name )
{
$size=$FORM{"size"};
$rules=$name+1000;
$sizeview1=$size*100;
$byte="Byte/s";
$sizeview="$sizeview1$byte";
printf lf ("$date\t$time\t$name\t set\t$rules\t$size\n");
open(fwr,"$ipfw s|");
while ($cr=<fwr>)
{
$cr =~ tr/ / /s;
($num, $pkt, $bytes, $typ, $tcp, $any, $ipr, $all)=split(/ /,$cr);
if ($num==$rules)
{
system("$ipfw del $rules > /dev/null");
}
}
system("$ipfw add $rules pipe $name ip from any to $IP via ed0 > /dev/null");
system("$ipfw add $rules pipe $name ip from $IP to any via ed0 > /dev/null");
system("$ipfw pipe $name config bw $sizeview >/dev/null");
}
}
}
if ($FORM{"action"} eq "close") ########################################
{
while ($ipf=<ipfile>)
{
$ipf =~ tr/\n//d; # Cut ending <LF>
($name, $IP)=split(/:/,$ipf);
if ( $FORM{"name"} eq $name )
{
$rules=$name+1000;
printf lf ("$date\t$time\t$name\t close\t$rules\t$size\n");
open(fwr,"$ipfw s|");
while ($cr=<fwr>)
{
$cr =~ tr/ / /s;
($num, $pkt, $bytes, $typ, $tcp, $any, $ipr, $all)=split(/ /,$cr);
if ($num==$rules)
{
system("$ipfw del $rules > /dev/null");
}
}
system("$ipfw add $rules deny ip from any to $IP via ed0 > /dev/null");
system("$ipfw add $rules deny ip from $IP to any via ed0 > /dev/null");
}
}
}
if ($FORM{"action"} eq "reset") ########################################
{
while ($ipf=<ipfile>)
{
$ipf =~ tr/\n//d; # Cut ending <LF>
($name, $IP)=split(/:/,$ipf);
if ( $FORM{"name"} eq $name )
{
$size=$FORM{"size"};
$rules=$name+1000;
printf lf ("$date\t$time\t$name\t reset\t$rules\n");
open(fwr,"$ipfw s|");
while ($cr=<fwr>)
{
$cr =~ tr/ / /s;
($num, $pkt, $bytes, $typ, $tcp, $any, $ipr, $all)=split(/ /,$cr);
if ($num==$rules)
{
system("$ipfw del $rules > /dev/null");
}
}
}
}
}
if ($FORM{"action"} eq "view") ########################################
{
goto VIEW;
}
#######################################################################
VIEW:
open(fwr,"$ipfw s|");
while ($cr=<fwr>)
{
$cr =~ tr/ / /s;
($num, $pkt, $bytes, $typ, $tcp, $any, $ipr, $all)=split(/ /,$cr);
if ($typ eq "pipe")
{
if ($numcounter ne $num)
{
$cr2=<fwr>;
$cr2 =~ tr/ / /s;
($num2, $pkt2, $bytes2, $typ2, $tcp2, $any2, $ipr2, $all2)=split(/ /,$cr2);
#00001: 100.000 bit/s 0 ms 50 sl. 0 queues (1 buckets) droptail
# mask: 0x00 0x00000000/0x0000 -> 0x00000000/0x0000
$post=0;
open(conf,"$ipfw pipe list $tcp |");
while ($bw=<conf>)
{
if ($post ne 0)
{
goto EXIT1;
}
$bw =~ tr/\n//d;
$bw =~ tr/:/ /s;
$bw =~ tr/ / /s;
($pipecount, $pipesize, $bit, $allparm)=split(/ /,$bw);
if ($pipecount = $tcp)
{
$name=$num-1000;
if ($name eq 250)
{
$name="ADMIN";
}
if ($bit eq "Kbit/s")
{
$pipesize=$pipesize/8;
}
if ($bit eq "bit/s")
{
$pipesize=$pipesize/8000;
}
$sumbytes=$bytes+$bytes2;
$text= reverse $bytes;
$text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1./g;
$bytes= reverse $text;
$text= reverse $bytes2;
$text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1./g;
$bytes2= reverse $text;
$text= reverse $sumbytes;
$text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1./g;
$sumbytes= reverse $text;
printf "<TR ALIGN=\"RIGHT\"><TD ALIGN=\"LEFT\">$name</TD><TD ALIGN=\"LEFT\">$pipesize</TD><TD>$bytes</TD><TD>$bytes2</TD><TD>$sumbytes</TD></TR>";
$numcounter=$num;
$post=1;
}
}
EXIT1:
}
}
if ($typ eq "deny")
{
if ($num>= 1000)
{
if ($num ne 65535)
{
if ($numcounter ne $num)
{
$name=$num-1000;
printf "<TR><TD>$name</TD><TD><FONT COLOR=\"RED\">ъблтщф</FONT></TD></TR>";
$numcounter=$num;
}
}
}
}
}
EXIT:
print "</TABLE>\n";
print "</body></html>\n";
close(lf);
close(ipfile);
sub com {
my $text = reverse $_[0];
$text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1./g;
return scalar reverse $text;
}
__END__
...
В логах пишеться:
[error] [client 10.10.10.100] ipfw: socket: Operation not permitted, referer: http://10.10.10.100/admin.html
[error] [client 10.10.10.14] user not found: /
....
А скрипт не работает - то есть он загружаеться, а правила файрвола не пишет и не отображает трафик...
Помогите плиз...
А скрипт этот для установки шейпов в инет-кафе
Всю необходимую информацию предоставлю.
Заранее спасибо..