Diff for /loncom/auth/lonracc.pm between versions 1.14 and 1.18

version 1.14, 2005/02/05 22:20:56 version 1.18, 2007/02/01 06:20:34
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;  use IO::Socket;
   
 sub subscribed {  sub subscribed {
     my ($filename,$id) = @_;      my ($filename,$id) = @_;
     my $found=0;  
       return 0 if (-e "$filename.subscription");
   
     my $hostname=$Apache::lonnet::hostname{$id};      my $hostname=$Apache::lonnet::hostname{$id};
     my (undef,undef,undef,undef,$ip) = gethostbyname($hostname);      my (undef,undef,undef,undef,$ip) = gethostbyname($hostname);
       
       return 0 if (length($ip) != 4);
   
     $ip=inet_ntoa($ip);      $ip=inet_ntoa($ip);
     my $expr='^'.$id.':'.$ip.':';  
     $expr =~ s/\./\\\./g;      my $expr='^'.quotemeta($id).':'.quotemeta($ip).':';
     my $sh;  
     if ($sh=Apache::File->new("$filename.subscription")) {      my $found=0;
       if (my $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 52  sub subscribed { Line 58  sub subscribed {
   
 sub handler {  sub handler {
     my $r = shift;      my $r = shift;
     my $reqhost = $r->get_remote_host(REMOTE_HOST);      my $reqhost = $r->get_remote_host(REMOTE_NOLOOKUP);
     if (!$reqhost) {      my %iphost=&Apache::lonnet::get_iphost();
  $r->log_reason("Unable to do hostname lookup for ".$ENV{'REMOTE_ADDR'});      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} =~ /\Q$reqhost\E/i) {   my $filename=$r->filename;
     my $filename=$r->filename;   my $uri =$r->uri;
     my $uri =$r->uri;   if (($filename=~/\.meta$/) ||
     if ((-e "$filename.$id") ||      ($uri=~m|^/raw/uploaded|) ||
  &subscribed($filename,$id) ||      (-e "$filename.$id") ||
  ($filename=~/\.meta$/) ||      &subscribed($filename,$id) ) {
  ($uri=~m|^/raw/uploaded|)) {      return OK;
  return OK;   } else {
     } else {      $return=FORBIDDEN;
  $return=FORBIDDEN;      push(@ids,$id);
  push(@ids,$id);  
     }  
  }   }
     }      }
     if ($return == FORBIDDEN) {      if ($return == FORBIDDEN) {

Removed from v.1.14  
changed lines
  Added in v.1.18


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