File:  [LON-CAPA] / loncom / auth / lonracc.pm
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Wed Oct 13 17:48:52 1999 UTC (24 years, 6 months ago) by albertel
Branches: loncom
CVS tags: start, LATEST, Bacillus, Aquifex
LON-CAPA Communication Module

# 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 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") {
	         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>