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 - 2001, Roxen IS.      // 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 "socket";    - constant cvs_version= "$Id: filesystem.pike,v 1.122 2003/06/26 15:59:22 anders Exp $"; + constant cvs_version= "$Id: filesystem.pike,v 1.123 2003/12/23 12:14:24 grubba Exp $";   constant thread_safe=1;      #include <module.h>   #include <roxen.h>   #include <stat.h>   #include <request_trace.h>         //<locale-token project="mod_filesystem">LOCALE</locale-token>   #define LOCALE(X,Y) _DEF_LOCALE("mod_filesystem",X,Y)
Roxen.git/server/modules/filesystems/filesystem.pike:387:    TRACE_ENTER(sprintf("Deleting file %O.", real_fname),    this_object());    if (!stat) {    if (!result) {    result = MultiStatus()->prefix(query_location());    }    result->add_response(relative_fname, XMLStatusNode(404));    TRACE_LEAVE("File not found.");    continue;    } -  if (stat->isdir()) { +  if (stat->isdir) {    result = recursive_rm(real_fname, relative_fname, id, result);    }       /* Clear the stat-cache for this file */    if (stat_cache) {    cache_set("stat_cache", real_fname, 0);    }       if (!rm(real_fname)) {   #if constant(System.EEXIST)
Roxen.git/server/modules/filesystems/filesystem.pike:429:    }    TRACE_LEAVE("Ok.");    }    }    TRACE_LEAVE("Done.");    return result;   }      mapping putting = ([]);    - void done_with_put( array(object|string) id_arr ) + void done_with_put( array(object|string|int) id_arr )   {   // werror("Done with put.\n");    object to;    object from;    object id;    string oldf; -  +  int size;    -  [to, from, id, oldf] = id_arr; +  [to, from, id, oldf, size] = id_arr;       FILESYSTEM_WERR(sprintf("done_with_put(%O)\n"    "from: %O\n",    id_arr, mkmapping(indices(from), values(from))));       to->close();    from->set_blocking();    m_delete(putting, from);       if (putting[from] && (putting[from] != 0x7fffffff)) {    // Truncated!    id->send_result(http_low_answer(400,    "<h2>Bad Request - "    "Expected more data.</h2>"));    } else { -  id->send_result(http_low_answer(200, "<h2>Transfer Complete.</h2>")); +  id->send_result(http_low_answer((size < 0)?201:200, +  "<h2>Transfer Complete.</h2>"));    }   }    - void got_put_data( array (object|string) id_arr, string data ) + void got_put_data( array(object|string|int) id_arr, string data )   {   // werror(strlen(data)+" .. ");       object to;    object from;    object id;    string oldf; -  +  int size;    -  [to, from, id, oldf] = id_arr; +  [to, from, id, oldf, size] = id_arr;       // Truncate at end.    data = data[..putting[from]];       if (id->misc->quota_obj &&    !id->misc->quota_obj->check_quota(oldf, sizeof(data))) {    to->close();    from->set_blocking();    m_delete(putting, from);    id->send_result(http_low_answer(413, "<h2>Out of disk quota.</h2>",
Roxen.git/server/modules/filesystems/filesystem.pike:755:    privs = 0;    errors++;    report_error(LOCALE(46,"Creation of %s failed. Permission denied.\n"),    oldf);    TRACE_LEAVE(sprintf("%s: Contains symlinks. Permission denied",    id->method));    return http_low_answer(403, "<h2>Permission denied.</h2>");    }       int code = mkdir(f); +  int err_code = errno();    privs = 0;       TRACE_ENTER(sprintf("%s: Accepted", id->method), 0);       if (code) {    chmod(f, 0777 & ~(id->misc->umask || 022));    TRACE_LEAVE(sprintf("%s: Success", id->method));    TRACE_LEAVE("Success");    if (id->method == "MKCOL") {    return http_low_answer(201, "Created");    }    return Roxen.http_string_answer("Ok");    } else {    TRACE_LEAVE(sprintf("%s: Failed", id->method));    TRACE_LEAVE("Failure");    if (id->method == "MKCOL") { -  +  if (err_code == + #if constant(system.ENOENT) +  system.ENOENT + #elif constant(System.ENOENT) +  System.ENOENT + #else +  2 + #endif +  ) { +  return http_low_answer(409, "Missing intermediate."); +  } else {    return http_low_answer(507, "Failed.");    } -  +  }    return 0;    }       break;       case "PUT":    if(!query("put"))    {    id->misc->error_code = 405;    TRACE_LEAVE("PUT disallowed");
Roxen.git/server/modules/filesystems/filesystem.pike:874:    TRACE_LEAVE("PUT: A string");    TRACE_LEAVE("PUT: Out of quota");    return http_low_answer(413, "<h2>Out of disk quota.</h2>",    "413 Out of disk quota");    }    }    }    if(!putting[id->my_fd]) {    TRACE_LEAVE("PUT: Just a string");    TRACE_LEAVE("Put: Success"); +  if (size < 0) { +  return Roxen.http_low_answer(201, "Created."); +  } else {    return Roxen.http_string_answer("Ok");    } -  +  }       if(id->clientprot == "HTTP/1.1") {    id->my_fd->write("HTTP/1.1 100 Continue\r\n");    } -  id->my_fd->set_id( ({ to, id->my_fd, id, URI }) ); +  id->my_fd->set_id( ({ to, id->my_fd, id, URI, size }) );    id->my_fd->set_nonblocking(got_put_data, 0, done_with_put);    TRACE_LEAVE("PUT: Pipe in progress");    TRACE_LEAVE("PUT: Success so far");    return Roxen.http_pipe_in_progress();    break;       case "CHMOD":    // Change permission of a file.    // FIXME: !!   
Roxen.git/server/modules/filesystems/filesystem.pike:1124:    TRACE_LEAVE("MOVE: Move failed");    TRACE_LEAVE("Failure");    return 0;    }    TRACE_LEAVE("MOVE: Success");    TRACE_LEAVE("Success");    return Roxen.http_string_answer("Ok");          case "DELETE": -  if(!query("delete") || size==-1) +  if(!query("delete"))    {    id->misc->error_code = 405;    TRACE_LEAVE("DELETE: Disabled");    return 0;    } -  +  if (size==-1) { +  id->misc->error_code = 404; +  TRACE_LEAVE("DELETE: Not found"); +  return 0; +  }       if (FILTER_INTERNAL_FILE (f, id)) {    id->misc->error_code = 405;    TRACE_LEAVE("DELETE of internal file is disallowed");    return 0;    }       if(query("check_auth") && (!id->conf->authenticate( id ) ) ) {    TRACE_LEAVE("DELETE: Permission denied");    return http_low_answer(403, "<h1>Permission to DELETE file denied</h1>");    }       if (query("no_symlinks") && (contains_symlinks(path, oldf))) {    errors++;    report_error(LOCALE(48,"Deletion of %s failed. Permission denied.\n"),f);    TRACE_LEAVE("DELETE: Contains symlinks");    return http_low_answer(403, "<h2>Permission denied.</h2>");    }       if ((size < 0) && -  !([ "infinity":0x7fffffff, 0:0x7fffffff ]) -  [String.trim_whites(id->request_headers->depth)]) { +  (String.trim_whites(id->request_headers->depth||"infinity") != +  "infinity")) {    // RFC 2518 8.6.2:    // The DELETE method on a collection MUST act as if a "Depth: infinity"    // header was used on it.    TRACE_LEAVE(sprintf("DELETE: Bad depth header: %O.",    id->request_headers->depth));    return http_low_answer(400, "<h2>Unsupported depth.</h2>");    }       if (size < 0) {    report_notice(LOCALE(64,"DELETING the directory %s.\n"), f);