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

foxr lon-capa-cvs@mail.lon-capa.org
Wed, 26 Jan 2005 12:13:59 -0000


foxr		Wed Jan 26 07:13:59 2005 EDT

  Modified files:              
    /loncom	lchtmldir lcuseradd lond 
  Log:
  Fix some safing issues with the pid for httpd that prevented the
  kill -USR1 from being sent to the right pid.
  
  Ensure that lond invokes lchtmldir for authors that switch both in and
  out of filesystem auth mode.
  
  
  
  
Index: loncom/lchtmldir
diff -u loncom/lchtmldir:1.14 loncom/lchtmldir:1.15
--- loncom/lchtmldir:1.14	Wed Jan 26 05:38:13 2005
+++ loncom/lchtmldir	Wed Jan 26 07:13:58 2005
@@ -221,6 +221,7 @@
 # Based on the authentiation mode, set the ownership of the directory.
 
 if($authentication eq "unix:") {	# Unix mode authentication...
+    print "Unix auth\n";
     &System("/bin/chown -R   $safeuser:$safeuser"." ".$fulldir);
     &JoinGroup($safeuser);
 } else {
@@ -300,7 +301,10 @@
 	print("Disable root: id = ".$>."\n");
     }
 }
-
+#
+#  Join the www user to the user's group.
+#  we must be running with euid as root at this time.
+#
 sub JoinGroup {
     my $usergroup = shift;
 
@@ -319,7 +323,16 @@
 	}
 	exit 6;
     }
-    
+    if (-e '/var/run/httpd.pid') {
+	open(PID,'/var/run/httpd.pid');
+	my $pid=<PID>;
+	close(PID);
+	my ($safepid) = $pid=~ /(\d+)/;
+	$pid = $safepid;
+	if ($pid) {
+	    my $status = system("kill -USR1 $safepid");
+	}
+    }
 }
 
 
Index: loncom/lcuseradd
diff -u loncom/lcuseradd:1.33 loncom/lcuseradd:1.34
--- loncom/lcuseradd:1.33	Wed Jan 26 05:38:13 2005
+++ loncom/lcuseradd	Wed Jan 26 07:13:58 2005
@@ -6,7 +6,7 @@
 #             with adding a user with filesystem privileges (e.g. author)
 #
 #
-# $Id: lcuseradd,v 1.33 2005/01/26 10:38:13 foxr Exp $
+# $Id: lcuseradd,v 1.34 2005/01/26 12:13:58 foxr Exp $
 ###
 
 ###############################################################################
@@ -219,7 +219,7 @@
 #    user, however that disallows authentication changes from i
 #    internal->fs.. so just check the passwd file instead.
 #
-my $not_found = system("grep -q $safeusername: /etc/passwd");
+my $not_found = system("cut -d: -f1 /etc/passwd | grep -q \"^$safeusername\$\" ");
 if (!$not_found) {
     print "Error user already exists\n" unless $noprint;
     unlink('/tmp/lock_lcpasswd');
@@ -318,7 +318,7 @@
 #
 #   In order to allow the loncapa daemons appropriate access
 #   to public_html, Top level and public_html directories should
-#   be owned by safeusername:www as should the smaple index.html..
+#   be owned by safeusername:safeusername as should the smaple index.html..
 print "lcuseradd ownership\n" unless $noprint;
 system('/bin/chown','-R',"$safeusername:$safeusername","/home/$safeusername"); # First set std ownership on everything.
 #  system('/bin/chown',"$safeusername:www","/home/$safeusername");	# Now adust top level...
@@ -329,7 +329,7 @@
     open(PID,'/var/run/httpd.pid');
     my $pid=<PID>;
     close(PID);
-    my ($safepid)=($pid=~s/(\D+)//g);
+    my ($safepid)= $pid=~ /(\D+)/;
     if ($pid) {
 	system('kill','-USR1',"$safepid");
     }
Index: loncom/lond
diff -u loncom/lond:1.275 loncom/lond:1.276
--- loncom/lond:1.275	Mon Jan 17 17:13:36 2005
+++ loncom/lond	Wed Jan 26 07:13:58 2005
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # lond "LON Daemon" Server (port "LOND" 5663)
 #
-# $Id: lond,v 1.275 2005/01/17 22:13:36 albertel Exp $
+# $Id: lond,v 1.276 2005/01/26 12:13:58 foxr Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -58,7 +58,7 @@
 my $status='';
 my $lastlog='';
 
-my $VERSION='$Revision: 1.275 $'; #' stupid emacs
+my $VERSION='$Revision: 1.276 $'; #' stupid emacs
 my $remoteVERSION;
 my $currenthostid="default";
 my $currentdomainid;
@@ -1799,10 +1799,11 @@
 	    #  to take ownership of the construction space back to www:www
 	    #
 
-	    if( ($oldauth =~ /^unix/) && ($umode eq "internal")) { # unix -> internal
+	    if( (($oldauth =~ /^unix/) && ($umode eq "internal")) ||
+		(($oldauth =~ /^internal/) && ($umode eq "unix")) ) { 
 		if(&is_author($udom, $uname)) {
 		    &Debug(" Need to manage author permissions...");
-		    &manage_permissions("/$udom/_au", $udom, $uname, "internal:");
+		    &manage_permissions("/$udom/_au", $udom, $uname, "$umode:");
 		}
 	    }