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

version» Context lines:

Roxen.git/server/modules/filesystems/filesystem.pike:1:   // This is a roxen module. (c) Informationsv√§varna AB 1996.      // 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. - string cvs_version = "$Id: filesystem.pike,v 1.10 1997/02/14 03:42:57 per Exp $"; +  + string cvs_version= "$Id: filesystem.pike,v 1.11 1997/03/26 05:54:10 per Exp $"; +    #include <module.h>   #include <stat.h>      #if DEBUG_LEVEL > 20   # ifndef FILESYSTEM_DEBUG   # define FILESYSTEM_DEBUG   # endif   #endif      inherit "module";
Roxen.git/server/modules/filesystems/filesystem.pike:60:    defvar("dir", 1, "Enable directory listings per default", TYPE_FLAG,    "If set, you have to create a file named .www_not_browsable ("    "or .nodiraccess) in a directory to disable directory listings."    " If unset, a file named .www_browsable in a directory will "    "_enable_ directory listings.\n");       defvar("tilde", 0, "Show backupfiles", TYPE_FLAG,    "If set, files ending with '~' or '#' or '.bak' will "+    "be shown in directory listings");    -  defvar("put", 1, "Handle the 'PUT' method", TYPE_FLAG, +  defvar("put", 1, "Handle the PUT method", TYPE_FLAG,    "If set, PUT can be used to upload files to the server.");    -  defvar("delete", 0, "Handle the 'DELETE' method", TYPE_FLAG, +  defvar("delete", 0, "Handle the DELETE method", TYPE_FLAG,    "If set, DELETE can be used to delete files from the "    "server.");       defvar("check_auth", 1, "Require authentication for modification",    TYPE_FLAG,    "Only allow authenticated users to use methods other than "    "GET and POST. If unset, this filesystem will be a _very_ "    "public one (anyone can edit files located on it)");       defvar("stat_cache", 1, "Cache the results of stat(2)",
Roxen.git/server/modules/filesystems/filesystem.pike:268: Inside #if defined(COMPAT)
  #ifdef COMPAT    if(QUERY(html)) /* Not very likely, really.. */    return ([ "type":"text/html", "file":o, ]);   #endif    return o;    }    break;       case "PUT":    if(!QUERY(put)) +  { +  id->misc->error_code = 405;    return 0; -  +  }       if(QUERY(check_auth) && (!id->auth || !id->auth[0])) -  return http_auth_required("foo","<h1>Permission to 'PUT' files denied</h1>"); -  +  return http_auth_required("foo", +  "<h1>Permission to 'PUT' files denied</h1>");    puts++;    - #if 0 -  perror("PUT "+id->not_query+" ; "+id->misc->len+" bytes for "+ -  id->misc->gecos+" (uid="+id->misc->uid+"; gid="+id->misc->gid+")\n"); - #endif - #if efun(geteuid) -  int ouid, ogid, dosetuid; -  if(id->misc->uid && !getuid()) // We want to create the files -  // with the correct uid/gid. -  { -  dosetuid = 1; ouid = geteuid(); ogid = getegid(); -  seteuid(getuid()); -  setegid( (int)id->misc->gid ); - #if efun(initgroups) -  initgroups( id->auth[1], (int)id->misc->gid ); - #endif -  seteuid( (int)id->misc->uid ); -  } - #endif +  object privs; +  +  if(id->misc->uid) +  privs=((program)"privs")("Saving file", id->misc->uid, id->misc->gid ); +     rm( f );    mkdirhier( f );    object to = open(f, "wc"); - #if efun(geteuid) -  if(dosetuid) -  { -  array ou; -  ou = roxen->user_from_uid( ouid, id ); -  seteuid(0); - #if efun(initgroups) -  if(ou) initgroups( ou[0], ogid ); - #endif -  seteuid( ouid ); -  setegid( ogid ); -  } - #endif +        if(!to) -  +  { +  id->misc->error_code = 403;    return 0; -  +  }       putting[id->my_fd]=id->misc->len;    if(id->data && strlen(id->data))    {    putting[id->my_fd] -= strlen(id->data);    to->write( id->data );    }    if(!putting[id->my_fd])    return http_string_answer("Ok");       if(id->prot == "HTTP/1.1")    id->my_fd->write("HTTP/1.1 100 Continue\r\n");    id->my_fd->set_id( ({ to, id->my_fd }) );    id->my_fd->set_nonblocking(got_put_data, 0, done_with_put);    return http_pipe_in_progress();    break;       case "DELETE":    if(!QUERY(delete) || size==-1) -  +  { +  id->misc->error_code = 405;    return 0; -  +  }    if(QUERY(check_auth) && !id->misc->auth_ok)    return http_low_answer(403, "<h1>Permission to DELETE file denied</h1>");    -  deletes++; +     report_error("DELETING the file "+f+"\n");    accesses++; -  rm(f); +  +  if(id->misc->uid) +  privs=((program)"privs")("Saving file", id->misc->uid, id->misc->gid ); +  +  if(!rm(f)) +  { +  id->misc->error_code = 405; +  return 0; +  } +  deletes++;    return http_low_answer(200,(f+" DELETED from the server"));       default:    return 0;    }    report_error("Not reached..\n");    return 0;   }      string query_name()   {    return sprintf("<i>%s</i> mounted on <i>%s</i>", query("searchpath"),    query("mountpoint"));   }