[LON-CAPA-cvs] cvs: loncom /auth lonracc.pm lontokacc.pm

albertel lon-capa-cvs@mail.lon-capa.org
Sun, 06 Feb 2005 07:23:40 -0000


albertel		Sun Feb  6 02:23:40 2005 EDT

  Modified files:              
    /loncom/auth	lonracc.pm lontokacc.pm 
  Log:
  - better job of finding our whose asking for stuff
  
  
Index: loncom/auth/lonracc.pm
diff -u loncom/auth/lonracc.pm:1.14 loncom/auth/lonracc.pm:1.15
--- loncom/auth/lonracc.pm:1.14	Sat Feb  5 17:20:56 2005
+++ loncom/auth/lonracc.pm	Sun Feb  6 02:23:40 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Access Handler for File Transfers
 #
-# $Id: lonracc.pm,v 1.14 2005/02/05 22:20:56 albertel Exp $
+# $Id: lonracc.pm,v 1.15 2005/02/06 07:23:40 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -52,9 +52,12 @@
 
 sub handler {
     my $r = shift;
-    my $reqhost = $r->get_remote_host(REMOTE_HOST);
+    my $reqhost = $r->get_remote_host(REMOTE_NOLOOKUP);
+    my $netaddr=inet_aton($reqhost);
+    ($reqhost) = gethostbyaddr($netaddr,AF_INET);
     if (!$reqhost) {
-	$r->log_reason("Unable to do hostname lookup for ".$ENV{'REMOTE_ADDR'});
+	$r->log_reason("Unable to do hostname $reqhost lookup for ".$r->get_remote_host(REMOTE_NOLOOKUP));
+	return FORBIDDEN;
     }
     if ($reqhost eq 'localhost.localdomain') {
 	return OK;
@@ -63,7 +66,7 @@
     my @ids=();
     my $id;
     foreach $id (keys %Apache::lonnet::hostname) {
-	if ($Apache::lonnet::hostname{$id} =~ /\Q$reqhost\E/i) {
+	if ($Apache::lonnet::hostname{$id} =~ /^\Q$reqhost\E$/i) {
 	    my $filename=$r->filename;
 	    my $uri =$r->uri;
 	    if ((-e "$filename.$id") ||
Index: loncom/auth/lontokacc.pm
diff -u loncom/auth/lontokacc.pm:1.11 loncom/auth/lontokacc.pm:1.12
--- loncom/auth/lontokacc.pm:1.11	Sat Feb  5 17:20:56 2005
+++ loncom/auth/lontokacc.pm	Sun Feb  6 02:23:40 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Access Handler for User File Transfers
 #
-# $Id: lontokacc.pm,v 1.11 2005/02/05 22:20:56 albertel Exp $
+# $Id: lontokacc.pm,v 1.12 2005/02/06 07:23:40 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -36,7 +36,13 @@
 
 sub handler {
     my $r = shift;
-    my $reqhost = $r->get_remote_host(REMOTE_HOST);
+    my $reqhost = $r->get_remote_host(REMOTE_NOLOOKUP);
+    my $netaddr=inet_aton($reqhost);
+    ($reqhost) = gethostbyaddr($netaddr,AF_INET);
+    if (!$reqhost) {
+	$r->log_reason("Unable to do hostname $reqhost lookup for ".$r->get_remote_host(REMOTE_NOLOOKUP));
+	return FORBIDDEN;
+    }
     if ($reqhost eq 'localhost.localdomain') {
        return OK;
     }