--- loncom/Attic/lcuseradd 2001/10/23 03:42:30 1.15 +++ loncom/Attic/lcuseradd 2001/11/16 06:18:35 1.18 @@ -1,12 +1,17 @@ #!/usr/bin/perl + +# The Learning Online Network with CAPA # -# lcuseradd +# lcuseradd - LON-CAPA setuid script to coordinate all actions +# with adding a user with filesystem privileges (e.g. author) # -# Scott Harrison -# SH: October 27, 2000 -# SH: October 29, 2000 +# YEAR=2000 +# 10/27,10/29,10/30 Scott Harrison # YEAR=2001 -# Scott Harrison 10/21 +# 10/21,11/13,11/15 Scott Harrison +# +# $Id: lcuseradd,v 1.18 2001/11/16 06:18:35 harris41 Exp $ +### ############################################################################### ## ## @@ -103,7 +108,7 @@ use strict; # Security $ENV{'PATH'}='/bin/:/usr/bin:/usr/local/sbin:/home/httpd/perl'; # Nullify path # information -$ENV{'BASH_ENV'}=""; # Nullify shell environment information. +delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # nullify potential taints # Do not print error messages. my $noprint=1; @@ -194,7 +199,12 @@ if (system('/usr/sbin/useradd','-c','LON } # Make www a member of that user group. -if (system('/usr/sbin/usermod','-G',$safeusername,'www')) { +my $groups=`/usr/bin/groups www` or exit(6); +chomp $groups; $groups=~s/^\S+\s+\:\s+//; +my @grouplist=split(/\s+/,$groups); +my @ugrouplist=grep {!/www|$safeusername/} @grouplist; +my $gl=join(',',(@ugrouplist,$safeusername)); +if (system('/usr/sbin/usermod','-G',$gl,'www')) { print "Error. Could not make www a member of the group ". "\"$safeusername\".\n" unless $noprint; unlink('/tmp/lock_lcpasswd'); @@ -206,8 +216,8 @@ if (system('/usr/sbin/usermod','-G',$saf unlink('/tmp/lock_lcpasswd'); &disable_root_capability; -($>,$<)=(500,500); -open OUT,"|lcpasswd"; +($>,$<)=($wwwid,$wwwid); +open OUT,"|/home/httpd/perl/lcpasswd"; print OUT $safeusername; print OUT "\n"; print OUT $password1; @@ -215,10 +225,10 @@ print OUT "\n"; print OUT $password1; print OUT "\n"; close OUT; -($>,$<)=(500,0); if ($?) { exit 8; } +($>,$<)=($wwwid,0); &enable_root_capability; # ------------------------------ Make final modifications to the user directory @@ -226,7 +236,8 @@ if ($?) { # system('/bin/chmod','-R','0660',"/home/$safeusername"); system('/bin/chmod','0710',"/home/$safeusername"); -mkdir "/home/$safeusername/public_html",2760; +mkdir "/home/$safeusername/public_html",0755; +system('/bin/chmod','02770',"/home/$safeusername/public_html"); open OUT,">/home/$safeusername/public_html/index.html"; print OUT< @@ -245,9 +256,9 @@ This area provides for:
  • resource construction
  • resource publication
  • record-keeping
  • - - - + + + END close OUT; system('/bin/chown','-R',"$safeusername:$safeusername","/home/$safeusername"); @@ -316,3 +327,32 @@ sub try_to_lock { close LOCK; return 1; } + +=head1 NAME + +lcuseradd - LON-CAPA setuid script to coordinate all actions + with adding a user with filesystem privileges (e.g. author) + +=head1 DESCRIPTION + +lcuseradd - LON-CAPA setuid script to coordinate all actions + with adding a user with filesystem privileges (e.g. author) + +=head1 README + +lcuseradd - LON-CAPA setuid script to coordinate all actions + with adding a user with filesystem privileges (e.g. author) + +=head1 PREREQUISITES + +=head1 COREQUISITES + +=pod OSNAMES + +linux + +=pod SCRIPT CATEGORIES + +LONCAPA/Administrative + +=cut