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.25 1998/01/04 07:25:54 peter Exp $"; + constant cvs_version= "$Id: filesystem.pike,v 1.26 1998/02/04 16:10:42 per Exp $";   int thread_safe=1;         #include <module.h>   #include <roxen.h>   #include <stat.h>      #if DEBUG_LEVEL > 20   # ifndef FILESYSTEM_DEBUG   # define FILESYSTEM_DEBUG   # endif   #endif    - #if !constant(Privs) - constant Privs=((program)"privs"); - #endif /* !constant(Privs) */ -  +    inherit "module";   inherit "roxenlib";   inherit "socket";      import Array;      int redirects, accesses, errors, dirlists;   int puts, deletes;      static int do_stat = 1;
Roxen.git/server/modules/filesystems/filesystem.pike:116:    "the users of your WWW-server. If you want to serve any 'normal' "    "files from your server, you will have to have atleast one filesystem.")    });   }      string path;   int stat_cache;      void start()   { + #ifdef THREADS +  if(QUERY(access_as_user)) +  report_warning("It is not possible to use 'Access as user' when " +  "running with threads. Remove -DENABLE_THREADS from " +  "the start script if you really need this function\n"); + #endif +     path = QUERY(searchpath);    stat_cache = QUERY(stat_cache);   #ifdef FILESYSTEM_DEBUG    perror("FILESYSTEM: Online at "+QUERY(mountpoint)+" (path="+path+")\n");   #endif   }      string query_location()   {    return QUERY(mountpoint);
Roxen.git/server/modules/filesystems/filesystem.pike:137:         mixed stat_file( mixed f, mixed id )   {    array fs;    if(stat_cache && !id->pragma["no-cache"] &&    (fs=cache_lookup("stat_cache",path+f)))    return fs;       object privs; -  + #ifndef THREADS    if (((int)id->misc->uid) && ((int)id->misc->gid) &&    (QUERY(access_as_user))) {    // NB: Root-access is prevented.    privs=Privs("Statting file", (int)id->misc->uid, (int)id->misc->gid );    } -  + #endif +     fs = file_stat(path + f); /* No security currently in this function */    privs = 0;    if(!stat_cache)    return fs;    cache_set("stat_cache", path+f, fs);    return fs;   }      string real_file( mixed f, mixed id )   {
Roxen.git/server/modules/filesystems/filesystem.pike:173:    return 1;   }      array find_dir( string f, object id )   {    mixed ret;    array dir;       object privs;    + #ifndef THREADS    if (((int)id->misc->uid) && ((int)id->misc->gid) &&    (QUERY(access_as_user))) {    // NB: Root-access is prevented.    privs=Privs("Getting dir", (int)id->misc->uid, (int)id->misc->gid );    } -  + #endif       if(!(dir = get_dir( path + f ))) {    privs = 0;    return 0;    }       privs = 0;       if(!QUERY(dir))    // Access to this dir is allowed.
Roxen.git/server/modules/filesystems/filesystem.pike:311:    return http_redirect(id->not_query[..sizeof(id->not_query)-2], id);    }       if(!id->misc->internal_get && QUERY(.files)    && (tmp = (id->not_query/"/")[-1])    && tmp[0] == '.')    return 0;       object privs;    + #ifndef THREADS    if (((int)id->misc->uid) && ((int)id->misc->gid) &&    (QUERY(access_as_user))) {    // NB: Root-access is prevented.    privs=Privs("Getting file", (int)id->misc->uid, (int)id->misc->gid );    } -  + #endif       o = open( f, "r" );       privs = 0;       if(!o || (QUERY(no_symlinks) && (contains_symlinks(path, oldf))))    {    errors++;    report_error("Open of " + f + " failed. Permission denied.\n");    return http_low_answer(403, "<h2>File exists, but access forbidden "
Roxen.git/server/modules/filesystems/filesystem.pike:353:    return 0;    }       if(QUERY(check_auth) && (!id->auth || !id->auth[0]))    return http_auth_required("foo",    "<h1>Permission to 'PUT' files denied</h1>");    puts++;       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("Saving file", (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");    return http_low_answer(403, "<h2>Permission denied.</h2>");    }       rm( f );    mkdirhier( f );