--- loncom/Attic/lcuseradd 2005/01/27 11:52:46 1.35 +++ loncom/Attic/lcuseradd 2005/04/07 22:27:52 1.36 @@ -6,7 +6,7 @@ # with adding a user with filesystem privileges (e.g. author) # # -# $Id: lcuseradd,v 1.35 2005/01/27 11:52:46 foxr Exp $ +# $Id: lcuseradd,v 1.36 2005/04/07 22:27:52 albertel Exp $ ### ############################################################################### @@ -253,6 +253,32 @@ if ($status) { unlink('/tmp/lock_lcpasswd'); &Exit(12); } +my ($dmy1, $dmy2, $uid, $gid) = getpwnam($safeusername); +my ($group) = getgrgid($gid); +if (! $group) { + print "Error. The primary group of user \"$safeusername\" could not be". + "determined.\n" unless $noprint; + system("/usr/sbin/userdel -r $safeusername"); + unlink('/tmp/lock_lcpasswd'); + &Exit(12); +} +if ($group != $safeusername) { + $status = system("/usr/sbin/groupadd -g $uid $safeusername"); + if (! $status) { + $status = system("/usr/sbin/usermod -g $uid $safeusername"); + if ($status) { + system("/usr/sbin/groupdel $safeusername"); + } + } + if ($status) { + print "Error. Something went wrong with the addition of user ". + "\"$safeusername\".\n" unless $noprint; + system("/usr/sbin/userdel -r $safeusername"); + unlink('/tmp/lock_lcpasswd'); + &Exit(12); + } +} + print "Done adding user\n" unless $noprint; # Make www a member of that user group. my $groups=`/usr/bin/groups www` or &Exit(6);