Diff for /loncom/lond between versions 1.225 and 1.226

version 1.225, 2004/08/09 10:34:18 version 1.226, 2004/08/10 11:30:24
Line 162  sub ResetStatistics { Line 162  sub ResetStatistics {
     $Failures     = 0;      $Failures     = 0;
 }  }
   
   
   
 #------------------------------------------------------------------------  #------------------------------------------------------------------------
 #  #
 #   LocalConnection  #   LocalConnection
Line 372  sub isClient { Line 370  sub isClient {
 #                     - This allows dynamic changes to the manager table  #                     - This allows dynamic changes to the manager table
 #                       without the need to signal to the lond.  #                       without the need to signal to the lond.
 #  #
   
 sub ReadManagerTable {  sub ReadManagerTable {
   
     #   Clean out the old table first..      #   Clean out the old table first..
Line 1743  sub update_resource_handler { Line 1740  sub update_resource_handler {
 &register_handler("update", \&update_resource_handler, 0 ,1, 0);  &register_handler("update", \&update_resource_handler, 0 ,1, 0);
   
 #  #
 #   Fetch a user file from a remote server:  #   Fetch a user file from a remote server to the user's home directory
   #   userfiles subdir.
 # Parameters:  # Parameters:
 #    $cmd      - The command that got us here.  #    $cmd      - The command that got us here.
 #    $tail     - Tail of the command (remaining parameters).  #    $tail     - Tail of the command (remaining parameters).
Line 1798  sub fetch_user_file_handler { Line 1796  sub fetch_user_file_handler {
 }  }
 &register_handler("fetchuserfile", \&fetch_user_file_handler, 0, 1, 0);  &register_handler("fetchuserfile", \&fetch_user_file_handler, 0, 1, 0);
   
   #
   #   Remove a file from a user's home directory userfiles subdirectory.
   # Parameters:
   #    cmd   - the Lond request keyword that got us here.
   #    tail  - the part of the command past the keyword.
   #    client- File descriptor connected with the client.
   #
   # Returns:
   #    1    - Continue processing.
   
   sub remove_user_file_handler {
       my ($cmd, $tail, $client) = @_;
   
       my ($fname) = split(/:/, $tail); # Get rid of any tailing :'s lonc may have sent.
   
       my ($udom,$uname,$ufile) = ($fname =~ m|^([^/]+)/([^/]+)/(.+)$|);
       &logthis("$udom - $uname - $ufile");
       if ($ufile =~m|/\.\./|) {
    # any files paths with /../ in them refuse 
    # to deal with
    &Failure($client, "refused\n", "$cmd:$tail");
       } else {
    my $udir = &propath($udom,$uname);
    if (-e $udir) {
       my $file=$udir.'/userfiles/'.$ufile;
       if (-e $file) {
    unlink($file);
    if (-e $file) {
       &Failure($client, "failed\n", "$cmd:$tail");
    } else {
       &Reply($client, "ok\n", "$cmd:$tail");
    }
       } else {
    &Failure($client, "not_found\n", "$cmd:$tail");
       }
    } else {
       &Failure($client, "not_home\n", "$cmd:$tail");
    }
       }
       return 1;
   }
   &register_handler("removeuserfile", \&remove_user_file_handler, 0,1,0);
   
 #---------------------------------------------------------------  #---------------------------------------------------------------
 #  #
 #   Getting, decoding and dispatching requests:  #   Getting, decoding and dispatching requests:
Line 1808  sub fetch_user_file_handler { Line 1849  sub fetch_user_file_handler {
 #   Gets a Request message from the client.  The transaction  #   Gets a Request message from the client.  The transaction
 #   is defined as a 'line' of text.  We remove the new line  #   is defined as a 'line' of text.  We remove the new line
 #   from the text line.    #   from the text line.  
 #     #
 sub get_request {  sub get_request {
     my $input = <$client>;      my $input = <$client>;
     chomp($input);      chomp($input);
 j  
     Debug("get_request: Request = $input\n");      Debug("get_request: Request = $input\n");
   
     &status('Processing '.$clientname.':'.$input);      &status('Processing '.$clientname.':'.$input);
Line 1912  sub process_request { Line 1953  sub process_request {
 #------------------- Commands not yet in spearate handlers. --------------  #------------------- Commands not yet in spearate handlers. --------------
   
   
 # --------------------------------------------------------- remove a user file   
    if ($userinput =~ /^removeuserfile/) { # Client clear or enc.  
  if(isClient) {  
     my ($cmd,$fname)=split(/:/,$userinput);  
     my ($udom,$uname,$ufile) = ($fname =~ m|^([^/]+)/([^/]+)/(.+)$|);  
     &logthis("$udom - $uname - $ufile");  
     if ($ufile =~m|/\.\./|) {  
  # any files paths with /../ in them refuse   
  # to deal with  
  print $client "refused\n";  
     } else {  
  my $udir=propath($udom,$uname);  
  if (-e $udir) {  
     my $file=$udir.'/userfiles/'.$ufile;  
     if (-e $file) {  
  unlink($file);  
  if (-e $file) {  
     print $client "failed\n";  
  } else {  
     print $client "ok\n";  
  }  
     } else {  
  print $client "not_found\n";  
     }  
  } else {  
     print $client "not_home\n";  
  }  
     }  
  } else {  
     Reply($client, "refused\n", $userinput);  
  }  
 # ------------------------------------------ authenticate access to a user file  # ------------------------------------------ authenticate access to a user file
     } elsif ($userinput =~ /^tokenauthuserfile/) { # Client only  
       if ($userinput =~ /^tokenauthuserfile/) { # Client only
  if(isClient) {   if(isClient) {
     my ($cmd,$fname,$session)=split(/:/,$userinput);      my ($cmd,$fname,$session)=split(/:/,$userinput);
     chomp($session);      chomp($session);
Line 3104  sub register_handler { Line 3116  sub register_handler {
         
     $Dispatcher{$request_name} = \@entry;      $Dispatcher{$request_name} = \@entry;
         
      
 }  }
   
   
Line 3151  sub catchexception { Line 3162  sub catchexception {
     $server->close();      $server->close();
     die($error);      die($error);
 }  }
   
 sub timeout {  sub timeout {
     &status("Handling Timeout");      &status("Handling Timeout");
     &logthis("<font color='red'>CRITICAL: TIME OUT ".$$."</font>");      &logthis("<font color='red'>CRITICAL: TIME OUT ".$$."</font>");
Line 3159  sub timeout { Line 3169  sub timeout {
 }  }
 # -------------------------------- Set signal handlers to record abnormal exits  # -------------------------------- Set signal handlers to record abnormal exits
   
   
 $SIG{'QUIT'}=\&catchexception;  $SIG{'QUIT'}=\&catchexception;
 $SIG{__DIE__}=\&catchexception;  $SIG{__DIE__}=\&catchexception;
   

Removed from v.1.225  
changed lines
  Added in v.1.226


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