version 1.12, 2004/04/26 00:07:29
|
version 1.15, 2005/02/06 07:23:40
|
Line 32 use strict;
|
Line 32 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) = @_; |
my $found=0; |
my $found=0; |
my $expr='^'.$id.':'.$Apache::lonnet::hostip{$id}.':'; |
my $hostname=$Apache::lonnet::hostname{$id}; |
|
my (undef,undef,undef,undef,$ip) = gethostbyname($hostname); |
|
$ip=inet_ntoa($ip); |
|
my $expr='^'.$id.':'.$ip.':'; |
$expr =~ s/\./\\\./g; |
$expr =~ s/\./\\\./g; |
my $sh; |
my $sh; |
if ($sh=Apache::File->new("$filename.subscription")) { |
if ($sh=Apache::File->new("$filename.subscription")) { |
Line 48 sub subscribed {
|
Line 52 sub subscribed {
|
|
|
sub handler { |
sub handler { |
my $r = shift; |
my $r = shift; |
my $reqhost = $r->get_remote_host(REMOTE_DOUBLE_REV); |
my $reqhost = $r->get_remote_host(REMOTE_NOLOOKUP); |
if (!$reqhost && $r->get_remote_host(REMOTE_NOLOOKUP) eq $r->get_server_name()) { |
my $netaddr=inet_aton($reqhost); |
$reqhost = $r->get_server_name(); |
($reqhost) = gethostbyaddr($netaddr,AF_INET); |
} |
if (!$reqhost) { |
unless ($reqhost) { |
$r->log_reason("Unable to do hostname $reqhost lookup for ".$r->get_remote_host(REMOTE_NOLOOKUP)); |
$r->log_reason("Spoof request from ".$ENV{'REMOTE_ADDR'}); |
return FORBIDDEN; |
return FORBIDDEN; |
|
} |
} |
if ($reqhost eq 'localhost.localdomain') { |
if ($reqhost eq 'localhost.localdomain') { |
return OK; |
return OK; |
} |
} |
my $readline; |
my $return; |
my $lontabdir=$r->dir_config('lonTabDir'); |
my @ids=(); |
{ |
my $id; |
my $fh; |
foreach $id (keys %Apache::lonnet::hostname) { |
unless ($fh=Apache::File->new("$lontabdir/hosts.tab")) { |
if ($Apache::lonnet::hostname{$id} =~ /^\Q$reqhost\E$/i) { |
$r->log_reason("Could not find host tab file"); |
my $filename=$r->filename; |
return FORBIDDEN; |
my $uri =$r->uri; |
} |
if ((-e "$filename.$id") || |
my $return; |
&subscribed($filename,$id) || |
my @ids=(); |
($filename=~/\.meta$/) || |
while ($readline=<$fh>) { |
($uri=~m|^/raw/uploaded|)) { |
my ($id,$domain,$role,$name,$ip)=split(/:/,$readline); |
return OK; |
if ($name =~ /$reqhost/i) { |
} else { |
my $filename=$r->filename; |
$return=FORBIDDEN; |
my $uri =$r->uri; |
push(@ids,$id); |
if ((-e "$filename.$id") || |
} |
&subscribed($filename,$id) || |
} |
($filename=~/\.meta$/) || |
} |
($uri=~m|^/raw/uploaded|)) { |
if ($return == FORBIDDEN) { |
return OK; |
$r->log_reason(join(':',@ids)." not subscribed", $r->filename); |
} else { |
return FORBIDDEN; |
$return=FORBIDDEN; |
|
push(@ids,$id); |
|
} |
|
} |
|
} |
|
if ($return == FORBIDDEN) { |
|
$r->log_reason(join(':',@ids)." not subscribed", $r->filename); |
|
return FORBIDDEN; |
|
} |
|
} |
} |
$r->log_reason("Invalid request for file transfer from $reqhost", |
$r->log_reason("Invalid request for file transfer from $reqhost", |
$r->filename); |
$r->filename); |