Diff for /loncom/lcinstallfile between versions 1.2 and 1.3

version 1.2, 2009/02/24 11:52:03 version 1.3, 2009/03/03 12:08:07
Line 62  use File::Copy; Line 62  use File::Copy;
 # 6    - Some file operation failed.  # 6    - Some file operation failed.
 # 7    - Invalid table filename.  # 7    - Invalid table filename.
 #  #
 my $noprint = 0;  my $noprint = 1;
 #  #
 #   Ensure we are www:  #   Ensure we are www:
 #  #
 #   # 
   print ("In lcinstallfile\n") unless $noprint;
   
 my $wwwid=getpwnam('www');  my $wwwid=getpwnam('www');
 &disable_root_capability;  &disable_root_capability;
Line 80  if ($wwwid!=$>) { Line 81  if ($wwwid!=$>) {
 #  #
 my $argc = scalar(@ARGV);  my $argc = scalar(@ARGV);
 if ($argc != 2) {  if ($argc != 2) {
     print("Usage: lcinstallfile sourcepath destfile\n") unless $noprint;      print("Usage: lcinstallfile sourcepath destfile had $argc parameters\n") unless $noprint;
     exit 2;      exit 2;
 }  }
 my $sourcepath = $ARGV[0];  my $sourcepath = $ARGV[0];
 my $destfile  = $ARGV[1];  my $destfile  = $ARGV[1];
   
   print("From: $sourcepath to: $destfile\n") unless $noprint;
   
   
 # Ensure the source file exists, and root can write it.:  # Ensure the source file exists, and root can write it.:
Line 96  my $destfile  = $ARGV[1]; Line 98  my $destfile  = $ARGV[1];
 # loncapa table files are all of the form.  # loncapa table files are all of the form.
 #  something.tab where something is all letters and _'s.  #  something.tab where something is all letters and _'s.
 #  #
 if ($sourcepath =~ /^(\w+\.tab)$/) {  if ($sourcepath =~ /^([\w\/]+\.\w+)$/) {
     $sourcepath = $1;      $sourcepath = $1;
 } else {  } else {
     print ("Invalid characters in filename $sourcepath \n") unless $noprint;      print ("Invalid characters in filename '$sourcepath' \n") unless $noprint;
     exit 7;      exit 7;
 }  }
   
Line 117  if (! -r $sourcepath) { Line 119  if (! -r $sourcepath) {
 #  We're not allowed to create new files, only replace existing files  #  We're not allowed to create new files, only replace existing files
 #  so ensure that the final destination file actually exists.  #  so ensure that the final destination file actually exists.
 #  #
 my $config_vars = LONCAPA::Configuration::read_conf('loncapa.conf');  
 my %config      = %{$config_vars};  
 my $tab_dir     = $config{'lonTabDir'};  
   
 my $final_file  = $tab_dir.'/'.$destfile;  
   
 #  #
 # Now sanitize the final file:  # Now sanitize the final file:
   
 if ($final_file =~ /^([\w\/]+\.tab)$/) {  my $final_file;
   if ($destfile =~ /^([\w\/]+\.\w+)$/) {
     $final_file = $1;      $final_file = $1;
 } else {  } else {
     print ("$final_file failed regexp match\n") unless $noprint;      print ("'$final_file' failed regexp match\n") unless $noprint;
     exit 7;      exit 7;
 }  }
   
Line 186  sub enable_root_capability { Line 185  sub enable_root_capability {
     else {      else {
  # root capability is already enabled   # root capability is already enabled
     }      }
       print ("Effective uid = $>\n");
     return $>;      return $>;
 }  }
   

Removed from v.1.2  
changed lines
  Added in v.1.3


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