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

version» Context lines:

Roxen.git/server/modules/filesystems/filesystem.pike:764:    if (rr[1] == -3) {    return(1);    }    } else {    return(0);    }    }    return(0);   }    + //! Return @expr{1@} if both arguments refer to the same inode. + int is_same_inode(Stdio.Stat a_st, Stdio.Stat b_st) + { +  if (a_st == b_st) return 1; +  if ((a_st->mode == b_st->mode) && +  (a_st->size == b_st->size) && +  (a_st->ino == b_st->ino) && +  (a_st->dev == b_st->dev)) { +  return 1; +  } +  return 0; + } +    //! @[chmod()] that doesn't throw errors.   string safe_chmod(string path, int mask)   {    return describe_error(catch {    chmod(path, mask);    return 0;    });   }      mapping make_collection(string coll, RequestID id)
Roxen.git/server/modules/filesystems/filesystem.pike:1484:    TRACE_LEAVE("");    TRACE_LEAVE("MOVE disallowed (DELE disabled)");    return 0;    }    TRACE_LEAVE("Overwrite allowed.");    if (overwrite || (size > -1)) {    Stdio.Stat src_st = stat_file(f, id);    Stdio.Stat dst_st = stat_file(new_uri, id);    // Check that src and dst refers to different inodes.    // Needed on case insensitive filesystems. -  if (src_st->mode != dst_st->mode || -  src_st->size != dst_st->size || -  src_st->ino != dst_st->ino || -  src_st->dev != dst_st->dev) { +  if (!is_same_inode(src_st, dst_st)) {    TRACE_ENTER(sprintf("Deleting destination: %O...\n", new_uri), 0);    mapping(string:mixed) res = recurse_delete_files(new_uri, id);    if (res && (!sizeof (res) || res->error >= 300)) {    privs = 0;    TRACE_LEAVE("");    TRACE_LEAVE("MOVE: Recursive delete failed.");    if (sizeof (res))    set_status_for_path (new_uri, res->error, res->rettext);    return ([]);    }
Roxen.git/server/modules/filesystems/filesystem.pike:1693:    if (query("no_symlinks") && (contains_symlinks(path, dest))) {    errors++;    report_error(LOCALE(57,"Copy to %O failed. Permission denied.\n"),    dest);    TRACE_LEAVE("COPY: Contains symlinks. Permission denied");    return Roxen.http_status(403, "Permission denied.");    }    Stat dest_st = stat_file(dest, id);    if (dest_st) {    SIMPLE_TRACE_ENTER (this, "COPY: Destination exists"); +  if (is_same_inode(source_st, dest_st)) { +  TRACE_LEAVE("Source and destination are the same inode."); +  TRACE_LEAVE(""); +  return Roxen.http_status(403, "Permission denied."); +  }    switch(overwrite) {    case NEVER_OVERWRITE:    TRACE_LEAVE("");    TRACE_LEAVE("");    return Roxen.http_status(412, "Destination already exists.");    case DO_OVERWRITE:    if (!query("delete")) {    TRACE_LEAVE("COPY: Deletion not allowed.");    TRACE_LEAVE("");    return Roxen.http_status(405, "Not allowed.");