[LON-CAPA-cvs] cvs: loncom / lcuseradd lond

foxr lon-capa-cvs@mail.lon-capa.org
Sat, 27 Apr 2002 13:10:47 -0000


foxr		Sat Apr 27 09:10:47 2002 EDT

  Modified files:              
    /loncom	lcuseradd lond 
  Log:
  Hid all the
  if($DEBUG) {
     &logthis(text)
  }
  Behind a sub Debug... should have done this a >long< time ago.
  
  
  
Index: loncom/lcuseradd
diff -u loncom/lcuseradd:1.19 loncom/lcuseradd:1.20
--- loncom/lcuseradd:1.19	Thu Feb 14 17:09:14 2002
+++ loncom/lcuseradd	Sat Apr 27 09:10:47 2002
@@ -9,8 +9,16 @@
 # 10/27,10/29,10/30 Scott Harrison
 # YEAR=2001
 # 10/21,11/13,11/15 Scott Harrison
+# YEAR=2002
+#   May 19, 2002 Ron Fox
+#      - Removed creation of the pulic_html directory.  This directory
+#        can now be added in two ways:
+#        o The user can add it themselves if they want some local web
+#          space which may or may not contain construction items.
+#        o LonCapa will add it if/when the user is granted an Author
+#          role.
 #
-# $Id: lcuseradd,v 1.19 2002/02/14 22:09:14 harris41 Exp $
+# $Id: lcuseradd,v 1.20 2002/04/27 13:10:47 foxr Exp $
 ###
 
 ###############################################################################
@@ -40,8 +48,7 @@
 # ------------------------------------------------------- Description of script
 #
 # This script is a setuid script that should
-# be run by user 'www'.  It creates a /home/USERNAME directory
-# as well as a /home/USERNAME/public_html directory.
+# be run by user 'www'.  It creates a /home/USERNAME directory.
 # It adds a user to the unix system.
 # Passwords are set with lcpasswd.
 # www becomes a member of this user group.
@@ -231,36 +238,40 @@
 ($>,$<)=($wwwid,0);
 &enable_root_capability;
 
+# -- Don't add public_html... that can be added either by the user
+#    or by lchtmldir when the user is granted an authorship role.
+
 # ------------------------------ Make final modifications to the user directory
 # -- Add a public_html file with a stand-in index.html file
 
 # system('/bin/chmod','-R','0660',"/home/$safeusername");
-system('/bin/chmod','0710',"/home/$safeusername");
-mkdir "/home/$safeusername/public_html",0755;
-system('/bin/chmod','02770',"/home/$safeusername/public_html");
-open OUT,">/home/$safeusername/public_html/index.html";
-print OUT<<END;
-<html>
-<head>
-<title>$safeusername</title>
-</head>
-<body>
-<h1>$safeusername</h1>
-<p>
-Learning Online Network
-</p>
-<p>
-This area provides for:
-</p>
-<ul>
-<li>resource construction</li>
-<li>resource publication</li>
-<li>record-keeping</li>
-</ul>
-</body>
-</html>
-END
-close OUT;
+#system('/bin/chmod','0710',"/home/$safeusername");
+#mkdir "/home/$safeusername/public_html",0755;
+#system('/bin/chmod','02770',"/home/$safeusername/public_html");
+#open OUT,">/home/$safeusername/public_html/index.html";
+#print OUT<<END;
+#<html>
+#<head>
+#<title>$safeusername</title>
+#</head>
+#<body>
+#<h1>$safeusername</h1>
+#<p>
+#Learning Online Network
+#</p>
+#<p>
+#This area provides for:
+#</p>
+#<ul>
+#<li>resource construction</li>
+#<li>resource publication</li>
+#<li>record-keeping</li>
+#</ul>
+#</body>
+#</html>
+#END
+#close OUT;
+
 system('/bin/chown','-R',"$safeusername:$safeusername","/home/$safeusername");
 
 # -------------------------------------------------------- Exit script
Index: loncom/lond
diff -u loncom/lond:1.76 loncom/lond:1.77
--- loncom/lond:1.76	Wed Mar 27 23:27:42 2002
+++ loncom/lond	Sat Apr 27 09:10:47 2002
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # lond "LON Daemon" Server (port "LOND" 5663)
 #
-# $Id: lond,v 1.76 2002/03/28 04:27:42 foxr Exp $
+# $Id: lond,v 1.77 2002/04/27 13:10:47 foxr Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -73,6 +73,8 @@
 use lib '/home/httpd/lib/perl/';
 use localauth;
 
+my $DEBUG = 0;		       # Non zero to enable debug log entries.
+
 my $status='';
 my $lastlog='';
 
@@ -235,6 +237,13 @@
     print $fh "$local ($$): $message\n";
 }
 
+# ------------------------- Conditional log if $DEBUG true.
+sub Debug {
+    my $message = shift;
+    if($DEBUG) {
+	&logthis($message);
+    }
+}
 # ------------------------------------------------------------------ Log status
 
 sub logstatus {
@@ -737,14 +746,19 @@
 		     }
 # -------------------------------------------------------------------- makeuser
                    } elsif ($userinput =~ /^makeuser/) {
+		     Debug("Make user received");
     	             my $oldumask=umask(0077);
 		     if ($wasenc==1) {
                        my 
                        ($cmd,$udom,$uname,$umode,$npass)=split(/:/,$userinput);
+		       &Debug("cmd =".$cmd." $udom =".$udom.
+				    " uname=".$uname);
                        chomp($npass);
                        $npass=&unescape($npass);
                        my $proname=propath($udom,$uname);
                        my $passfilename="$proname/passwd";
+		       &Debug("Password file created will be:".
+				    $passfilename);
                        if (-e $passfilename) {
 			   print $client "already_exists\n";
                        } elsif ($udom ne $perlvar{'lonDefDomain'}) {
@@ -773,7 +787,8 @@
                                $salt=substr($salt,6,2);
 			       my $ncpass=crypt($npass,$salt);
                                { 
-                                 my $pf = IO::File->new(">$passfilename");
+				 &Debug("Creating internal auth");
+				 my $pf = IO::File->new(">$passfilename");
  	  		         print $pf "internal:$ncpass\n"; 
                                }
                                print $client "ok\n";
@@ -788,6 +803,8 @@
 				 my $execpath="$perlvar{'lonDaemons'}/".
 				              "lcuseradd";
 				 {
+				     &Debug("Executing external: ".
+						  $execpath);
 				     my $se = IO::File->new("|$execpath");
 				     print $se "$uname\n";
 				     print $se "$npass\n";
@@ -816,10 +833,13 @@
 		     umask($oldumask);
 # -------------------------------------------------------------- changeuserauth
                    } elsif ($userinput =~ /^changeuserauth/) {
-		     if ($wasenc==1) {
+		       &Debug("Changing authorization");
+		      if ($wasenc==1) {
                        my 
                        ($cmd,$udom,$uname,$umode,$npass)=split(/:/,$userinput);
                        chomp($npass);
+		       &Debug("cmd = ".$cmd." domain= ".$udom.
+			      "uname =".$uname." umode= ".$umode);
                        $npass=&unescape($npass);
                        my $proname=propath($udom,$uname);
                        my $passfilename="$proname/passwd";
@@ -1028,9 +1048,13 @@
                       }
 # -------------------------------------------------------------------- rolesput
                    } elsif ($userinput =~ /^rolesput/) {
+		       &Debug("rolesput");
 		    if ($wasenc==1) {
                        my ($cmd,$exedom,$exeuser,$udom,$uname,$what)
                           =split(/:/,$userinput);
+		       &Debug("cmd = ".$cmd." exedom= ".$exedom.
+				    "user = ".$exeuser." udom=".$udom.
+				    "what = ".$what);
                        my $namespace='roles';
                        chomp($what);
                        my $proname=propath($udom,$uname);