Roxen.git / server / base_server / configuration.pike

version» Context lines:

Roxen.git/server/base_server/configuration.pike:1:   // This file is part of Roxen WebServer.   // Copyright © 1996 - 2001, Roxen IS.   //      // @appears Configuration   //! A site's main configuration    - constant cvs_version = "$Id: configuration.pike,v 1.544 2003/11/25 17:27:56 anders Exp $"; + constant cvs_version = "$Id: configuration.pike,v 1.545 2004/02/17 20:47:18 mast Exp $";   #include <module.h>   #include <module_constants.h>   #include <roxen.h>   #include <request_trace.h>   #include <timers.h>      #define CATCH(P,X) do{mixed e;if(e=catch{X;})report_error("While "+P+"\n"+describe_backtrace(e));}while(0)      // --- Locale defines ---   //<locale-token project="roxen_start"> LOC_S </locale-token>
Roxen.git/server/base_server/configuration.pike:1043:    if (f)    return (["file":f, "type":"image/gif", "stat":f->stat(),]);    else    return 0;    // File not found.   }      private static int nest = 0;      #ifdef MODULE_LEVEL_SECURITY - private mapping misc_cache = set_weak_flag (([]), 1); + private mapping(RoxenModule:array) security_level_cache = set_weak_flag (([]), 1);      int|mapping check_security(function|RoxenModule a, RequestID id,    void|int slevel)   {    array seclevels;    // NOTE:    // ip_ok and auth_ok are three-state variables.    // Valid contents for them are:    // 0 Unknown state -- No such restriction encountered yet.    // 1 May be bad -- Restriction encountered, and test failed.    // ~0 OK -- Test passed.    -  if(!(seclevels = misc_cache[ a ])) -  { -  RoxenModule mod = Roxen.get_owning_module (a); -  if(mod && mod->query_seclevels) -  misc_cache[ a ] = seclevels = ({ +  if (RoxenModule mod = Roxen.get_owning_module (a)) { +  // Only store the module objects in the cache and not `a' directly +  // since it can be (in) an object that is very short lived. +  if (!(seclevels = security_level_cache[mod])) { +  if(mod->query_seclevels) +  seclevels = ({    mod->query_seclevels(),    mod->query("_seclvl"),    });    else -  misc_cache[ a ] = seclevels = ({0,0}); +  seclevels = ({0,0}); +  security_level_cache[mod] = seclevels;    } -  +  } +  else +  seclevels = ({0,0});       if(slevel && (seclevels[1] > slevel)) // "Trustlevel" to low.    // Regarding memory cache: This won't have any impact, since it's    // always the same, regardless of the client requesting the file.    return 1;       mixed err;    if( function(RequestID:int|mapping) f = seclevels[0] )    // And here we don't have to take notice of the RAM-cache either,    // since the security patterns themselves does that.
Roxen.git/server/base_server/configuration.pike:1106:    filter_module_cache = 0;    userdb_module_cache = 0;    auth_module_cache = 0;    first_module_cache = 0;    url_module_cache = 0;    location_module_cache = 0;    logger_module_cache = 0;    file_extension_module_cache = ([]);    provider_module_cache = ([]);   #ifdef MODULE_LEVEL_SECURITY -  misc_cache = ([ ]); +  security_level_cache = set_weak_flag (([ ]), 1);   #endif   }      // Empty all the caches above AND the ones in the loaded modules.   void clear_memory_caches()   {    invalidate_cache();    foreach(indices(otomod), RoxenModule m)    if (m && m->clear_memory_caches)    if (mixed err = catch( m->clear_memory_caches() ))
Roxen.git/server/base_server/configuration.pike:1429:    {    TRACE_LEAVE("");    TRACE_LEAVE(examine_return_mapping(fid));    TIMER_END(internal_magic);    return fid;    }    else    {   #ifdef MODULE_LEVEL_SECURITY    int oslevel = slevel; -  slevel = misc_cache[ find_internal ][1]; -  // misc_cache from +  slevel = security_level_cache[ Roxen.get_owning_module (find_internal) ][1]; +  // security_level_cache from    // check_security    id->misc->seclevel = slevel;   #endif    if(objectp(fid))    TRACE_LEAVE("Returned open filedescriptor. "   #ifdef MODULE_LEVEL_SECURITY    +(slevel != oslevel?    sprintf(" The security level is now %d.", slevel):"")   #endif    );
Roxen.git/server/base_server/configuration.pike:1551:    {    TRACE_LEAVE(""); // Location module [...]    TRACE_LEAVE(examine_return_mapping(fid));    TIMER_END(location_modules);    return fid;    }    else    {   #ifdef MODULE_LEVEL_SECURITY    int oslevel = slevel; -  slevel = misc_cache[ tmp[1] ][1]; -  // misc_cache from +  slevel = security_level_cache[ Roxen.get_owning_module (tmp[1]) ][1]; +  // security_level_cache from    // check_security    id->misc->seclevel = slevel;   #endif    if(objectp(fid))    TRACE_LEAVE("Returned open filedescriptor."   #ifdef MODULE_LEVEL_SECURITY    +(slevel != oslevel?    sprintf(" The security level is now %d.", slevel):"")   #endif