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

version» Context lines:

Roxen.git/server/modules/filesystems/filesystem.pike:686:       Stat stat = file_stat(real_fname);    SIMPLE_TRACE_ENTER(this, "Deleting %s %O.",    stat?(stat->isdir?"directory":"file"):"missing",    real_fname);    if (!stat) {    id->set_status_for_path(virt_fname, 404);    TRACE_LEAVE("File not found.");    continue;    } +  if (stat->isdir) { +  virt_fname += "/"; +  }    int(0..1)|mapping sub_status; -  if (check_status_needed && -  mappingp(sub_status = write_access(virt_fname, 1, id))) { +  if (mappingp(sub_status = write_access(virt_fname, 1, id))) {    id->set_status_for_path(virt_fname, sub_status->error);    TRACE_LEAVE("Write access denied.");    continue;    }    if (stat->isdir) {    recursive_rm(real_fname, virt_fname, sub_status, id);    }       /* Clear the stat-cache for this file */    if (stat_cache) {
Roxen.git/server/modules/filesystems/filesystem.pike:718:    TRACE_LEAVE("Deletion failed.");    }   #if constant(System.EEXIST)    else {    TRACE_LEAVE("Directory not empty.");    }   #endif    } else {    deletes++;    +  unlock_path(virt_fname, id); +     if (id->misc->quota_obj && stat->isreg()) {    id->misc->quota_obj->deallocate(virt_fname,    stat->size());    }    TRACE_LEAVE("Ok.");    }    }    TRACE_LEAVE("Done.");   }   
Roxen.git/server/modules/filesystems/filesystem.pike:898:    id->method));    if (id->method == "MKCOL") {    return Roxen.http_status(405,    "Collection already exists.");    }    return 0;    }       // Disallow if the name is locked, or if the parent directory is locked.    mapping(string:mixed) ret = -  write_access(({coll, combine_path(coll, "..")}), 0, id); +  write_access(({coll + "/", combine_path(coll, "../")}), 0, id);    if (ret) return ret;       mkdirs++;    object privs;    SETUID_TRACE("Creating directory/collection", 0);       if (query("no_symlinks") && (contains_symlinks(path, coll))) {    privs = 0;    errors++;    report_error(LOCALE(46,"Creation of %O failed. Permission denied.\n"),
Roxen.git/server/modules/filesystems/filesystem.pike:1107:    if (size != -1) {    TRACE_LEAVE(sprintf("%s failed. Directory name already exists. ",    id->method));    if (id->method == "MKCOL") {    return Roxen.http_status(405,    "Collection already exists.");    }    return 0;    }    -  if (mapping(string:mixed) ret = write_access(f, 0, id)) { +  if (mapping(string:mixed) ret = write_access(f + "/", 0, id)) {    TRACE_LEAVE("MKCOL: Write access denied.");    return ret;    }       mkdirs++;    SETUID_TRACE("Creating directory/collection", 0);       if (query("no_symlinks") && (contains_symlinks(path, f))) {    privs = 0;    errors++;    report_error(LOCALE(46,"Creation of %O failed. Permission denied.\n"),    f);    TRACE_LEAVE(sprintf("%s: Contains symlinks. Permission denied",    id->method));    return Roxen.http_status(403, "Permission denied.");    }    -  +  TRACE_ENTER(sprintf("%s: Accepted", id->method), 0); +     code = mkdir(f);    int err_code = errno();    -  TRACE_ENTER(sprintf("%s: Accepted", id->method), 0); -  +     if (code) {    string msg = safe_chmod(f, 0777 & ~(id->misc->umask || 022));    privs = 0;    if (msg) {    TRACE_LEAVE(sprintf("%s: chmod %O failed: %s", id->method, f, msg));    } else {    TRACE_LEAVE(sprintf("%s: Success", id->method));    }    TRACE_LEAVE("Success");    if (id->method == "MKCOL") {    return Roxen.http_status(201, "Created");    }    return Roxen.http_string_answer("Ok");    } else {    privs = 0; -  SIMPLE_TRACE_LEAVE("%s: Failed (errcode:%d)", id->method, errcode); +  SIMPLE_TRACE_LEAVE("%s: Failed (err: %d: %s)", +  id->method, err_code, strerror(err_code));    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 Roxen.http_status(409, "Missing intermediate.");    } else {    return Roxen.http_status(507, "Failed.");    }    }    return 0;
Roxen.git/server/modules/filesystems/filesystem.pike:1488:    if (query("no_symlinks") &&    ((contains_symlinks(path, norm_f)) ||    (contains_symlinks(path, moveto)))) {    privs = 0;    errors++;    TRACE_LEAVE("MOVE: Contains symlinks. Permission denied");    return Roxen.http_status(403, "Permission denied.");    }       // 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); +  mapping(string:mixed) ret = write_access(({ f, new_uri }), 1, id);    if (ret) {    TRACE_LEAVE("MOVE: Locked");    return ret;    } -  +  ret = write_access(combine_path(f, "../"), 0, id); +  if (ret) { +  TRACE_LEAVE("MOVE: Parent directory 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);   
Roxen.git/server/modules/filesystems/filesystem.pike:1653:    return errno_to_status (errno(), 0, id);    }    } else {    return errno_to_status (errno(), 0, id);    }       if (id->multi_status_size() > start_ms_size) {    TRACE_LEAVE("DELETE: Partial failure.");    return ([]);    } +  } else { +  unlock_path(f, id);    }    } else {    mapping|int(0..1) res =    write_access(({ combine_path(f, "../"), f }), 0, id);    if (res) {    SIMPLE_TRACE_LEAVE("DELETE: Write access denied.");    return res;    }      #if 0
Roxen.git/server/modules/filesystems/filesystem.pike:1685:    if(!rm(norm_f))    {    privs = 0;    id->misc->error_code = 405;    TRACE_LEAVE("DELETE: Failed");    return 0;    }    privs = 0;    deletes++;    +  unlock_path(f, id); +     if (id->misc->quota_obj && (size > 0)) {    id->misc->quota_obj->deallocate(URI, size);    }    }    TRACE_LEAVE("DELETE: Success");    return Roxen.http_status(204,(norm_f+" DELETED from the server"));       default:    id->misc->error_code = 501;    SIMPLE_TRACE_LEAVE("%s: Not supported", id->method);
Roxen.git/server/modules/filesystems/filesystem.pike:1770:    TRACE_LEAVE("");    return errno_to_status (errno(), 0, id);    }       if (id->multi_status_size() > start_ms_size) {    privs = 0;    TRACE_LEAVE("COPY: Partial failure in destination directory delete.");    TRACE_LEAVE("");    return ([]);    } +  } else { +  unlock_path(dest, id);    }    SIMPLE_TRACE_LEAVE("COPY: Delete ok.");    } else if (source_st->isdir) {    if (!rm(dest_path)) {    privs = 0;    if (errno() != System.ENOENT)    {    mapping(string:mixed) status = errno_to_status (errno(), 0, id);    if (!status) status = (["error": id->misc->error_code]);    id->set_status_for_path(mountpoint + dest,    status->error, status->rettext);    TRACE_LEAVE("");    return ([]);    }    SIMPLE_TRACE_LEAVE("COPY: File deletion failed (destination disappeared).");    } else {    SIMPLE_TRACE_LEAVE("COPY: File deletion ok."); -  +  +  unlock_path(dest, id);    }    } else {    SIMPLE_TRACE_LEAVE("COPY: No need to perform deletion.");    }    privs = 0;    break;    case MAYBE_OVERWRITE:    if ((source_st->isreg != dest_st->isreg) ||    (source_st->isdir != dest_st->isdir)) {    TRACE_LEAVE("COPY: Resource types for source and destination differ.");