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.111 2001/09/11 15:17:19 per Exp $"; + constant cvs_version= "$Id: filesystem.pike,v 1.112 2001/09/21 09:52:09 per 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:132:       defvar("stat_cache", 0, LOCALE(33,"Cache the results of stat(2)"),    TYPE_FLAG|VAR_MORE,    LOCALE(34,"A performace option that can speed up retrieval of files "    "from NFS with up to 50%. In turn it uses some memory and the "    "file system will not notice that files have changed unless "    "it gets a pragma no-cache request (produced e.g. by "    "Alt-Ctrl-Reload in Netscape). Therefore this option should "    "not be used on file systems that change a lot."));    -  defvar("access_as_user", 0, LOCALE(35,"Access file as the logged in user"), +  defvar("access_as_user", 0, LOCALE(35,"Access files as the logged in user"),    TYPE_FLAG|VAR_MORE,    LOCALE(36,"If set, the module will access files as the authenticated "    "user. This assumes that a authentication module which imports"    " the users from the operating systems, such as the <i>User "    "database</i> module is used. This option is very useful for "    "named FTP sites, but it will have severe performance impacts "    "since all threads will be locked for each access."));    -  +  defvar("access_as_user_db", +  Variable.UserDBChoice( " all", VAR_MORE, +  LOCALE(0,"Authentication database to use"), +  LOCALE(36,"The User database module to use " +  "when authenticating users for the " +  "access file as the logged in user " +  "feature."), +  my_configuration())); +  +  defvar( "access_as_user_throw", 0, +  LOCALE(0,"Access files as the logged in user forces login"), +  TYPE_FLAG|VAR_MORE, +  LOCALE(0,"If true, a user will have to be logged in to access files in " +  "this filesystem") ); +     defvar("no_symlinks", 0, LOCALE(37,"Forbid access to symlinks"),    TYPE_FLAG|VAR_MORE,    LOCALE(38,"It set, the file system will not follow symbolic links. "    "This option can lower performace by a lot." ));       defvar("charset", "iso-8859-1", LOCALE(39,"File contents charset"),    TYPE_STRING,    LOCALE(40,"The charset of the contents of the files on this file "    "system. This variable makes it possible for Roxen to use "    "any text file, no matter what charset it is written in. If"
Roxen.git/server/modules/filesystems/filesystem.pike:174:    "considered internal. Internal files cannot be requested "    "directly from a browser, won't show up in directory listings "    "and can never be uploaded, moved or deleted by a browser."    "They can only be accessed internally, e.g. with the RXML tags"    " <tt>&lt;insert&gt;</tt> and <tt>&lt;use&gt;</tt>."));   }      string path, mountpoint, charset, path_encoding, normalized_path;   int stat_cache, dotfiles, access_as_user, no_symlinks, tilde;   array(string) internal_files; -  + UserDB access_as_user_db; + int access_as_user_throw;   void start()   {    tilde = query("tilde");    charset = query("charset");    path_encoding = query("path_encoding");    no_symlinks = query("no_symlinks");    access_as_user = query("access_as_user"); -  +  access_as_user_throw = query("access_as_user_throw"); +  access_as_user_db = +  my_configuration()->find_user_database( query("access_as_user_db") );    dotfiles = query(".files");    path = query("searchpath");    mountpoint = query("mountpoint");    stat_cache = query("stat_cache");    internal_files = query("internal_files"); -  +  +  +    #if constant(system.normalize_path)    if (catch {    if ((<'/','\\'>)[path[-1]]) {    normalized_path = system.normalize_path(path + ".");    } else {    normalized_path = system.normalize_path(path);    }   #ifdef __NT__    normalized_path += "\\";   #else /* !__NT__ */
Roxen.git/server/modules/filesystems/filesystem.pike:222:    return mountpoint;   }         #define FILTER_INTERNAL_FILE(f, id) \    (!id->misc->internal_get && sizeof (filter (internal_files, glob, (f/"/")[-1])))      #define SETUID(X) \    if( access_as_user ) \    { \ -  User uid = id->conf->authenticate( id ); \ +  User uid = id->conf->authenticate( id,access_as_user_db ); \ +  if( access_as_user_throw && !uid ) \ +  return id->conf->authenticate_throw( id, "User",access_as_user_db);\    if( uid && uid->uid() ) \    privs=Privs(X, uid->uid(), uid->gid() ); \    }    -  + #define SETUID_NT(X) \ +  if( access_as_user ) \ +  { \ +  User uid = id->conf->authenticate( id,access_as_user_db ); \ +  if( uid && uid->uid() ) \ +  privs=Privs(X, uid->uid(), uid->gid() ); \ +  } +    mixed stat_file( string f, RequestID id )   {    Stat fs;       FILESYSTEM_WERR("stat_file for \""+f+"\"" +    (id->misc->internal_get ? " (internal)" : ""));       f = path+f;       if (FILTER_INTERNAL_FILE (f, id))    return 0;       if(stat_cache && !id->pragma["no-cache"] &&    (fs=cache_lookup("stat_cache",f)))    return fs[0];    object privs; -  SETUID("Statting file"); +  SETUID_NT("Statting file");       /* No security currently in this function */    fs = file_stat(decode_path(f));    privs = 0;    if(!stat_cache) return fs;    cache_set("stat_cache", f, ({fs}));    return fs;   }      string real_file( string f, RequestID id )
Roxen.git/server/modules/filesystems/filesystem.pike:281:   }      array find_dir( string f, RequestID id )   {    array dir;       FILESYSTEM_WERR("find_dir for \""+f+"\"" +    (id->misc->internal_get ? " (internal)" : ""));       object privs; -  SETUID("Read dir"); +  SETUID_NT("Read dir");       if (catch {    f = NORMALIZE_PATH(decode_path(path + f));    } || !(dir = get_dir(f))) {    privs = 0;    return 0;    }    privs = 0;       if(!query("dir"))