[LON-CAPA-dev] lcscripts patch
Martin Siegert
lon-capa-dev@mail.lon-capa.org
Thu, 7 Apr 2005 15:00:21 -0700
--pf9I7BMVVzbSWLtt
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Hi,
here is a tiny contribution towards getting LON-CAPA to work on a SuSE
system: I modified the lc* perl scripts in loncapa-1.3.2/loncom
so that they work on SuSE as well. This is necessary because "useradd"
under SuSE does not create a primary group for each user. The modifications
should not have no effect when the scripts are run on a RH like system.
Cheers,
Martin
--pf9I7BMVVzbSWLtt
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="loncapa-1.3.2-lcscripts.patch"
--- loncapa-1.3.2/loncom/lchtmldir.orig 2005-03-26 12:43:04.216983659 -0800
+++ loncapa-1.3.2/loncom/lchtmldir 2005-03-29 09:39:24.038656229 -0800
@@ -144,7 +144,7 @@
if($DEBUG) {
print("Save username = $safeuser \n");
}
-if(($username ne $safeuser) or ($safeuser!~/^[A-za-z]/)) {
+if(($username ne $safeuser) or ($safeuser!~/^[A-z]/)) {
if($DEBUG) {
print("User name $username had illegal characters\n");
}
@@ -185,6 +185,17 @@
exit 6;
}
}
+if ($authentication eq "unix:") {
+ # check whether group $safeuser exists.
+ my $usergroups = `id -nG $safeuser`;
+ if (! grep /^$safeuser$/, split(/\s+/,$usergroups)) {
+ if($DEBUG) {
+ print("Group \"$safeuser\" does not exist or $safeuser is not a member of that group.\n");
+ }
+ exit 7;
+ }
+}
+
&EnableRoot;
&System("/bin/mkdir -p $fulldir") unless (-e $fulldir);
--- loncapa-1.3.2/loncom/lcpasswd.orig 2005-03-26 12:08:14.278942939 -0800
+++ loncapa-1.3.2/loncom/lcpasswd 2005-03-26 12:19:49.730559660 -0800
@@ -159,9 +159,9 @@
print OUT $password1;
print OUT "\n";
close OUT;
-($>,$<)=(0,500);
+($>,$<)=(0,$wwwid);
-print "pwchange done, back to uid 500" unless $noprint;
+print "pwchange done, back to uid $wwwid" unless $noprint;
if ($?) {
exit 8;
@@ -173,7 +173,7 @@
($>,$<)=(0,0); # fool smbpasswd here to think this is not a setuid
# environment
-# If the -a swithc is put on the smbpasswd
+# If the -a switch is put on the smbpasswd
# command line, either a new entry will be created or the old one
# will be used.
# Therefore the old strategy of looking for and adding a dummy entry is
--- loncapa-1.3.2/loncom/lcuseradd.orig 2005-03-23 18:40:58.761266509 -0800
+++ loncapa-1.3.2/loncom/lcuseradd 2005-03-23 19:20:29.829750960 -0800
@@ -251,6 +251,33 @@
unlink('/tmp/lock_lcpasswd');
&Exit(12);
}
+my ($dmy1, $dmy2, $uid, $gid) = getpwnam $safeusername;
+my $group = `awk -F: '{if (\$3 == '$gid') print \$1}' /etc/group`;
+chomp($group);
+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);
--pf9I7BMVVzbSWLtt--