Roxen.git / server / modules / filesystems / filesystem.pike

version» Context lines:

Roxen.git/server/modules/filesystems/filesystem.pike:1:   // This is a roxen module. Copyright © 1996 - 1998, Idonex AB.      // This is a virtual "file-system".   // It will be located somewhere in the name-space of the server.   // Also inherited by some of the other filesystems.      inherit "module";   inherit "roxenlib";   inherit "socket";    - constant cvs_version= "$Id: filesystem.pike,v 1.46 1998/08/26 11:31:03 grubba Exp $"; + constant cvs_version= "$Id: filesystem.pike,v 1.47 1999/02/01 03:31:54 peter Exp $";   constant thread_safe=1;         #include <module.h>   #include <roxen.h>   #include <stat.h>      #if DEBUG_LEVEL > 20   # ifndef FILESYSTEM_DEBUG   # define FILESYSTEM_DEBUG
Roxen.git/server/modules/filesystems/filesystem.pike:347:    * FIXME: The proper way to do this would probably be to set path info    * here, and have the redirect be done by the extension modules,    * or by the protocol module if there isn't any extension module.    * /grubba 1998-08-26    */    return 0;    /* Do not try redirect on top level directory */    if(sizeof(id->not_query) < 2)    return 0;    redirects++; -  TRACE_LEAVE("Redirecting to \"" + -  id->not_query[..sizeof(id->not_query)-2] + -  "\""); -  return http_redirect(id->not_query[..sizeof(id->not_query)-2], id); +  +  // Note: Keep the query part. +  /* FIXME: Should probably keep prestates etc too. +  * /grubba 1999-01-14 +  */ +  string new_query = +  http_encode_string(id->not_query[..sizeof(id->not_query)-2]) + +  (id->query?("?" + id->query):""); +  TRACE_LEAVE("Redirecting to \"" + new_query + "\""); +  return http_redirect(new_query, id);    }       if(!id->misc->internal_get && QUERY(.files)    && (tmp = (id->not_query/"/")[-1])    && tmp[0] == '.') {    TRACE_LEAVE("Is .-file");    return 0;    }   #ifndef THREADS    object privs;
Roxen.git/server/modules/filesystems/filesystem.pike:667:    {    id->misc->error_code = 403;    TRACE_LEAVE("MV: Move failed");    TRACE_LEAVE("Failure");    return 0;    }    TRACE_LEAVE("MV: Success");    TRACE_LEAVE("Success");    return http_string_answer("Ok");    +  case "MOVE": +  // This little kluge is used by NETSCAPE 4.5 +  +  if(!QUERY(put)) +  { +  id->misc->error_code = 405; +  TRACE_LEAVE("MOVE disallowed (since PUT is disallowed)"); +  return 0; +  } +  if(size != -1) +  { +  id->misc->error_code = 404; +  TRACE_LEAVE("MOVE failed (no such file)"); +  return 0; +  } +  +  if(QUERY(check_auth) && (!id->auth || !id->auth[0])) { +  TRACE_LEAVE("MOVE: Permission denied"); +  return http_auth_required("foo", +  "<h1>Permission to 'MOVE' files denied</h1>"); +  } +  +  if(!sizeof(id->misc["new-uri"] || "")) { +  id->misc->error_code = 405; +  errors++; +  TRACE_LEAVE("MOVE: No dest file"); +  return 0; +  } +  string mountpoint = QUERY(mountpoint); +  string moveto = combine_path(mountpoint + "/" + oldf + "/..", +  id->misc["new-uri"]); +  +  if (moveto[..sizeof(mountpoint)-1] != mountpoint) { +  id->misc->error_code = 405; +  TRACE_LEAVE("MOVE: Dest file on other filesystem."); +  return(0); +  } +  moveto = path + moveto[sizeof(mountpoint)..]; +  +  size = FILE_SIZE(moveto); +  +  if(!QUERY(delete) && size != -1) +  { +  id->misc->error_code = 405; +  TRACE_LEAVE("MOVE disallowed (DELE disabled, can't overwrite file)"); +  return 0; +  } +  +  if(size < -1) +  { +  id->misc->error_code = 405; +  TRACE_LEAVE("MOVE: Cannot overwrite directory"); +  return 0; +  } +  +  object privs; +  + // #ifndef THREADS // Ouch. This is is _needed_. Well well... +  if (((int)id->misc->uid) && ((int)id->misc->gid)) { +  // NB: Root-access is prevented. +  privs=Privs("Moving file", (int)id->misc->uid, (int)id->misc->gid ); +  } + // #endif +  +  if (QUERY(no_symlinks) && +  ((contains_symlinks(path, f)) || +  (contains_symlinks(path, moveto)))) { +  privs = 0; +  errors++; +  TRACE_LEAVE("MOVE: Contains symlinks. Permission denied"); +  return http_low_answer(403, "<h2>Permission denied.</h2>"); +  } +  +  TRACE_ENTER("MOVE: Accepted", 0); +  +  moves++; +  +  /* Clear the stat-cache for this file */ + #ifdef __NT__ +  // if(movefrom[-1] == '/') +  // movefrom = move_from[..strlen(movefrom)-2]; + #endif +  if (stat_cache) { +  cache_set("stat_cache", moveto, 0); +  cache_set("stat_cache", f, 0); +  } + #ifdef DEBUG +  report_notice("Moving file " + f + " to " + moveto + "\n"); + #endif /* DEBUG */ +  +  int code = mv(f, moveto); +  privs = 0; +  +  if(!code) +  { +  id->misc->error_code = 403; +  TRACE_LEAVE("MOVE: Move failed"); +  TRACE_LEAVE("Failure"); +  return 0; +  } +  TRACE_LEAVE("MOVE: Success"); +  TRACE_LEAVE("Success"); +  return http_string_answer("Ok"); +  +     case "DELETE":    if(!QUERY(delete) || size==-1)    {    id->misc->error_code = 405;    TRACE_LEAVE("DELETE: Disabled");    return 0;    }    if(QUERY(check_auth) && (!id->auth || !id->auth[0])) {    TRACE_LEAVE("DELETE: Permission denied");    return http_low_answer(403, "<h1>Permission to DELETE file denied</h1>");