--- loncom/lonhttpd 2003/07/01 19:57:45 1.8 +++ loncom/lonhttpd 2010/03/11 16:34:48 1.17 @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $Id: lonhttpd,v 1.8 2003/07/01 19:57:45 albertel Exp $ +# $Id: lonhttpd,v 1.17 2010/03/11 16:34:48 droeschl Exp $ $VERSION = "1.3.2 (Demonic/Linux/LON-CAPA Derivative $Revison$)"; @@ -51,7 +51,8 @@ if ($port_to_use eq '80') { die('Apache "mpeg" => "video/mpeg", "mpg" => "video/mpeg", "jpeg" => "image/jpeg", - "jpg" => "image/jpeg"); + "jpg" => "image/jpeg", + "png" => "image/png"); $logfile = "/home/httpd/perl/logs/lonhttpd.log"; @@ -61,7 +62,7 @@ $pidfile="/home/httpd/perl/logs/lonhttpd if (-e $pidfile) { open(LFH,"$pidfile"); - my $pide=<$LFH>; + my $pide=; chomp($pide); close(LFH); if (kill 0 => $pide) { die "already running"; } @@ -86,89 +87,7 @@ Server: HTTPi/$VERSION MIME-Version: 1.0 EOF -%virtual_files = - ( -"/adm/lonLCDfont/0.gif" => [ "image/gif", "FILE", - "/home/httpd/html/adm/lonLCDfont/0.gif" ] , -"/adm/lonLCDfont/1.gif" => [ "image/gif", "FILE", - "/home/httpd/html/adm/lonLCDfont/1.gif" ] , -"/adm/lonLCDfont/2.gif" => [ "image/gif", "FILE", - "/home/httpd/html/adm/lonLCDfont/2.gif" ] , -"/adm/lonLCDfont/3.gif" => [ "image/gif", "FILE", - "/home/httpd/html/adm/lonLCDfont/3.gif" ] , -"/adm/lonLCDfont/4.gif" => [ "image/gif", "FILE", - "/home/httpd/html/adm/lonLCDfont/4.gif" ] , -"/adm/lonLCDfont/5.gif" => [ "image/gif", "FILE", - "/home/httpd/html/adm/lonLCDfont/5.gif" ] , -"/adm/lonLCDfont/6.gif" => [ "image/gif", "FILE", - "/home/httpd/html/adm/lonLCDfont/6.gif" ] , -"/adm/lonLCDfont/7.gif" => [ "image/gif", "FILE", - "/home/httpd/html/adm/lonLCDfont/7.gif" ] , -"/adm/lonLCDfont/8.gif" => [ "image/gif", "FILE", - "/home/httpd/html/adm/lonLCDfont/8.gif" ] , -"/adm/lonLCDfont/9.gif" => [ "image/gif", "FILE", - "/home/httpd/html/adm/lonLCDfont/9.gif" ] , -"/adm/lonLCDfont/a.gif" => [ "image/gif", "FILE", - "/home/httpd/html/adm/lonLCDfont/a.gif" ] , -"/adm/lonLCDfont/b.gif" => [ "image/gif", "FILE", - "/home/httpd/html/adm/lonLCDfont/b.gif" ] , -"/adm/lonLCDfont/c.gif" => [ "image/gif", "FILE", - "/home/httpd/html/adm/lonLCDfont/c.gif" ] , -"/adm/lonLCDfont/d.gif" => [ "image/gif", "FILE", - "/home/httpd/html/adm/lonLCDfont/d.gif" ] , -"/adm/lonLCDfont/e.gif" => [ "image/gif", "FILE", - "/home/httpd/html/adm/lonLCDfont/e.gif" ] , -"/adm/lonLCDfont/f.gif" => [ "image/gif", "FILE", - "/home/httpd/html/adm/lonLCDfont/f.gif" ] , -"/adm/lonLCDfont/g.gif" => [ "image/gif", "FILE", - "/home/httpd/html/adm/lonLCDfont/g.gif" ] , -"/adm/lonLCDfont/h.gif" => [ "image/gif", "FILE", - "/home/httpd/html/adm/lonLCDfont/h.gif" ] , -"/adm/lonLCDfont/i.gif" => [ "image/gif", "FILE", - "/home/httpd/html/adm/lonLCDfont/i.gif" ] , -"/adm/lonLCDfont/j.gif" => [ "image/gif", "FILE", - "/home/httpd/html/adm/lonLCDfont/j.gif" ] , -"/adm/lonLCDfont/k.gif" => [ "image/gif", "FILE", - "/home/httpd/html/adm/lonLCDfont/k.gif" ] , -"/adm/lonLCDfont/l.gif" => [ "image/gif", "FILE", - "/home/httpd/html/adm/lonLCDfont/l.gif" ] , -"/adm/lonLCDfont/m.gif" => [ "image/gif", "FILE", - "/home/httpd/html/adm/lonLCDfont/m.gif" ] , -"/adm/lonLCDfont/n.gif" => [ "image/gif", "FILE", - "/home/httpd/html/adm/lonLCDfont/n.gif" ] , -"/adm/lonLCDfont/o.gif" => [ "image/gif", "FILE", - "/home/httpd/html/adm/lonLCDfont/o.gif" ] , -"/adm/lonLCDfont/p.gif" => [ "image/gif", "FILE", - "/home/httpd/html/adm/lonLCDfont/p.gif" ] , -"/adm/lonLCDfont/q.gif" => [ "image/gif", "FILE", - "/home/httpd/html/adm/lonLCDfont/q.gif" ] , -"/adm/lonLCDfont/r.gif" => [ "image/gif", "FILE", - "/home/httpd/html/adm/lonLCDfont/r.gif" ] , -"/adm/lonLCDfont/s.gif" => [ "image/gif", "FILE", - "/home/httpd/html/adm/lonLCDfont/s.gif" ] , -"/adm/lonLCDfont/t.gif" => [ "image/gif", "FILE", - "/home/httpd/html/adm/lonLCDfont/t.gif" ] , -"/adm/lonLCDfont/u.gif" => [ "image/gif", "FILE", - "/home/httpd/html/adm/lonLCDfont/u.gif" ] , -"/adm/lonLCDfont/v.gif" => [ "image/gif", "FILE", - "/home/httpd/html/adm/lonLCDfont/v.gif" ] , -"/adm/lonLCDfont/w.gif" => [ "image/gif", "FILE", - "/home/httpd/html/adm/lonLCDfont/w.gif" ] , -"/adm/lonLCDfont/x.gif" => [ "image/gif", "FILE", - "/home/httpd/html/adm/lonLCDfont/x.gif" ] , -"/adm/lonLCDfont/y.gif" => [ "image/gif", "FILE", - "/home/httpd/html/adm/lonLCDfont/y.gif" ] , -"/adm/lonLCDfont/z.gif" => [ "image/gif", "FILE", - "/home/httpd/html/adm/lonLCDfont/z.gif" ] , -"/adm/lonLCDfont/colon.gif" => [ "image/gif", "FILE", - "/home/httpd/html/adm/lonLCDfont/colon.gif" ] , -"/adm/lonLCDfont/slash.gif" => [ "image/gif", "FILE", - "/home/httpd/html/adm/lonLCDfont/slash.gif" ] , -"/adm/lonLCDfont/hyphen.gif" => [ "image/gif", "FILE", - "/home/httpd/html/adm/lonLCDfont/hyphen.gif" ] , -"/adm/lonLCDfont/space.gif" => [ "image/gif", "FILE", - "/home/httpd/html/adm/lonLCDfont/space.gif" ] , - ); +%virtual_files = (); %content_types = (%system_content_types, %content_types); undef %system_content_types; @@ -260,7 +179,9 @@ EOF } -sub bye { unlink($pidfile); exit; } +sub bye { exit; } + +sub goodbye { unlink($pidfile); exit; } sub dead { &htsponse(500, "Server Error"); @@ -276,7 +197,8 @@ EOF } $SIG{'__DIE__'} = \&dead; -$SIG{'ALRM'} = $SIG{'TERM'} = $SIG{'INT'} = \&bye; +$SIG{'ALRM'} = \&bye; +$SIG{'TERM'} = $SIG{'INT'} = \&goodbye; sub master { $0 = "lonhttpd: (dhttpi) handling request"; @@ -345,12 +267,16 @@ while () { 1 while $address =~ s#/\.(/|$)#\1#; 1 while $address =~ s#/[^/]*/\.\.(/|$)#\1#; 1 while $address =~ s#^/\.\.(/|$)#\1#; - $fail = 0; + $fail = 1; # # Heavily customized for LON-CAPA # $address=~s/\/+/\//g; - unless ($address=~/^\/(status|adm\/|res\/adm\/)/) { $fail=1; } + if ($address=~/^\/(status|adm\/|res\/adm\/)/) { + $fail = 0; + } elsif ($address =~ /^\/res\/([\w\.\-]+)\/\1\-domainconfig\/(logo|domlogo|img|login)\/[^\/]+$/) { + $fail = 0; + } # # because existing restriction matrix would not do precedence across rules # @@ -587,6 +513,7 @@ for (;;) { waitpid($pid, 0); $0 = "lonhttpd: (dhttpi) on ANY:$port_to_use, last request " . scalar localtime; + close(NS); } else { $0 = "lonhttpd: (dhttpi) child switching to socket"; open(STDIN, "<&NS");