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

foxr lon-capa-cvs@mail.lon-capa.org
Mon, 18 Oct 2004 10:43:39 -0000


foxr		Mon Oct 18 06:43:39 2004 EDT

  Modified files:              
    /loncom	lcuseradd 
  Log:
  Defect 550: Allow users to be created if their home dir already exists, as 
             long as they don't already appear in the /etc/passwd file.
             This is necessary for users to be able to change auth mode
             from internal -> filesystem if they are authors.
  
  
  
Index: loncom/lcuseradd
diff -u loncom/lcuseradd:1.30 loncom/lcuseradd:1.31
--- loncom/lcuseradd:1.30	Thu Sep  2 15:04:00 2004
+++ loncom/lcuseradd	Mon Oct 18 06:43:39 2004
@@ -6,7 +6,7 @@
 #             with adding a user with filesystem privileges (e.g. author)
 #
 #
-# $Id: lcuseradd,v 1.30 2004/09/02 19:04:00 albertel Exp $
+# $Id: lcuseradd,v 1.31 2004/10/18 10:43:39 foxr Exp $
 ###
 
 ###############################################################################
@@ -214,13 +214,20 @@
 }
 
 
-# -- Only add user if we can create a brand new home directory (/home/username)
-if (-e "/home/$safeusername") {
-    print "Error. User already exists.\n" unless $noprint;
+# -- Only add the user if they are >not< in /etc/passwd.
+#    Used to look for the ability to create a new directory for the
+#    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");
+if (!$not_found) {
+    print "Error user already exists\n" unless $noprint;
     unlink('/tmp/lock_lcpasswd');
     &Exit(11);
 }
 
+
+
 # -- Only add user if the two password arguments match.
 
 if ($password1 ne $password2) {