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

matthew lon-capa-cvs@mail.lon-capa.org
Thu, 08 Aug 2002 20:33:50 -0000


matthew		Thu Aug  8 16:33:50 2002 EDT

  Modified files:              
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  Bug 263.  Modified &allowed to deal properly with domain coordinator 
  domains.  Modified &createcourse to take another parameter to specify
  the server to create a course on.  Was using $ENV{'user.home'} for the
  course home server.
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.263 loncom/lonnet/perl/lonnet.pm:1.264
--- loncom/lonnet/perl/lonnet.pm:1.263	Thu Aug  8 09:42:01 2002
+++ loncom/lonnet/perl/lonnet.pm	Thu Aug  8 16:33:50 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.263 2002/08/08 13:42:01 www Exp $
+# $Id: lonnet.pm,v 1.264 2002/08/08 20:33:50 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1602,6 +1602,13 @@
             return 'F';
         }
     }
+    # Domain coordinator is trying to create a course
+    if (($priv eq 'ccc') && ($ENV{'request.role'} =~ /^dc\./)) {
+        # uri is the requested domain in this case.
+        # comparison to 'request.role.domain' shows if the user has selected
+        # a role of dc for the domain in question. 
+        return 'F' if ($uri eq $ENV{'request.role.domain'});
+    }
 
     my $thisallowed='';
     my $statecond=0;
@@ -2188,13 +2195,10 @@
 # ---------------------------------------------------------- Make/modify course
 
 sub createcourse {
-    my ($udom,$description,$url)=@_;
+    my ($udom,$description,$url,$course_server)=@_;
     $url=&declutter($url);
     my $cid='';
-    unless (&allowed('ccc',$ENV{'user.domain'})) {
-        return 'refused';
-    }
-    unless ($udom eq $ENV{'user.domain'}) {
+    unless (&allowed('ccc',$udom)) {
         return 'refused';
     }
 # ------------------------------------------------------------------- Create ID
@@ -2210,9 +2214,14 @@
            return 'error: unable to generate unique course-ID';
        } 
    }
+# ------------------------------------------------ Check supplied server name
+    $course_server = $ENV{'user.homeserver'} if (! defined($course_server));
+    if (! exists($libserv{$course_server})) {
+        return 'error:bad server name '.$course_server;
+    }
 # ------------------------------------------------------------- Make the course
     my $reply=&reply('encrypt:makeuser:'.$udom.':'.$uname.':none::',
-                      $ENV{'user.home'});
+                      $course_server);
     unless ($reply eq 'ok') { return 'error: '.$reply; }
     $uhome=&homeserver($uname,$udom,'true');
     if (($uhome eq '') || ($uhome eq 'no_host')) {