File:  [LON-CAPA] / loncom / auth / lonracc.pm
Revision 1.2: download - view: text, annotated - select for diffs
Fri Jun 30 17:09:51 2000 UTC (24 years, 6 months ago) by www
Branches: MAIN
CVS tags: stable_2001_fall, HEAD
Now also replicate metadata files, filename.meta

# The LearningOnline Network
# Access Handler for File Transfers
# (lonacc: Cookie Based Access Handler
# 5/21/99,5/22,5/29,5/31,6/15 Gerd Kortemeyer)
# 6/16,6/18,7/3,
# 6/30/00 Gerd Kortemeyer

package Apache::lonracc;

use strict;
use Apache::Constants qw(:common :remotehost);
use Apache::File();

sub handler {
    my $r = shift;
    my $reqhost;
    unless ($reqhost=$r->get_remote_host(REMOTE_DOUBLE_REV)) {
       $r->log_reason("Spoof request");
       return FORBIDDEN;
    }
    my $readline;
    my $lontabdir=$r->dir_config('lonTabDir');
    {
       my $fh;
       unless ($fh=Apache::File->new("$lontabdir/hosts.tab")) {
          $r->log_reason("Could not find host tab file");
          return FORBIDDEN;
       }
       while ($readline=<$fh>) {
          my ($id,$domain,$role,$name,$ip)=split(/:/,$readline);
          if ($name =~ /$reqhost/i) {
              my $filename=$r->filename;
              if ((-e "$filename.$id") || ($filename=~/\.meta$/)) {
	         return OK;
              } else {
                 $r->log_reason("$id not subscribed", $r->filename);
                 return FORBIDDEN;
              }
          }
       }

    }
    $r->log_reason("Invalid request for file transfer from $reqhost", 
                   $r->filename); 
    return FORBIDDEN;
}

1;
__END__









FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>