[LON-CAPA-cvs] cvs: loncom /auth loncacc.pm lonroles.pm /lonnet/perl lonnet.pm /publisher lonpublisher.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Tue, 27 Jan 2004 22:55:00 -0000
albertel Tue Jan 27 17:55:00 2004 EDT
Modified files:
/loncom/lonnet/perl lonnet.pm
/loncom/auth loncacc.pm lonroles.pm
/loncom/publisher lonpublisher.pm
Log:
- supporting authors on multidomain machines
- this works, but requires that all users that author have unique usernames
( I.e. albertel@basement and albertel@annarbor will end up accessing the same /home/albertel/public_html)
- I plan on isntalling this on s17.lite.msu.edu to support the serway@brookscole user
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.464 loncom/lonnet/perl/lonnet.pm:1.465
--- loncom/lonnet/perl/lonnet.pm:1.464 Mon Jan 26 16:58:34 2004
+++ loncom/lonnet/perl/lonnet.pm Tue Jan 27 17:54:59 2004
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.464 2004/01/26 21:58:34 albertel Exp $
+# $Id: lonnet.pm,v 1.465 2004/01/27 22:54:59 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -4484,6 +4484,30 @@
return $file;
}
return $file;
+}
+
+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
Index: loncom/auth/loncacc.pm
diff -u loncom/auth/loncacc.pm:1.32 loncom/auth/loncacc.pm:1.33
--- loncom/auth/loncacc.pm:1.32 Thu Jan 15 15:22:47 2004
+++ loncom/auth/loncacc.pm Tue Jan 27 17:54:59 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.32 2004/01/15 20:22:47 www Exp $
+# $Id: loncacc.pm,v 1.33 2004/01/27 22:54:59 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/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.82 loncom/auth/lonroles.pm:1.83
--- loncom/auth/lonroles.pm:1.82 Thu Jan 15 15:22:47 2004
+++ loncom/auth/lonroles.pm Tue Jan 27 17:54:59 2004
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.82 2004/01/15 20:22:47 www Exp $
+# $Id: lonroles.pm,v 1.83 2004/01/27 22:54:59 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -404,7 +404,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}.
@@ -425,7 +428,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/publisher/lonpublisher.pm
diff -u loncom/publisher/lonpublisher.pm:1.162 loncom/publisher/lonpublisher.pm:1.163
--- loncom/publisher/lonpublisher.pm:1.162 Tue Jan 20 17:52:17 2004
+++ loncom/publisher/lonpublisher.pm Tue Jan 27 17:54:59 2004
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Publication Handler
#
-# $Id: lonpublisher.pm,v 1.162 2004/01/20 22:52:17 albertel Exp $
+# $Id: lonpublisher.pm,v 1.163 2004/01/27 22:54:59 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1840,12 +1840,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;
}