#!/usr/bin/perl #__________________________________________________________ # # File: wrap # By: Matt Ho # Date: 7/23/95 # Purpose: Wrapper to dynamically create HTML documents # that contain a easy to read directory content. #__________________________________________________________ require "flush.pl"; #__________________________________________________________ # # IRIX 6.5 disables the 'download' feature for # security reasons. This functionality will removed # entirely in the next release. # # The supported way for a user to download a file is # to use the browser 'Save Link' feature. # # If you need to restore this functionality, and you are # behind a firewall, and trust all others behind that # firewall, then change the line below to: # $HANDLER_DISABLED = 0 ; #__________________________________________________________ $HANDLER_DISABLED = 1 ; #__________________________________________________________ # # Set some environment variables, we'll need through the # script and do some initial error checking. #__________________________________________________________ $PATH = $ENV{'PATH_INFO'} ; $ls = "/sbin/ls -a1" ; $outboxcgi = "/var/www/cgi-bin/outbox-cgi" ; $wrap = "/cgi-bin/wrap" ; #__________________________________________________________ # # Read the form data in. PATH_INFO may be passed here # if this was called from a SSI. We're going to make # one final tweak and read from the arg list as well # for SSI's. #__________________________________________________________ if( $ENV{'REQUEST_METHOD'} eq "GET" ) { $buffer=$ENV{'QUERY_STRING'} ; } else { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}) ; } @pairs = split(/&/, $buffer) ; foreach (@pairs) { tr/+/ / ; ($name,$value) = split(/=/) ; $value =~ s/%(..)/pack("c",hex($1))/ge ; $name =~ s/%(..)/pack("c",hex($1))/ge ; $FORM{$name} = $value ; } #_________________________________ # # Some basic checks to take # care of #_________________________________ if( $ARGV[0] ) { $PATH = $ARGV[0] ; $arg = 1 ; } # trim off undesirable meta chars. $PATH =~ s/[|;]//go ; chop $PATH if substr($PATH, -1) eq "/" ; @_ = split('/', $PATH) ; $outBoxPath = $PATH ; $outBoxPath =~ s/^\/$_[1]// ; $pathRoot = $_[$#_] ; ($pwname,$pwpasswd,$pwuid,$pwgid,$pwquota,$pwcomment,$pwgcos,$pwdir,$pwshell) = getpwnam($_[1]) ; $doc = $pwdir."/public_html".$outBoxPath ; &ErrBadPath if ! defined $PATH || $PATH eq "" ; # check for empty path &ErrBadPath unless &ValidPath($doc) ; # Check for server spoofing &ErrBadUser unless -e $pwdir ; # Check to see it exists &ErrBadPath unless -e $doc ; # Check to see it exists &ErrBadPath if -f $doc ; # Don't allow download of file via wrap &ErrBadUser if $pwname eq "" ; # don't allow listing of non-OutBox folder #__________________________________________________________ # # If we get to this point, we can be reasonably certain # that this is a valid shared directory. We want to # show it using the appropriate method. The following # section is the leading data. ShowContents will supply # the rest of the data. # # We do, however, need to account for the user putting # an index.html file in the directory. We'll handle # that as follows. If the file exists, it is assumed to # be in the right. We will append out data at the end, # using the index.html's head section. Otherwise, we # will use ours. #__________________________________________________________ if( $arg == 1 ) { # This is intentionally left blank } elsif( -r "$doc/index.html" ) { print "Content-type: text/html\n\n" ; open(INDEX, "$doc/index.html") ; while( ) { s/