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