Roxen.git / server / base_server / roxen.pike

version» Context lines:

Roxen.git/server/base_server/roxen.pike:1:   // This file is part of Roxen WebServer.   // Copyright © 1996 - 2004, Roxen IS.   //   // The Roxen WebServer main program.   //   // Per Hedbor, Henrik Grubbström, Pontus Hagland, David Hedbor and others.   // ABS and suicide systems contributed freely by Francesco Chemolli    - constant cvs_version="$Id: roxen.pike,v 1.918 2006/04/18 17:24:48 grubba Exp $"; + constant cvs_version="$Id: roxen.pike,v 1.919 2006/04/19 09:16:52 grubba Exp $";      //! @appears roxen   //!   //! The Roxen WebServer main program.      // The argument cache. Used by the image cache.   ArgCache argcache;      // Some headerfiles   #define IN_ROXEN
Roxen.git/server/base_server/roxen.pike:3530:    }    }    res->stat = ({ 0, 0, 0, 900000000, 0, 0, 0, 0, 0 });       // Setting the cacheable flag is done in order to get headers sent which    // cause the image to be cached in the client even when using https    // sessions. However, this flag also controls whether the file should    // be placed in the protocol-level cache, so we'll counter by setting a    // separate flag.    RAISE_CACHE(INITIAL_CACHEABLE); - #if 0 + #ifndef ENABLE_NEW_ARGCACHE    NO_PROTO_CACHE();   #endif    return res;    }       mapping metadata( array|string|mapping data,    RequestID id,    int|void nodraw )    //! Returns a mapping of image metadata for an image generated from    //! the data given (as sent to @[store()]). If a non-zero
Roxen.git/server/base_server/roxen.pike:5672:   //! @[NO_PROTO_CACHE()], @[array_sscanf()]   array(array(string|int|array)) security_checks = ({    ({ "ip=%s:%s",2,({    lambda( string a, string b ){    int net = Roxen.ip_to_int( a );    int mask = Roxen.ip_to_int( b );    net &= mask;    return ({ net, sprintf("%c",mask)[0] });    },    " if ((Roxen.ip_to_int(id->remoteaddr) & %[1]d) == %[0]d)", -  (<" id->register_vary_callback(0, Roxen.get_remoteaddr);">), +     }), "ip" }),    ({ "ip=%s/%d",2,({    lambda( string a, int b ){    int net = Roxen.ip_to_int( a );    int mask = ((~0<<(32-b))&0xffffffff);    net &= mask;    return ({ net, sprintf("%c",mask)[0] });    },    " if ((Roxen.ip_to_int(id->remoteaddr) & %[1]d) == %[0]d) ", -  (<" id->register_vary_callback(0, Roxen.get_remoteaddr);">), +     }), "ip", }),    ({ "ip=%s",1,({    " if (sizeof(filter(%[0]O/\",\",\n"    " lambda(string q){\n"    " return glob(q,id->remoteaddr);\n"    " })))", -  (<" id->register_vary_callback(0, Roxen.get_remoteaddr);">), +     }), "ip", }),    ({ "user=%s",1,({ 1,    lambda( string x ) {    return ({sprintf("(< %{%O, %}>)", x/"," )});    },       " if ((user || (user = authmethod->authenticate(id, userdb_module)))\n"    " && ((%[0]s->any) || (%[0]s[user->name()]))) ",    (<" User user" >),    // No need to NOCACHE () here, since it's up to the
Roxen.git/server/base_server/roxen.pike:5720:    // auth-modules to do that.    }), "group", }),    ({ "dns=%s",1,({    " if(!dns && \n"    " ((dns=roxen.quick_ip_to_host(id->remoteaddr))==id->remoteaddr))\n"    " if( (id->misc->delayed+=0.1) < 1.0 )\n"    " return Roxen.http_try_again( 0.1 );\n"    " if (sizeof(filter(%[0]O/\",\",\n"    " lambda(string q){return glob(lower_case(q),lower_case(dns));})))",    (< " string dns" >), -  (<" id->register_vary_callback(0, Roxen.get_remoteaddr);">), +     }), "ip", }),    ({ "time=%d:%d-%d:%d",4,({    (< " mapping l = localtime(time(1))" >),    (< " int th = l->hour, tm = l->min" >),    // No need to NOCACHE() here, does not depend on client.    " if (((th >= %[0]d) && (tm >= %[1]d)) &&\n"    " ((th <= %[2]d) && (tm <= %[3]d)))",    }), "time", }),    ({ "referer=%s", 1, ({    (<    " string referer = sizeof(id->referer||({}))?id->referer[0]:\"\"; "    >),    " if( sizeof(filter(%[0]O/\",\",\n"    " lambda(string q){return glob(q,referer);})))", -  (<" id->register_vary_callback(\"referer\");">), +     }), "referer", }),    ({ "day=%s",1,({    lambda( string q ) {    multiset res = (<>);    foreach( q/",", string w ) if( (int)w )    res[((int)w % 7)] = 1;    else    res[ (["monday":1,"thuesday":2,"wednesday":3,"thursday":4,"friday":5,    "saturday":6,"sunday":0,"mon":1, "thu":2, "wed":3, "thu":4,    "fri":5, "sat":6, "sun":0, ])[ lower_case(w) ] ] = 1;
Roxen.git/server/base_server/roxen.pike:5840:   // #endif    }             string code = "";    array variables = ({ " object userdb_module",    " object authmethod = id->conf",    " string realm = \"User\"",    " mapping(string:int|mapping) state = ([])", +  " id->register_vary_cb(0, vary_cb)",    });       // Some state variables for optimizing.    int all_shorted = 1; // All allow patterns have return.    int need_auth = 0; // We need auth for some checks.    int max_short_code = 0; // Max fail code for return checks.    int patterns; // Number of patterns.    multiset(string) checks = (<>); // Checks in state.       foreach( pattern / "\n", string line )
Roxen.git/server/base_server/roxen.pike:6118:    "") +    (max_short_code > 1?    " if (short_fail > 1)\n"    " return authmethod->authenticate_throw(id, realm);\n":    "") +    (!all_shorted && need_auth?    " if (fail == 2)\n"    " return authmethod->authenticate_throw(id, realm);\n":    "") +    " return 1;\n" +  "}\n" +  "string vary_cb(string ignored, RequestID id)\n" +  "{\n" +  " int|mapping res = f(id);" +  " if (intp(res)) return (string) res;" +  " return 0; // FIXME: Analyze the mapping." +  "}\n" +  "int|mapping f(RequestID id)\n" +  "{\n" +  " int res = low_f(id);\n" +  " if (res == 2) authmethod->authenticate_throw(id, realm);\n" +  " return res;\n"    "}\n");   #if defined(SECURITY_PATTERN_DEBUG) || defined(HTACCESS_DEBUG)    report_debug(sprintf("Compiling security pattern:\n"    "%{ %s\n%}\n"    "Code:\n"    "%{ %s\n%}\n",    pattern/"\n",    code/"\n"));   #endif /* SECURITY_PATTERN_DEBUG || HTACCESS_DEBUG */    mixed res = compile_string( code );