[LON-CAPA-cvs] cvs: loncom /publisher loncfile.pm

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 07 Jun 2002 01:35:48 -0000


albertel		Thu Jun  6 21:35:48 2002 EDT

  Modified files:              
    /loncom/publisher	loncfile.pm 
  Log:
  - $fn seems to be set to the full path (/home/$uname/public_html) but was treated as if to was relative to the public_html directory.
  
  - tested for filesystem authenticated, but not internal users
  
  
Index: loncom/publisher/loncfile.pm
diff -u loncom/publisher/loncfile.pm:1.10 loncom/publisher/loncfile.pm:1.11
--- loncom/publisher/loncfile.pm:1.10	Sun May 26 23:18:46 2002
+++ loncom/publisher/loncfile.pm	Thu Jun  6 21:35:48 2002
@@ -10,7 +10,7 @@
 #
 
 #
-# $Id: loncfile.pm,v 1.10 2002/05/27 03:18:46 foxr Exp $
+# $Id: loncfile.pm,v 1.11 2002/06/07 01:35:48 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -139,7 +139,12 @@
     my $main=$2;
     my $suffix=$3;
 
-    my $conspace='/home/'.$uname.'/public_html'.$fn;
+    my $conspace;
+    if ($fn =~ m-^/home/-) {
+        $conspace=$fn;
+    } else {
+        $conspace='/home/'.$uname.'/public_html'.$fn;
+    }
 
     $r->print('<form action=/adm/cfile method=post>'.
 	      '<input type=hidden name=filename value="/~'.$uname.$fn.'">'.
@@ -215,6 +220,7 @@
     my $dir=$1;
     my $main=$2;
     my $suffix=$3;
+    $dir =~ s-^/[^/]*/[^/]*/[^/]*--;
     
     
     &Debug($r, "loncfile::phase2 dir = $dir main = $main suffix = $suffix");
@@ -228,7 +234,7 @@
     if ($ENV{'form.action'} eq 'rename') {
 	if (-e $conspace) {
 	    if ($ENV{'form.newfilename'}) {
-               unless (rename('/home/'.$uname.'/public_html'.$fn,
+               unless (rename($fn,
           '/home/'.$uname.'/public_html'.$dir.'/'.$ENV{'form.newfilename'})) {
 	    $r->print('<font color=red>Error: '.$!.'</font>');
                }
@@ -239,7 +245,7 @@
         }
     } elsif ($ENV{'form.action'} eq 'delete') { 
 	if (-e $conspace) {
-            unless (unlink('/home/'.$uname.'/public_html'.$fn)) {
+            unless (unlink($fn)) {
 	       $r->print('<font color=red>Error: '.$!.'</font>');
             }
         } else {
@@ -249,7 +255,7 @@
     } elsif ($ENV{'form.action'} eq 'copy') { 
 	if (-e $conspace) {
 	    if ($ENV{'form.newfilename'}) {
-               unless (copy('/home/'.$uname.'/public_html'.$fn,
+               unless (copy($fn,
            '/home/'.$uname.'/public_html'.$dir.'/'.$ENV{'form.newfilename'})) {
 	          $r->print('<font color=red>Error: '.$!.'</font>');
                }