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

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 02 Mar 2007 23:43:30 -0000


albertel		Fri Mar  2 18:43:30 2007 EDT

  Modified files:              
    /loncom/lonnet/perl	lonnet.pm 
    /loncom/auth	lonracc.pm lontokacc.pm 
  Log:
  - maiking this get_iphost thing more targeted easier to dns with
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.838 loncom/lonnet/perl/lonnet.pm:1.839
--- loncom/lonnet/perl/lonnet.pm:1.838	Fri Mar  2 18:17:40 2007
+++ loncom/lonnet/perl/lonnet.pm	Fri Mar  2 18:43:24 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.838 2007/03/02 23:17:40 albertel Exp $
+# $Id: lonnet.pm,v 1.839 2007/03/02 23:43:24 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -7634,6 +7634,15 @@
     }
 }
 
+sub get_hosts_from_ip {
+    my ($ip) = @_;
+    my %iphosts = &get_iphost();
+    if (ref($iphosts{$ip})) {
+	return @{$iphosts{$ip}};
+    }
+    return;
+}
+
 sub get_iphost {
     if (%iphost) { return %iphost; }
     my %name_to_ip;
Index: loncom/auth/lonracc.pm
diff -u loncom/auth/lonracc.pm:1.21 loncom/auth/lonracc.pm:1.22
--- loncom/auth/lonracc.pm:1.21	Fri Mar  2 18:17:48 2007
+++ loncom/auth/lonracc.pm	Fri Mar  2 18:43:29 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Access Handler for File Transfers
 #
-# $Id: lonracc.pm,v 1.21 2007/03/02 23:17:48 albertel Exp $
+# $Id: lonracc.pm,v 1.22 2007/03/02 23:43:29 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -65,9 +65,8 @@
     }
 
     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' ) {
+    my @hostids= &Apache::lonnet::get_hosts_from_ip($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;
@@ -78,7 +77,7 @@
     my $return;
     my @ids;
 
-    foreach my $id (@{$hostids}) {
+    foreach my $id (@hostids) {
 	my $uri =$r->uri;
 	if (($filename=~/\.meta$/) ||
 	    ($uri=~m|^/raw/uploaded|) ||
Index: loncom/auth/lontokacc.pm
diff -u loncom/auth/lontokacc.pm:1.17 loncom/auth/lontokacc.pm:1.18
--- loncom/auth/lontokacc.pm:1.17	Fri Mar  2 18:17:48 2007
+++ loncom/auth/lontokacc.pm	Fri Mar  2 18:43:29 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Access Handler for User File Transfers
 #
-# $Id: lontokacc.pm,v 1.17 2007/03/02 23:17:48 albertel Exp $
+# $Id: lontokacc.pm,v 1.18 2007/03/02 23:43:29 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -37,9 +37,8 @@
 sub handler {
     my $r = shift;
     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' ) {
+    my @hostids= &Apache::lonnet::get_hosts_from_ip($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;
@@ -58,7 +57,7 @@
        while ($readline=<$fh>) {
 	   $readline=~s/\s*$//;
 	   my ($id,$domain,$role,$name)=split(/:/,$readline);
-	   foreach my $hostid (@{$hostids}) {
+	   foreach my $hostid (@hostids) {
 	       my $hostname=&Apache::lonnet::hostname($hostid);
 	       if ($name =~ /^\Q$hostname\E$/i) {
 		   return OK; 
@@ -67,7 +66,7 @@
        }
 
     }
-    $r->log_reason("Invalid request for user file transfer from $reqhost (".join(",",@{$hostids}).")", 
+    $r->log_reason("Invalid request for user file transfer from $reqhost (".join(",",@hostids).")", 
                    $r->filename); 
     return FORBIDDEN;
 }