[LON-CAPA-cvs] cvs: loncom(version_1_1_X) /auth loncacc.pm lonlogin.pm lonroles.pm /lonnet/perl lonnet.pm /publisher lonpublisher.pm

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 10 Feb 2004 19:23:11 -0000


albertel		Tue Feb 10 14:23:11 2004 EDT

  Modified files:              (Branch: version_1_1_X)
    /loncom/auth	loncacc.pm lonlogin.pm lonroles.pm 
    /loncom/lonnet/perl	lonnet.pm 
    /loncom/publisher	lonpublisher.pm 
  Log:
  - backporting support for CSTR on multidomained machines into 1.1.X
  
  
Index: loncom/auth/loncacc.pm
diff -u loncom/auth/loncacc.pm:1.31 loncom/auth/loncacc.pm:1.31.4.1
--- loncom/auth/loncacc.pm:1.31	Sat Sep 20 13:44:22 2003
+++ loncom/auth/loncacc.pm	Tue Feb 10 14:23:11 2004
@@ -2,7 +2,7 @@
 # Cookie Based Access Handler for Construction Area
 # (lonacc: 5/21/99,5/22,5/29,5/31 Gerd Kortemeyer)
 #
-# $Id: loncacc.pm,v 1.31 2003/09/20 17:44:22 www Exp $
+# $Id: loncacc.pm,v 1.31.4.1 2004/02/10 19:23:11 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -43,6 +43,8 @@
 use CGI::Cookie();
 use Fcntl qw(:flock);
 use Apache::lonlocal;
+use Apache::lonnet();
+
 
 sub constructaccess {
     my ($url,$ownerdomain)=@_;
@@ -50,17 +52,24 @@
     unless (($ownername) && ($ownerdomain)) { return ''; }
     # We do not allow editing of previous versions of files.
     if ($url=~/\.(\d+)\.(\w+)$/) { return ''; }
-    if (($ownername eq $ENV{'user.name'}) &&
-        ($ownerdomain eq $ENV{'user.domain'})) {
-	return ($ownername,$ownerdomain);
+    my @possibledomains = &Apache::lonnet::current_machine_domains();
+    &Apache::lonnet::logthis("got domains of ".join(':',@possibledomains));
+    if ($ownername eq $ENV{'user.name'}) {
+	foreach my $domain (@possibledomains) {
+	    if ($domain eq $ENV{'user.domain'}) {
+		return ($ownername,$domain);
+	    }
+	}
     }
+    
 
-    my $capriv='user.priv.ca./'.
-               $ownerdomain.'/'.$ownername.'./';
-    foreach (keys %ENV) {
-        if ($_ eq $capriv) {
-           return ($ownername,$ownerdomain);
-        }
+    foreach my $domain (@possibledomains) {
+	my $capriv='user.priv.ca./'.$domain.'/'.$ownername.'./';
+	foreach (keys %ENV) {
+	    if ($_ eq $capriv) {
+		return ($ownername,$domain);
+	    }
+	}
     }
     return '';
 }
Index: loncom/auth/lonlogin.pm
diff -u loncom/auth/lonlogin.pm:1.55 loncom/auth/lonlogin.pm:1.55.4.1
--- loncom/auth/lonlogin.pm:1.55	Wed Nov 12 11:55:40 2003
+++ loncom/auth/lonlogin.pm	Tue Feb 10 14:23:11 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Login Screen
 #
-# $Id: lonlogin.pm,v 1.55 2003/11/12 16:55:40 www Exp $
+# $Id: lonlogin.pm,v 1.55.4.1 2004/02/10 19:23:11 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -109,6 +109,10 @@
     my $iconpath= 'http://'.$ENV{'HTTP_HOST'}.':'.$port_to_use.
                   $r->dir_config('lonIconsURL');
     my $domain  = $r->dir_config('lonDefDomain');
+    my $testdomain=(split(/\./,$ENV{'HTTP_HOST'}))[0];
+    foreach my $posdom (values(%Apache::lonnet::hostdom)) {
+	if ($posdom eq $testdomain) { $domain=$testdomain; }
+    }
     if (($ENV{'form.domain'}) && 
 	 ($Apache::lonnet::domaindescription{$ENV{'form.domain'}})) {
 	$domain=$ENV{'form.domain'};
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.80 loncom/auth/lonroles.pm:1.80.4.1
--- loncom/auth/lonroles.pm:1.80	Tue Dec  9 16:25:53 2003
+++ loncom/auth/lonroles.pm	Tue Feb 10 14:23:11 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # User Roles Screen
 #
-# $Id: lonroles.pm,v 1.80 2003/12/09 21:25:53 albertel Exp $
+# $Id: lonroles.pm,v 1.80.4.1 2004/02/10 19:23:11 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -402,7 +402,10 @@
                 # First, Co-Authorship roles
                 if ($role eq 'ca') {
                     my $home = &Apache::lonnet::homeserver($trest,$tdom);
-                    if ($home ne $r->dir_config('lonHostID')) {
+		    my $allowed=0;
+		    my @ids=&Apache::lonnet::current_machine_ids();
+		    foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
+                    if (!$allowed) {
 			$button=0;
                         $switchserver=&Apache::lonnet::escape('http://'.
                          $Apache::lonnet::hostname{$home}.
@@ -422,7 +425,10 @@
                     # Authors
                     my $home = &Apache::lonnet::homeserver
                         ($ENV{'user.name'},$ENV{'user.domain'});
-                    if ($home ne $r->dir_config('lonHostID')) {
+		    my $allowed=0;
+		    my @ids=&Apache::lonnet::current_machine_ids();
+		    foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
+                    if (!$allowed) {
 			$button=0;
                         $switchserver=&Apache::lonnet::escape('http://'.
                          $Apache::lonnet::hostname{$home}.
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.459.2.2 loncom/lonnet/perl/lonnet.pm:1.459.2.3
--- loncom/lonnet/perl/lonnet.pm:1.459.2.2	Mon Jan 26 17:00:07 2004
+++ loncom/lonnet/perl/lonnet.pm	Tue Feb 10 14:23:11 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.459.2.2 2004/01/26 22:00:07 albertel Exp $
+# $Id: lonnet.pm,v 1.459.2.3 2004/02/10 19:23:11 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -4453,6 +4453,31 @@
     }
 }
 
+
+sub current_machine_domains {
+    my $hostname=$hostname{$perlvar{'lonHostID'}};
+    my @domains;
+    while( my($id, $name) = each(%hostname)) {
+	&logthis("-$id-$name-$hostname-");
+	if ($hostname eq $name) {
+	    push(@domains,$hostdom{$id});
+	}
+    }
+    return @domains;
+}
+
+sub current_machine_ids {
+    my $hostname=$hostname{$perlvar{'lonHostID'}};
+    my @ids;
+    while( my($id, $name) = each(%hostname)) {
+	&logthis("-$id-$name-$hostname-");
+	if ($hostname eq $name) {
+	    push(@ids,$id);
+	}
+    }
+    return @ids;
+}
+  
 # ------------------------------------------------------------- Declutters URLs
 
 sub declutter {
Index: loncom/publisher/lonpublisher.pm
diff -u loncom/publisher/lonpublisher.pm:1.145.2.1 loncom/publisher/lonpublisher.pm:1.145.2.2
--- loncom/publisher/lonpublisher.pm:1.145.2.1	Tue Jan 20 18:02:20 2004
+++ loncom/publisher/lonpublisher.pm	Tue Feb 10 14:23:11 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Publication Handler
 #
-# $Id: lonpublisher.pm,v 1.145.2.1 2004/01/20 23:02:20 albertel Exp $
+# $Id: lonpublisher.pm,v 1.145.2.2 2004/02/10 19:23:11 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1731,12 +1731,14 @@
 	return HTTP_NOT_ACCEPTABLE;
     }
 
-    unless (&Apache::lonnet::homeserver($cuname,$cudom) 
-	    eq $r->dir_config('lonHostID')) {
+    my $home=&Apache::lonnet::homeserver($cuname,$cudom);
+    my $allowed=0;
+    my @ids=&Apache::lonnet::current_machine_ids();
+    foreach my $id (@ids) { if ($id eq $home) { $allowed = 1; }  }
+    unless ($allowed) {
 	$r->log_reason($cuname.' at '.$cudom.
 		       ' trying to publish file '.$ENV{'form.filename'}.
-		       ' ('.$fn.') - not homeserver ('.
-		       &Apache::lonnet::homeserver($cuname,$cudom).')', 
+		       ' ('.$fn.') - not homeserver ('.$home.')', 
 		       $r->filename); 
 	return HTTP_NOT_ACCEPTABLE;
     }