[LON-CAPA-cvs] cvs: loncom /interface lonannounce.pm /lonnet/perl lonnet.pm

albertel lon-capa-cvs@mail.lon-capa.org
Sat, 03 Mar 2007 02:16:17 -0000


albertel		Fri Mar  2 21:16:17 2007 EDT

  Modified files:              
    /loncom/lonnet/perl	lonnet.pm 
    /loncom/interface	lonannounce.pm 
  Log:
  - remove accesses from hostdom global
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.843 loncom/lonnet/perl/lonnet.pm:1.844
--- loncom/lonnet/perl/lonnet.pm:1.843	Fri Mar  2 21:10:59 2007
+++ loncom/lonnet/perl/lonnet.pm	Fri Mar  2 21:16:10 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.843 2007/03/03 02:10:59 albertel Exp $
+# $Id: lonnet.pm,v 1.844 2007/03/03 02:16:10 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -35,7 +35,7 @@
 use HTTP::Date;
 # use Date::Parse;
 use vars 
-qw(%perlvar %badServerCache %iphost %spareid %hostdom 
+qw(%perlvar %badServerCache %iphost %spareid 
    %libserv %pr %prp $memcache %packagetab 
    %courselogs %accesshash %userrolehash %domainrolehash $processmarker $dumpcount 
    %coursedombuf %coursenumbuf %coursehombuf %coursedescrbuf %courseinstcodebuf %courseownerbuf %coursetypebuf
@@ -1842,7 +1842,7 @@
 # Is used in pickcourse
 #
     foreach my $crs_home (keys(%courseidbuffer)) {
-        &courseidput($hostdom{$crs_home},$courseidbuffer{$crs_home},
+        &courseidput(&host_domain($crs_home),$courseidbuffer{$crs_home},
 		     $crs_home);
     }
 #
@@ -2097,7 +2097,7 @@
 
 sub postannounce {
     my ($server,$text)=@_;
-    unless (&allowed('psa',$hostdom{$server})) { return 'refused'; }
+    unless (&allowed('psa',&host_domain($server))) { return 'refused'; }
     unless ($text=~/\w/) { $text=''; }
     return &reply('setannounce:'.&escape($text),$server);
 }
@@ -2135,9 +2135,9 @@
     unless ($domfilter) { $domfilter=''; }
     foreach my $tryserver (keys %libserv) {
         if ( ($hostidflag == 1 && grep/^$tryserver$/,@{$hostidref}) || (!defined($hostidflag)) ) {
-	    if ((!$domfilter) || ($hostdom{$tryserver} eq $domfilter)) {
+	    if ((!$domfilter) || (&host_domain($tryserver) eq $domfilter)) {
 	        foreach my $line (
-                 split(/\&/,&reply('courseiddump:'.$hostdom{$tryserver}.':'.
+                 split(/\&/,&reply('courseiddump:'.&host_domain($tryserver).':'.
 			       $sincefilter.':'.&escape($descfilter).':'.
                                &escape($instcodefilter).':'.&escape($ownerfilter).':'.&escape($coursefilter).':'.&escape($typefilter).':'.&escape($regexp_ok),
                                $tryserver))) {
@@ -4811,7 +4811,7 @@
     if (($uhome eq 'no_host') && 
 	(($umode && $upass) || ($umode eq 'localauth'))) {
         my $unhome='';
-        if (defined($desiredhome) && $hostdom{$desiredhome} eq $udom) { 
+        if (defined($desiredhome) && &host_domain($desiredhome) eq $udom) { 
             $unhome = $desiredhome;
 	} elsif($env{'course.'.$env{'request.course.id'}.'.domain'} eq $udom) {
 	    $unhome=$env{'course.'.$env{'request.course.id'}.'.home'};
@@ -7404,7 +7404,7 @@
     while( my($id, $name) = each(%hostname)) {
 #	&logthis("-$id-$name-$hostname-");
 	if ($hostname eq $name) {
-	    push(@domains,$hostdom{$id});
+	    push(@domains,&host_domain($id));
 	}
     }
     return @domains;
@@ -7592,6 +7592,7 @@
 # ------------------------------------------------------------- Read hosts file
 {
     my %hostname;
+    my %hostdom;
     open(my $config,"<$perlvar{'lonTabDir'}/hosts.tab");
 
     while (my $configline=<$config>) {
@@ -7636,6 +7637,11 @@
 	}
 	return %result;
     }
+    sub host_domain {
+	my ($lonid) = @_;
+	return $hostdom{$lonid};
+    }
+
     sub all_domains {
 	my %seen;
 	my @uniq = grep(!$seen{$_}++, values(%hostdom));
Index: loncom/interface/lonannounce.pm
diff -u loncom/interface/lonannounce.pm:1.66 loncom/interface/lonannounce.pm:1.67
--- loncom/interface/lonannounce.pm:1.66	Fri Mar  2 18:17:58 2007
+++ loncom/interface/lonannounce.pm	Fri Mar  2 21:16:17 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Announce
 #
-# $Id: lonannounce.pm,v 1.66 2007/03/02 23:17:58 albertel Exp $
+# $Id: lonannounce.pm,v 1.67 2007/03/03 02:16:17 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -499,7 +499,8 @@
 # list servers
     my %hostname = &Apache::lonnet::all_hostnames();
     foreach my $host (sort(keys(%hostname))) {
-	if (&Apache::lonnet::allowed('psa',$Apache::lonnet::hostdom{$host})) {
+	if (&Apache::lonnet::allowed('psa',
+				     &Apache::lonnet::host_domain($host))) {
 	    $r->print ('<br /><label><input type="checkbox" name="postto_'.$host.'" /> '.
 		       $host.' <tt>'.$hostname{$host}.'</tt> '.
 		       '</label><a href="http://'.$hostname{$host}.