version 1.7, 2003/05/02 21:03:19
|
version 1.13, 2007/04/11 21:37:24
|
Line 12 $VERSION = "1.3.2 (Demonic/Linux/LON-CAP
|
Line 12 $VERSION = "1.3.2 (Demonic/Linux/LON-CAP
|
|
|
use lib '/home/httpd/lib/perl/'; |
use lib '/home/httpd/lib/perl/'; |
use LONCAPA::Configuration(); |
use LONCAPA::Configuration(); |
|
use Apache::lonnet; |
%loncapavar=%{&LONCAPA::Configuration::read_conf('loncapa.conf')}; |
%loncapavar=%{&LONCAPA::Configuration::read_conf('loncapa.conf')}; |
$port_to_use=$loncapavar{'lonhttpdPort'}; |
$port_to_use=$loncapavar{'lonhttpdPort'}; |
if (!defined($port_to_use)) { |
if (!defined($port_to_use)) { |
Line 51 if ($port_to_use eq '80') { die('Apache
|
Line 52 if ($port_to_use eq '80') { die('Apache
|
"mpeg" => "video/mpeg", |
"mpeg" => "video/mpeg", |
"mpg" => "video/mpeg", |
"mpg" => "video/mpeg", |
"jpeg" => "image/jpeg", |
"jpeg" => "image/jpeg", |
"jpg" => "image/jpeg"); |
"jpg" => "image/jpeg", |
|
"png" => "image/png"); |
|
|
$logfile = "/home/httpd/perl/logs/lonhttpd.log"; |
$logfile = "/home/httpd/perl/logs/lonhttpd.log"; |
|
|
Line 61 $pidfile="/home/httpd/perl/logs/lonhttpd
|
Line 63 $pidfile="/home/httpd/perl/logs/lonhttpd
|
|
|
if (-e $pidfile) { |
if (-e $pidfile) { |
open(LFH,"$pidfile"); |
open(LFH,"$pidfile"); |
my $pide=<$LFH>; |
my $pide=<LFH>; |
chomp($pide); |
chomp($pide); |
close(LFH); |
close(LFH); |
if (kill 0 => $pide) { die "already running"; } |
if (kill 0 => $pide) { die "already running"; } |
Line 260 EOF
|
Line 262 EOF
|
} |
} |
|
|
|
|
sub bye { unlink($pidfile); exit; } |
sub bye { exit; } |
|
|
|
sub goodbye { unlink($pidfile); exit; } |
|
|
sub dead { |
sub dead { |
&htsponse(500, "Server Error"); |
&htsponse(500, "Server Error"); |
Line 276 EOF
|
Line 280 EOF
|
} |
} |
|
|
$SIG{'__DIE__'} = \&dead; |
$SIG{'__DIE__'} = \&dead; |
$SIG{'ALRM'} = $SIG{'TERM'} = $SIG{'INT'} = \&bye; |
$SIG{'ALRM'} = \&bye; |
|
$SIG{'TERM'} = $SIG{'INT'} = \&goodbye; |
|
|
sub master { |
sub master { |
$0 = "lonhttpd: (dhttpi) handling request"; |
$0 = "lonhttpd: (dhttpi) handling request"; |
Line 296 $date = "$dt/$mon/$yr:$tm +0000";
|
Line 301 $date = "$dt/$mon/$yr:$tm +0000";
|
select(STDOUT); $|=1; $address = 0; |
select(STDOUT); $|=1; $address = 0; |
alarm 1; |
alarm 1; |
while (<STDIN>) { |
while (<STDIN>) { |
if(/^([A-Z]+)\s+([^\s]+)\s+([^\s\r\l\n]*)/) { |
if(/^([A-Z]+)\s+(\S+)\s+(\S*)/) { |
$method = $1; |
$method = $1; |
$address = $2; |
$address = $2; |
$httpver = $3; |
$httpver = $3; |
Line 345 while (<STDIN>) {
|
Line 350 while (<STDIN>) {
|
1 while $address =~ s#/\.(/|$)#\1#; |
1 while $address =~ s#/\.(/|$)#\1#; |
1 while $address =~ s#/[^/]*/\.\.(/|$)#\1#; |
1 while $address =~ s#/[^/]*/\.\.(/|$)#\1#; |
1 while $address =~ s#^/\.\.(/|$)#\1#; |
1 while $address =~ s#^/\.\.(/|$)#\1#; |
$fail = 0; |
$fail = 1; |
# |
# |
# Heavily customized for LON-CAPA |
# Heavily customized for LON-CAPA |
# |
# |
$address=~s/\/+/\//g; |
$address=~s/\/+/\//g; |
unless ($address=~/^\/(status|adm\/|res\/adm\/)/) { $fail=1; } |
if ($address=~/^\/(status|adm\/|res\/adm\/)/) { |
|
$fail = 0; |
|
} elsif (&Apache::lonnet::is_domainimage($address)) { |
|
$fail = 0; |
|
} |
# |
# |
# because existing restriction matrix would not do precedence across rules |
# because existing restriction matrix would not do precedence across rules |
# |
# |