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

version» Context lines:

Roxen.git/server/modules/filesystems/filesystem.pike:1074:    // RFC 2518 8.3.1:    // If a server receives a MKCOL request entity type it does not support    // or understand it MUST respond with a 415 (Unsupported Media Type)    // status code.    SIMPLE_TRACE_LEAVE ("MKCOL failed since the request has content.");    return Roxen.http_status(415, "Unsupported media type.");    }    /* FALL_THROUGH */    case "MKDIR":   #if 1 -  return make_collection(f, id); +  mixed ret = make_collection(f, id); +  if (ret) return ret; +  if (id->misc->error_code) { +  return Roxen.http_status(id->misc->error_code); +  } +  return 0;   #else /* !1 */    if(!query("put"))    {    id->misc->error_code = 405;    TRACE_LEAVE(sprintf("%s disallowed (since PUT is disallowed)",    id->method));    return 0;    }       if (FILTER_INTERNAL_FILE (f, id)) {
Roxen.git/server/modules/filesystems/filesystem.pike:1210:    if (query("no_symlinks") && (contains_symlinks(path, f))) {    errors++;    report_error(LOCALE(46,"Creation of %O failed. Permission denied.\n"),f);    TRACE_LEAVE("PUT: Contains symlinks. Permission denied");    return Roxen.http_status(403, "Permission denied.");    }       SETUID_TRACE("Saving file", 0);       rm(norm_f); -  mkdirhier(norm_f); +  // mkdirhier(norm_f);       if (id->misc->quota_obj) {    QUOTA_WERR("Checking if the file already existed.");    if (size > 0) {    QUOTA_WERR("Deallocating " + size + "bytes.");    id->misc->quota_obj->deallocate(URI, size);    }    }       object to = Stdio.File();
Roxen.git/server/modules/filesystems/filesystem.pike:1234:    /* Clear the stat-cache for this file */    if (stat_cache) {    cache_set("stat_cache", norm_f, 0);    }       if(!to->open(norm_f, "wct", 0666))    {    int err = to->errno();    privs = 0;    TRACE_LEAVE("PUT: Open failed"); -  return errno_to_status (err, 1, id); +  mixed ret = errno_to_status (err, 1, id); +  if (ret) return ret; +  if (id->misc->error_code) { +  return Roxen.http_status(id->misc->error_code);    } -  +  return 0; +  }       // FIXME: Race-condition.    string msg = safe_chmod(norm_f, 0666 & ~(id->misc->umask || 022));    privs = 0;       Stdio.File my_fd = id->connection();       putting[my_fd] = id->misc->len;    if(strlen(id->data))    {
Roxen.git/server/modules/filesystems/filesystem.pike:1453:    return 0;    }       // FIXME: The code below doesn't allow for this module being overloaded.    if (!has_prefix(new_uri, mountpoint)) {    id->misc->error_code = 405;    TRACE_LEAVE("MOVE: Dest file on other filesystem.");    return(0);    }    new_uri = new_uri[sizeof(mountpoint)..]; -  string moveto = path + "/" + encode_path(new_uri); +  string moveto = real_path(new_uri, id);       // Workaround for Linux, Tru64 and FreeBSD.    if (has_suffix(moveto, "/")) {    moveto = moveto[..sizeof(moveto)-2];    }       if (FILTER_INTERNAL_FILE (f, id) ||    FILTER_INTERNAL_FILE (new_uri, id)) {    id->misc->error_code = 405;    TRACE_LEAVE("MOVE to or from internal file is disallowed");
Roxen.git/server/modules/filesystems/filesystem.pike:1484:    }       // NB: Consider the case of moving of directories containing locked files.    mapping(string:mixed) ret =    write_access(({ combine_path(f, "../"), f, new_uri }), 1, id);    if (ret) {    TRACE_LEAVE("MOVE: Locked");    return ret;    }    +  if (norm_f == moveto) { +  privs = 0; +  errors++; +  TRACE_LEAVE("MOVE: Source and destination are the same path."); +  return Roxen.http_status(403, "Permission denied."); +  } +     size = _file_size(new_uri, id);       SETUID_TRACE("Moving file", 0);       if (size != -1) {    // Destination exists.       TRACE_ENTER(sprintf("Destination exists: %d\n", size), 0);    int(0..1) overwrite =    !id->request_headers->overwrite ||
Roxen.git/server/modules/filesystems/filesystem.pike:1549:       /* Clear the stat-cache for this file */    if (stat_cache) {    cache_set("stat_cache", new_uri, 0);    cache_set("stat_cache", f, 0);    }       if(!code)    {    SIMPLE_TRACE_LEAVE("MOVE: Move failed (%s)", strerror (err_code)); -  return errno_to_status (err_code, 1, id); +  mixed ret = errno_to_status (err_code, 1, id); +  if (ret) return ret; +  if (id->misc->error_code) { +  return Roxen.http_status(id->misc->error_code);    } -  +  return 0; +  }    TRACE_LEAVE("MOVE: Success");    TRACE_LEAVE("Success");    if (size != -1) return Roxen.http_status(204);    return Roxen.http_status(201);    }       case "DELETE":    if (size==-1) {    id->misc->error_code = 404;    TRACE_LEAVE("DELETE: Not found");