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 - 1998, Idonex AB.      // 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.34 1998/04/27 14:30:23 grubba Exp $"; + constant cvs_version= "$Id: filesystem.pike,v 1.35 1998/05/01 01:05:56 grubba Exp $";   constant thread_safe=1;         #include <module.h>   #include <roxen.h>   #include <stat.h>      #if DEBUG_LEVEL > 20   # ifndef FILESYSTEM_DEBUG   # define FILESYSTEM_DEBUG   # endif   #endif      // import Array;      #define TRACE_ENTER(A,B) do{if(id->misc->trace_enter)id->misc->trace_enter((A),(B));}while(0)   #define TRACE_LEAVE(A) do{if(id->misc->trace_leave)id->misc->trace_leave((A));}while(0)         int redirects, accesses, errors, dirlists; - int puts, deletes; + int puts, deletes, mkdirs;      static int do_stat = 1;      string status()   {    return ("<h2>Accesses to this filesystem</h2>"+    (redirects?"<b>Redirects</b>: "+redirects+"<br>":"")+    (accesses?"<b>Normal files</b>: "+accesses+"<br>"    :"No file accesses<br>")+    (QUERY(put)&&puts?"<b>Puts</b>: "+puts+"<br>":"")+ -  +  (QUERY(put)&&mkdirs?"<b>Mkdirs</b>: "+mkdirs+"<br>":"")+    (QUERY(delete)&&deletes?"<b>Deletes</b>: "+deletes+"<br>":"")+    (errors?"<b>Permission denied</b>: "+errors    +" (not counting .htaccess)<br>":"")+    (dirlists?"<b>Directories</b>:"+dirlists+"<br>":""));   }      void create()   {    defvar("mountpoint", "/", "Mount point", TYPE_LOCATION,    "This is where the module will be inserted in the "+
Roxen.git/server/modules/filesystems/filesystem.pike:380: Inside #if defined(COMPAT)
   if(QUERY(html)) {/* Not very likely, really.. */    TRACE_LEAVE("Compat return");    return ([ "type":"text/html", "file":o, ]);    }   #endif    TRACE_LEAVE("Normal return");    return o;    }    break;    +  case "MKDIR": +  if(!QUERY(put)) +  { +  id->misc->error_code = 405; +  TRACE_LEAVE("MKDIR disallowed (since PUT is disallowed)"); +  return 0; +  } +  +  if(QUERY(check_auth) && (!id->auth || !id->auth[0])) { +  TRACE_LEAVE("MKDIR: Permission denied"); +  return http_auth_required("foo", +  "<h1>Permission to 'MKDIR' denied</h1>"); +  } +  mkdirs++; +  object privs; +  + // #ifndef THREADS // Ouch. This is is _needed_. Well well... +  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 ); +  } + // #endif +  +  if (QUERY(no_symlinks) && (contains_symlinks(path, oldf))) { +  privs = 0; +  errors++; +  report_error("Creation of " + f + " failed. Permission denied.\n"); +  TRACE_LEAVE("MKDIR: Contains symlinks. Permission denied"); +  return http_low_answer(403, "<h2>Permission denied.</h2>"); +  } +  +  TRACE_ENTER("MKDIR: Accepted", 0); +  +  int code = mkdir( f ); +  +  privs = 0; +  if (code) { +  TRACE_LEAVE("MKDIR: Success"); +  TRACE_LEAVE("Success"); +  return http_string_answer("Ok"); +  } else { +  TRACE_LEAVE("MKDIR: Failed"); +  TRACE_LEAVE("Failure"); +  return 0; +  } +  +  break; +     case "PUT":    if(!QUERY(put))    {    id->misc->error_code = 405;    TRACE_LEAVE("PUT disallowed");    return 0;    }       if(QUERY(check_auth) && (!id->auth || !id->auth[0])) {    TRACE_LEAVE("PUT: Permission denied");