Diff for /loncom/Attic/lcuseradd between versions 1.15 and 1.19

version 1.15, 2001/10/23 03:42:30 version 1.19, 2002/02/14 22:09:14
Line 1 Line 1
 #!/usr/bin/perl  #!/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  # YEAR=2000
 # SH: October 27, 2000  # 10/27,10/29,10/30 Scott Harrison
 # SH: October 29, 2000  
 # YEAR=2001  # YEAR=2001
 # Scott Harrison 10/21  # 10/21,11/13,11/15 Scott Harrison
   #
   # $Id$
   ###
   
 ###############################################################################  ###############################################################################
 ##                                                                           ##  ##                                                                           ##
Line 103  use strict; Line 108  use strict;
 # Security  # Security
 $ENV{'PATH'}='/bin/:/usr/bin:/usr/local/sbin:/home/httpd/perl'; # Nullify path  $ENV{'PATH'}='/bin/:/usr/bin:/usr/local/sbin:/home/httpd/perl'; # Nullify path
                                                                 # information                                                                  # information
 $ENV{'BASH_ENV'}=""; # Nullify shell environment information.  delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # nullify potential taints
   
 # Do not print error messages.  # Do not print error messages.
 my $noprint=1;  my $noprint=1;
Line 146  else { Line 151  else {
  unlink('/tmp/lock_lcpasswd');   unlink('/tmp/lock_lcpasswd');
  exit 3;   exit 3;
     }      }
     map {chomp} @input;      foreach (@input) {chomp;}
 }  }
   
 my ($username,$password1,$password2)=@input;  my ($username,$password1,$password2)=@input;
Line 159  if (($username ne $safeusername) or ($sa Line 164  if (($username ne $safeusername) or ($sa
     exit 9;      exit 9;
 }  }
 my $pbad=0;  my $pbad=0;
 map {if ((ord($_)<32)||(ord($_)>126)){$pbad=1;}} (split(//,$password1));  foreach (split(//,$password1)) {if ((ord($_)<32)||(ord($_)>126)){$pbad=1;}}
 map {if ((ord($_)<32)||(ord($_)>126)){$pbad=1;}} (split(//,$password2));  foreach (split(//,$password2)) {if ((ord($_)<32)||(ord($_)>126)){$pbad=1;}}
 if ($pbad) {  if ($pbad) {
     print "Error. A password entry had an invalid character.\n";      print "Error. A password entry had an invalid character.\n";
     unlink('/tmp/lock_lcpasswd');      unlink('/tmp/lock_lcpasswd');
Line 194  if (system('/usr/sbin/useradd','-c','LON Line 199  if (system('/usr/sbin/useradd','-c','LON
 }  }
   
 # Make www a member of that user group.  # 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 ".      print "Error. Could not make www a member of the group ".
   "\"$safeusername\".\n" unless $noprint;    "\"$safeusername\".\n" unless $noprint;
     unlink('/tmp/lock_lcpasswd');      unlink('/tmp/lock_lcpasswd');
Line 206  if (system('/usr/sbin/usermod','-G',$saf Line 216  if (system('/usr/sbin/usermod','-G',$saf
   
 unlink('/tmp/lock_lcpasswd');  unlink('/tmp/lock_lcpasswd');
 &disable_root_capability;  &disable_root_capability;
 ($>,$<)=(500,500);  ($>,$<)=($wwwid,$wwwid);
 open OUT,"|lcpasswd";  open OUT,"|/home/httpd/perl/lcpasswd";
 print OUT $safeusername;  print OUT $safeusername;
 print OUT "\n";  print OUT "\n";
 print OUT $password1;  print OUT $password1;
Line 215  print OUT "\n"; Line 225  print OUT "\n";
 print OUT $password1;  print OUT $password1;
 print OUT "\n";  print OUT "\n";
 close OUT;  close OUT;
 ($>,$<)=(500,0);  
 if ($?) {  if ($?) {
     exit 8;      exit 8;
 }  }
   ($>,$<)=($wwwid,0);
 &enable_root_capability;  &enable_root_capability;
   
 # ------------------------------ Make final modifications to the user directory  # ------------------------------ Make final modifications to the user directory
Line 226  if ($?) { Line 236  if ($?) {
   
 # system('/bin/chmod','-R','0660',"/home/$safeusername");  # system('/bin/chmod','-R','0660',"/home/$safeusername");
 system('/bin/chmod','0710',"/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";  open OUT,">/home/$safeusername/public_html/index.html";
 print OUT<<END;  print OUT<<END;
 <html>  <html>
Line 245  This area provides for: Line 256  This area provides for:
 <li>resource construction</li>  <li>resource construction</li>
 <li>resource publication</li>  <li>resource publication</li>
 <li>record-keeping</li>  <li>record-keeping</li>
 </UL>  </ul>
 </BODY>  </body>
 </HTML>  </html>
 END  END
 close OUT;  close OUT;
 system('/bin/chown','-R',"$safeusername:$safeusername","/home/$safeusername");  system('/bin/chown','-R',"$safeusername:$safeusername","/home/$safeusername");
Line 316  sub try_to_lock { Line 327  sub try_to_lock {
     close LOCK;      close LOCK;
     return 1;      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

Removed from v.1.15  
changed lines
  Added in v.1.19


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>