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.127 2004/05/05 21:24:38 mast Exp $"; + constant cvs_version= "$Id: filesystem.pike,v 1.128 2004/05/06 13:34:37 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:339:    return 0;   }      string real_file( string f, RequestID id )   {    if(stat_file( f, id )) {    return real_path(f, id);    }   }    + // We support locking if put is enabled. + mapping(string:mixed) lock_file(string path, DAVLock lock, RequestID id) + { +  if (!query("put")) return 0; +  if(query("check_auth") && (!id->conf->authenticate( id ) ) ) { +  TRACE_LEAVE("PUT: Permission denied"); +  return +  Roxen.http_auth_required("foo", +  "<h1>Permission to 'PUT' files denied</h1>"); +  } +  register_lock(path, lock, id); +  return 0; + } +    int dir_filter_function(string f, RequestID id)   {    if(f[0]=='.' && !dotfiles) return 0;    if(!tilde && Roxen.backup_extension(f)) return 0;    return 1;   }      array(string) list_lock_files() {    return query("nobrowse");   }
Roxen.git/server/modules/filesystems/filesystem.pike:613:    }    return 0;    }       if(query("check_auth") && (!id->conf->authenticate( id ) ) ) {    TRACE_LEAVE(sprintf("%s: Permission denied", id->method));    return Roxen.http_auth_required("foo",    sprintf("<h1>Permission to '%s' denied</h1>",    id->method));    } +  +  // Disallow if the name is locked, or if the parent directory is locked. +  mapping(string:mixed) ret = write_access(coll, 0, id) || +  write_access(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 %s failed. Permission denied.\n"),    coll);    TRACE_LEAVE(sprintf("%s: Contains symlinks. Permission denied",
Roxen.git/server/modules/filesystems/filesystem.pike:913:    TRACE_LEAVE("PUT of internal file is disallowed");    return 0;    }       if(query("check_auth") && (!id->conf->authenticate( id ) ) ) {    TRACE_LEAVE("PUT: Permission denied");    return Roxen.http_auth_required("foo",    "<h1>Permission to 'PUT' files denied</h1>");    }    +  if (mapping(string:mixed) ret = write_access(f, 0, id)) { +  TRACE_LEAVE("PUT: Locked"); +  return ret; +  } +     puts++;       QUOTA_WERR("Checking quota.\n");    if (id->misc->quota_obj && (id->misc->len > 0) &&    !id->misc->quota_obj->check_quota(URI, id->misc->len)) {    errors++;    report_warning(LOCALE(47,"Creation of %s failed. Out of quota.\n"),f);    TRACE_LEAVE("PUT: Out of quota.");    return http_low_answer(413, "<h2>Out of disk quota.</h2>",    "413 Out of disk quota");
Roxen.git/server/modules/filesystems/filesystem.pike:1029:    TRACE_LEAVE("CHMOD of internal file is disallowed");    return 0;    }       if(query("check_auth") && (!id->conf->authenticate( id ) ) ) {    TRACE_LEAVE("CHMOD: Permission denied");    return Roxen.http_auth_required("foo",    "<h1>Permission to 'CHMOD' files denied</h1>");    }    +  if (mapping(string:mixed) ret = write_access(f, 0, id)) { +  TRACE_LEAVE("PUT: Locked"); +  return ret; +  }       SETUID_TRACE("CHMODing file", 0);       if (query("no_symlinks") && (contains_symlinks(path, oldf))) {    privs = 0;    errors++;    TRACE_LEAVE("CHMOD: Contains symlinks. Permission denied");    return http_low_answer(403, "<h2>Permission denied.</h2>");    }   
Roxen.git/server/modules/filesystems/filesystem.pike:1107:    return 0;    }       if (FILTER_INTERNAL_FILE (movefrom, id) ||    FILTER_INTERNAL_FILE (f, id)) {    id->misc->error_code = 405;    TRACE_LEAVE("MV to or from internal file is disallowed");    return 0;    }    +  // FIXME: What about moving of directories containing locked files? +  if (mapping(string:mixed) ret = write_access(f, 0, id) || +  write_access(id->misc->move_from, 0, id)) { +  TRACE_LEAVE("MV: Locked"); +  return ret; +  } +     SETUID_TRACE("Moving file", 0);       if (query("no_symlinks") &&    ((contains_symlinks(path, oldf)) ||    (contains_symlinks(path, id->misc->move_from)))) {    privs = 0;    errors++;    TRACE_LEAVE("MV: Contains symlinks. Permission denied");    return http_low_answer(403, "<h2>Permission denied.</h2>");    }
Roxen.git/server/modules/filesystems/filesystem.pike:1143:    id->misc->error_code = 403;    TRACE_LEAVE("MV: Move failed");    TRACE_LEAVE("Failure");    return 0;    }    TRACE_LEAVE("MV: Success");    TRACE_LEAVE("Success");    return Roxen.http_string_answer("Ok");       case "MOVE": -  // This little kluge is used by NETSCAPE 4.5 +  // This little kluge is used by NETSCAPE 4.5 and RFC 2518.       // FIXME: Support for quota.       if(!query("put"))    {    id->misc->error_code = 405;    TRACE_LEAVE("MOVE disallowed (since PUT is disallowed)");    return 0;    }    if(size == -1)
Roxen.git/server/modules/filesystems/filesystem.pike:1224:    return 0;    }       if(size < -1)    {    id->misc->error_code = 405;    TRACE_LEAVE("MOVE: Cannot overwrite directory");    return 0;    }    +  if (mapping(string:mixed) ret = +  write_access(moveto, 0, id) || +  write_access(f, 0, id)) { +  TRACE_LEAVE("MOVE: Locked"); +  return ret; +  } +     SETUID_TRACE("Moving file", 0);       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>");    }