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 - 2000, 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 "roxenlib"; +    inherit "socket";    - constant cvs_version= "$Id: filesystem.pike,v 1.79 2000/04/06 01:49:40 wing Exp $"; + constant cvs_version= "$Id: filesystem.pike,v 1.80 2000/05/01 05:42:09 nilsson Exp $";   constant thread_safe=1;      #include <module.h>   #include <roxen.h>   #include <stat.h>   #include <request_trace.h>      #if DEBUG_LEVEL > 20   # ifndef FILESYSTEM_DEBUG   # define FILESYSTEM_DEBUG
Roxen.git/server/modules/filesystems/filesystem.pike:211:   {    if(this->stat_file( f, id ))   /* This filesystem might be inherited by other filesystem, therefore    'this' */    return path + f;   }      int dir_filter_function(string f, RequestID id)   {    if(f[0]=='.' && !QUERY(.files)) return 0; -  if(!QUERY(tilde) && backup_extension(f)) return 0; +  if(!QUERY(tilde) && Roxen.backup_extension(f)) return 0;    return 1;   }      array find_dir( string f, RequestID id )   {    mixed ret;    array dir;       FILESYSTEM_WERR("find_dir for \""+f+"\"");   
Roxen.git/server/modules/filesystems/filesystem.pike:468:    /* Do not try redirect on top level directory */    if(sizeof(id->not_query) < 2)    return 0;    redirects++;       // Note: Keep the query part.    /* FIXME: Should probably keep prestates etc too.    * /grubba 1999-01-14    */    string new_query = -  http_encode_string(id->not_query[..sizeof(id->not_query)-2]) + +  Roxen.http_encode_string(id->not_query[..sizeof(id->not_query)-2]) +    (id->query?("?" + id->query):"");    TRACE_LEAVE("Redirecting to \"" + new_query + "\""); -  return http_redirect(new_query, id); +  return Roxen.http_redirect(new_query, id);    }       if(!id->misc->internal_get) {    if (!QUERY(.files)    && sizeof (tmp = (id->not_query/"/")[-1])    && tmp[0] == '.') {    TRACE_LEAVE("Is .-file");    return 0;    }    if (FILTER_INTERNAL_FILE (f, id)) {
Roxen.git/server/modules/filesystems/filesystem.pike:536:    }       if (FILTER_INTERNAL_FILE (f, id)) {    id->misc->error_code = 405;    TRACE_LEAVE("MKDIR disallowed (since the dir name matches internal file glob)");    return 0;    }       if(QUERY(check_auth) && (!id->auth || !id->auth[0])) {    TRACE_LEAVE("MKDIR: Permission denied"); -  return http_auth_required("foo", +  return Roxen.http_auth_required("foo",    "<h1>Permission to 'MKDIR' denied</h1>");    }    mkdirs++;    object privs;       if (((int)id->misc->uid) && ((int)id->misc->gid)) {    // NB: Root-access is prevented.    privs=Privs("Creating directory",    (int)id->misc->uid, (int)id->misc->gid );    }
Roxen.git/server/modules/filesystems/filesystem.pike:565:       int code = mkdir( decode_path(f) );    privs = 0;       TRACE_ENTER("MKDIR: Accepted", 0);       if (code) {    chmod(f, 0777 & ~(id->misc->umask || 022));    TRACE_LEAVE("MKDIR: Success");    TRACE_LEAVE("Success"); -  return http_string_answer("Ok"); +  return Roxen.http_string_answer("Ok");    } else {    TRACE_LEAVE("MKDIR: Failed");    TRACE_LEAVE("Failure");    return 0;    }       break;       case "PUT":    if(!QUERY(put))
Roxen.git/server/modules/filesystems/filesystem.pike:590:    }       if (FILTER_INTERNAL_FILE (f, id)) {    id->misc->error_code = 405;    TRACE_LEAVE("PUT of internal file is disallowed");    return 0;    }       if(QUERY(check_auth) && (!id->auth || !id->auth[0])) {    TRACE_LEAVE("PUT: Permission denied"); -  return http_auth_required("foo", +  return Roxen.http_auth_required("foo",    "<h1>Permission to 'PUT' files denied</h1>");    }       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("Creation of " + f + " failed. Out of quota.\n");
Roxen.git/server/modules/filesystems/filesystem.pike:678:    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"); -  return http_string_answer("Ok"); +  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_nonblocking(got_put_data, 0, done_with_put);    TRACE_LEAVE("PUT: Pipe in progress");    TRACE_LEAVE("PUT: Success so far"); -  return http_pipe_in_progress(); +  return Roxen.http_pipe_in_progress();    break;       case "CHMOD":    // Change permission of a file.    // FIXME: !!       if(!QUERY(put))    {    id->misc->error_code = 405;    TRACE_LEAVE("CHMOD disallowed (since PUT is disallowed)");
Roxen.git/server/modules/filesystems/filesystem.pike:710:    }       if (FILTER_INTERNAL_FILE (f, id)) {    id->misc->error_code = 405;    TRACE_LEAVE("CHMOD of internal file is disallowed");    return 0;    }       if(QUERY(check_auth) && (!id->auth || !id->auth[0])) {    TRACE_LEAVE("CHMOD: Permission denied"); -  return http_auth_required("foo", +  return Roxen.http_auth_required("foo",    "<h1>Permission to 'CHMOD' files denied</h1>");    }       object privs;       if (((int)id->misc->uid) && ((int)id->misc->gid)) {    // NB: Root-access is prevented.    privs=Privs("CHMODing file", (int)id->misc->uid, (int)id->misc->gid );    }   
Roxen.git/server/modules/filesystems/filesystem.pike:748:       if(err)    {    id->misc->error_code = 403;    TRACE_LEAVE("CHMOD: Failure");    TRACE_LEAVE("Failure");    return 0;    }    TRACE_LEAVE("CHMOD: Success");    TRACE_LEAVE("Success"); -  return http_string_answer("Ok"); +  return Roxen.http_string_answer("Ok");       case "MV":    // This little kluge is used by ftp2 to move files.       // FIXME: Support for quota.       if(!QUERY(put))    {    id->misc->error_code = 405;    TRACE_LEAVE("MV disallowed (since PUT is disallowed)");
Roxen.git/server/modules/filesystems/filesystem.pike:777:       if(size < -1)    {    id->misc->error_code = 405;    TRACE_LEAVE("MV: Cannot overwrite directory");    return 0;    }       if(QUERY(check_auth) && (!id->auth || !id->auth[0])) {    TRACE_LEAVE("MV: Permission denied"); -  return http_auth_required("foo", +  return Roxen.http_auth_required("foo",    "<h1>Permission to 'MV' files denied</h1>");    }    string movefrom;    if(!id->misc->move_from ||    !(movefrom = id->conf->real_file(id->misc->move_from, id))) {    id->misc->error_code = 405;    errors++;    TRACE_LEAVE("MV: No source file");    return 0;    }
Roxen.git/server/modules/filesystems/filesystem.pike:834:       if(!code)    {    id->misc->error_code = 403;    TRACE_LEAVE("MV: Move failed");    TRACE_LEAVE("Failure");    return 0;    }    TRACE_LEAVE("MV: Success");    TRACE_LEAVE("Success"); -  return http_string_answer("Ok"); +  return Roxen.http_string_answer("Ok");       case "MOVE":    // This little kluge is used by NETSCAPE 4.5       // FIXME: Support for quota.       if(!QUERY(put))    {    id->misc->error_code = 405;    TRACE_LEAVE("MOVE disallowed (since PUT is disallowed)");
Roxen.git/server/modules/filesystems/filesystem.pike:856:    }    if(size != -1)    {    id->misc->error_code = 404;    TRACE_LEAVE("MOVE failed (no such file)");    return 0;    }       if(QUERY(check_auth) && (!id->auth || !id->auth[0])) {    TRACE_LEAVE("MOVE: Permission denied"); -  return http_auth_required("foo", +  return Roxen.http_auth_required("foo",    "<h1>Permission to 'MOVE' files denied</h1>");    }       if(!sizeof(id->misc["new-uri"] || "")) {    id->misc->error_code = 405;    errors++;    TRACE_LEAVE("MOVE: No dest file");    return 0;    }    string new_uri = combine_path(uri + "/../",
Roxen.git/server/modules/filesystems/filesystem.pike:936:       if(!code)    {    id->misc->error_code = 403;    TRACE_LEAVE("MOVE: Move failed");    TRACE_LEAVE("Failure");    return 0;    }    TRACE_LEAVE("MOVE: Success");    TRACE_LEAVE("Success"); -  return http_string_answer("Ok"); +  return Roxen.http_string_answer("Ok");          case "DELETE":    if(!QUERY(delete) || size==-1)    {    id->misc->error_code = 405;    TRACE_LEAVE("DELETE: Disabled");    return 0;    }