Diff for /loncom/auth/lonracc.pm between versions 1.13 and 1.20

version 1.13, 2004/05/03 19:52:19 version 1.20, 2007/02/01 07:13:04
Line 30  package Apache::lonracc; Line 30  package Apache::lonracc;
   
 use strict;  use strict;
 use Apache::Constants qw(:common :remotehost);  use Apache::Constants qw(:common :remotehost);
 use Apache::lonnet();  use Apache::lonnet;
 use Apache::File();  use Apache::File();
   use IO::Socket;
   
 sub subscribed {  sub subscribed {
     my ($filename,$id) = @_;      my ($filename,$id) = @_;
   
       return 0 if (!-e "$filename.subscription");
   
       my $hostname=$Apache::lonnet::hostname{$id};
       my (undef,undef,undef,undef,$ip) = gethostbyname($hostname);
       
       return 0 if (length($ip) != 4);
   
       $ip=inet_ntoa($ip);
   
       my $expr='^'.quotemeta($id).':'.quotemeta($ip).':';
   
     my $found=0;      my $found=0;
     my $expr='^'.$id.':'.$Apache::lonnet::hostip{$id}.':';      if (my $sh=Apache::File->new("$filename.subscription")) {
     $expr =~ s/\./\\\./g;  
     my $sh;  
     if ($sh=Apache::File->new("$filename.subscription")) {  
  while (my $subline=<$sh>) { if ($subline =~ /$expr/) { $found=1; } }   while (my $subline=<$sh>) { if ($subline =~ /$expr/) { $found=1; } }
  $sh->close();   $sh->close();
     }      }
Line 48  sub subscribed { Line 58  sub subscribed {
   
 sub handler {  sub handler {
     my $r = shift;      my $r = shift;
     my $reqhost = $r->get_remote_host(REMOTE_DOUBLE_REV);  
     if (!$reqhost && $r->get_remote_host(REMOTE_NOLOOKUP) eq $r->get_server_name()) {       my $filename=$r->filename;
         $reqhost = $r->get_server_name();      if (!-e $filename) {
     }    return NOT_FOUND;
     unless ($reqhost) {      }
        $r->log_reason("Spoof request from ".$ENV{'REMOTE_ADDR'});  
        return FORBIDDEN;      my $reqhost = $r->get_remote_host(REMOTE_NOLOOKUP);
       my %iphost=&Apache::lonnet::get_iphost();
       my $hostids=$iphost{$reqhost};
       if (!$hostids && $reqhost ne '127.0.0.1' ) {
    $r->log_reason("Unable to find a host for ".
          $r->get_remote_host(REMOTE_NOLOOKUP));
    return FORBIDDEN;
     }      }
     if ($reqhost eq 'localhost.localdomain') {      if ($reqhost eq '127.0.0.1') {
        return OK;   return OK;
     }      }
     my $return;      my $return;
     my @ids=();      my @ids;
     my $id;  
     foreach $id (keys %Apache::lonnet::hostname) {      foreach my $id (@{$hostids}) {
  if ($Apache::lonnet::hostname{$id} =~ /$reqhost/i) {   my $uri =$r->uri;
     my $filename=$r->filename;   if (($filename=~/\.meta$/) ||
     my $uri =$r->uri;      ($uri=~m|^/raw/uploaded|) ||
     if ((-e "$filename.$id") ||      (-e "$filename.$id") ||
  &subscribed($filename,$id) ||      &subscribed($filename,$id) ) {
  ($filename=~/\.meta$/) ||      return OK;
  ($uri=~m|^/raw/uploaded|)) {   } else {
  return OK;      $return=FORBIDDEN;
     } else {      push(@ids,$id);
  $return=FORBIDDEN;  
  push(@ids,$id);  
     }  
  }   }
     }      }
     if ($return == FORBIDDEN) {      if ($return == FORBIDDEN) {

Removed from v.1.13  
changed lines
  Added in v.1.20


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