File:  [LON-CAPA] / loncom / auth / lonracc.pm
Revision 1.3: download - view: text, annotated - select for diffs
Thu Nov 29 19:12:44 2001 UTC (22 years, 7 months ago) by www
Branches: MAIN
CVS tags: HEAD
GPL

    1: # The LearningOnline Network
    2: # Access Handler for File Transfers
    3: #
    4: # $Id: lonracc.pm,v 1.3 2001/11/29 19:12:44 www Exp $
    5: #
    6: # Copyright Michigan State University Board of Trustees
    7: #
    8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    9: #
   10: # LON-CAPA is free software; you can redistribute it and/or modify
   11: # it under the terms of the GNU General Public License as published by
   12: # the Free Software Foundation; either version 2 of the License, or
   13: # (at your option) any later version.
   14: #
   15: # LON-CAPA is distributed in the hope that it will be useful,
   16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   18: # GNU General Public License for more details.
   19: #
   20: # You should have received a copy of the GNU General Public License
   21: # along with LON-CAPA; if not, write to the Free Software
   22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   23: #
   24: # /home/httpd/html/adm/gpl.txt
   25: #
   26: # http://www.lon-capa.org/
   27: #
   28: # (lonacc: Cookie Based Access Handler
   29: # 5/21/99,5/22,5/29,5/31,6/15 Gerd Kortemeyer)
   30: # 6/16,6/18,7/3,
   31: # 6/30/00 Gerd Kortemeyer
   32: 
   33: package Apache::lonracc;
   34: 
   35: use strict;
   36: use Apache::Constants qw(:common :remotehost);
   37: use Apache::File();
   38: 
   39: sub handler {
   40:     my $r = shift;
   41:     my $reqhost;
   42:     unless ($reqhost=$r->get_remote_host(REMOTE_DOUBLE_REV)) {
   43:        $r->log_reason("Spoof request");
   44:        return FORBIDDEN;
   45:     }
   46:     my $readline;
   47:     my $lontabdir=$r->dir_config('lonTabDir');
   48:     {
   49:        my $fh;
   50:        unless ($fh=Apache::File->new("$lontabdir/hosts.tab")) {
   51:           $r->log_reason("Could not find host tab file");
   52:           return FORBIDDEN;
   53:        }
   54:        while ($readline=<$fh>) {
   55:           my ($id,$domain,$role,$name,$ip)=split(/:/,$readline);
   56:           if ($name =~ /$reqhost/i) {
   57:               my $filename=$r->filename;
   58:               if ((-e "$filename.$id") || ($filename=~/\.meta$/)) {
   59: 	         return OK;
   60:               } else {
   61:                  $r->log_reason("$id not subscribed", $r->filename);
   62:                  return FORBIDDEN;
   63:               }
   64:           }
   65:        }
   66: 
   67:     }
   68:     $r->log_reason("Invalid request for file transfer from $reqhost", 
   69:                    $r->filename); 
   70:     return FORBIDDEN;
   71: }
   72: 
   73: 1;
   74: __END__
   75: 
   76: 
   77: 
   78: 
   79: 
   80: 
   81: 
   82: 

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