--- loncom/auth/lontokacc.pm 2002/08/02 14:45:04 1.5 +++ loncom/auth/lontokacc.pm 2005/02/05 22:20:56 1.11 @@ -1,7 +1,7 @@ # The LearningOnline Network # Access Handler for User File Transfers # -# $Id: lontokacc.pm,v 1.5 2002/08/02 14:45:04 www Exp $ +# $Id: lontokacc.pm,v 1.11 2005/02/05 22:20:56 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -33,12 +33,12 @@ use Apache::Constants qw(:common :remote use Apache::lonnet(); use Apache::File(); + sub handler { my $r = shift; - my $reqhost; - unless ($reqhost=$r->get_remote_host(REMOTE_DOUBLE_REV)) { - $r->log_reason("Spoof request ".$reqhost); - return FORBIDDEN; + my $reqhost = $r->get_remote_host(REMOTE_HOST); + if ($reqhost eq 'localhost.localdomain') { + return OK; } my $readline; my $lontabdir=$r->dir_config('lonTabDir'); @@ -49,11 +49,11 @@ sub handler { return FORBIDDEN; } while ($readline=<$fh>) { - my ($id,$domain,$role,$name,$ip)=split(/:/,$readline); - if ($name =~ /$reqhost/i) { - $r->register_cleanup(\&removefile); - return OK; - } + $readline=~s/\s*$//; + my ($id,$domain,$role,$name)=split(/:/,$readline); + if ($name =~ /\Q$reqhost\E/i) { + return OK; + } } } @@ -64,10 +64,11 @@ sub handler { sub removefile { my $r=shift; - if ($r->status==HTTP_OK) { - &Apache::lonnet::logthis('Unlinking '.$r->filename); + if ($r->status==200) { + unlink($r->filename); + #&Apache::lonnet::logthis('Unlinking '.$r->filename); } else { - &Apache::lonnet::logthis("Failed to transfer ".$r->filename); + &Apache::lonnet::logthis('Failed to transfer '.$r->filename); } } 1;