Diff for /loncom/lond between versions 1.226 and 1.229

version 1.226, 2004/08/10 11:30:24 version 1.229, 2004/08/16 10:54:19
Line 1812  sub remove_user_file_handler { Line 1812  sub remove_user_file_handler {
     my ($fname) = split(/:/, $tail); # Get rid of any tailing :'s lonc may have sent.      my ($fname) = split(/:/, $tail); # Get rid of any tailing :'s lonc may have sent.
   
     my ($udom,$uname,$ufile) = ($fname =~ m|^([^/]+)/([^/]+)/(.+)$|);      my ($udom,$uname,$ufile) = ($fname =~ m|^([^/]+)/([^/]+)/(.+)$|);
     &logthis("$udom - $uname - $ufile");  
     if ($ufile =~m|/\.\./|) {      if ($ufile =~m|/\.\./|) {
  # any files paths with /../ in them refuse    # any files paths with /../ in them refuse 
  # to deal with   # to deal with
Line 1839  sub remove_user_file_handler { Line 1838  sub remove_user_file_handler {
 }  }
 &register_handler("removeuserfile", \&remove_user_file_handler, 0,1,0);  &register_handler("removeuserfile", \&remove_user_file_handler, 0,1,0);
   
   
   #
   #  Authenticate access to a user file by checking the user's 
   #  session token(?)
   #
   # Parameters:
   #   cmd      - The request keyword that dispatched to tus.
   #   tail     - The tail of the request (colon separated parameters).
   #   client   - Filehandle open on the client.
   # Return:
   #    1.
   
   sub token_auth_user_file_handler {
       my ($cmd, $tail, $client) = @_;
   
       my ($fname, $session) = split(/:/, $tail);
       
       chomp($session);
       my $reply='non_auth';
       if (open(ENVIN,$perlvar{'lonIDsDir'}.'/'.
        $session.'.id')) {
    while (my $line=<ENVIN>) {
       if ($line=~ m|userfile\.\Q$fname\E\=|) { $reply='ok'; }
    }
    close(ENVIN);
    &Reply($client, $reply);
       } else {
    &Failure($client, "invalid_token\n", "$cmd:$tail");
       }
       return 1;
   
   }
   
   &register_handler("tokenauthuserfile", \&token_auth_user_file_handler, 0,1,0);
   
   
   #
   #   Unsubscribe from a resource.
   #
   # Parameters:
   #    $cmd      - The command that got us here.
   #    $tail     - Tail of the command (remaining parameters).
   #    $client   - File descriptor connected to client.
   # Returns
   #     0        - Requested to exit, caller should shut down.
   #     1        - Continue processing.
   #
   sub unsubscribe_handler {
       my ($cmd, $tail, $client) = @_;
   
       my $userinput= "$cmd:$tail";
       
       my ($fname) = split(/:/,$tail); # Split in case there's extrs.
   
       &Debug("Unsubscribing $fname");
       if (-e $fname) {
    &Debug("Exists");
    &Reply($client, &unsub($fname,$clientip), $userinput);
       } else {
    &Failure($client, "not_found\n", $userinput);
       }
       return 1;
   }
   &register_handler("unsub", \&unsubscribe_handler, 0, 1, 0);
   
 #---------------------------------------------------------------  #---------------------------------------------------------------
 #  #
 #   Getting, decoding and dispatching requests:  #   Getting, decoding and dispatching requests:
Line 1954  sub process_request { Line 2018  sub process_request {
   
   
   
 # ------------------------------------------ authenticate access to a user file  
   
     if ($userinput =~ /^tokenauthuserfile/) { # Client only  
  if(isClient) {  
     my ($cmd,$fname,$session)=split(/:/,$userinput);  
     chomp($session);  
     my $reply='non_auth';  
     if (open(ENVIN,$perlvar{'lonIDsDir'}.'/'.  
      $session.'.id')) {  
  while (my $line=<ENVIN>) {  
     if ($line=~ m|userfile\.\Q$fname\E\=|) { $reply='ok'; }  
     }  
  close(ENVIN);  
  print $client $reply."\n";  
     } else {  
  print $client "invalid_token\n";  
     }  
  } else {  
     Reply($client, "refused\n", $userinput);  
       
  }  
 # ----------------------------------------------------------------- unsubscribe  
     } elsif ($userinput =~ /^unsub/) {  
  if(isClient) {  
     my ($cmd,$fname)=split(/:/,$userinput);  
     if (-e $fname) {  
  print $client &unsub($fname,$clientip);  
     } else {  
  print $client "not_found\n";  
     }  
  } else {  
     Reply($client, "refused\n", $userinput);  
       
  }  
 # ------------------------------------------------------------------- subscribe  # ------------------------------------------------------------------- subscribe
     } elsif ($userinput =~ /^sub/) {     if ($userinput =~ /^sub/) {
  if(isClient) {   if(isClient) {
     print $client &subscribe($userinput,$clientip);      print $client &subscribe($userinput,$clientip);
  } else {   } else {

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


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