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.      inherit "module";   inherit "roxenlib";   inherit "socket";    - constant cvs_version= "$Id: filesystem.pike,v 1.28 1998/02/24 12:06:06 grubba Exp $"; + constant cvs_version= "$Id: filesystem.pike,v 1.29 1998/02/24 22:26:24 per Exp $";   constant thread_safe=1;         #include <module.h>   #include <roxen.h>   #include <stat.h>      #if DEBUG_LEVEL > 20   # ifndef FILESYSTEM_DEBUG   # define FILESYSTEM_DEBUG
Roxen.git/server/modules/filesystems/filesystem.pike:137:   {    return QUERY(mountpoint);   }         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; +  return fs[0];    -  object privs; +    #ifndef THREADS -  +  object privs;    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 */ -  + #ifndef THREADS    privs = 0; -  + #endif    if(!stat_cache)    return fs; -  cache_set("stat_cache", path+f, fs); +  cache_set("stat_cache", path+f, ({fs}));    return fs;   }      string real_file( mixed f, mixed id )   {    if(this->stat_file( f, id ))   /* This filesystem might be inherited by other filesystem, therefore    'this' */    return path + f;   }
Roxen.git/server/modules/filesystems/filesystem.pike:245:    putting[id[1]] -= strlen(data);    if(putting[id[1]] <= 0)    done_with_put( id );   }      int _file_size(string X,object id)   {    array fs;    if(!id->pragma["no-cache"]&&(fs=cache_lookup("stat_cache",(X))))    { -  id->misc->stat = fs; -  return fs[ST_SIZE]; +  id->misc->stat = fs[0]; +  return fs[0]?fs[0][ST_SIZE]:-1;    }    if(fs = file_stat(X))    {    id->misc->stat = fs; -  cache_set("stat_cache",(X),fs); +  cache_set("stat_cache",(X),({fs}));    return fs[ST_SIZE]; -  } +  } else +  cache_set("stat_cache",(X),({0}));    return -1;   }      #define FILE_SIZE(X) (stat_cache?_file_size((X),id):Stdio.file_size(X))      int contains_symlinks(string root, string path)   {    array arr = path/"/";       foreach(arr - ({ "" }), path) {
Roxen.git/server/modules/filesystems/filesystem.pike:316:    return 0;    redirects++;    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 -  +  object privs;    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" );    -  + #ifndef THREADS    privs = 0; -  + #endif       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 "    "by user</h2>");    }       id->realfile = f;