0bf5a1 | 1998-04-03 | Henrik Grubbström (Grubba) | | string cvs_version = "$Id: configuration.pike,v 1.117 1998/04/03 17:20:15 grubba Exp $";
|
b1fca0 | 1996-11-12 | Per Hedbor | | #include <module.h>
|
14179b | 1997-01-29 | Per Hedbor | | #include <roxen.h>
|
8afc81 | 1998-02-04 | Per Hedbor | |
#ifdef PROFILE
mapping profile_map = ([]);
#endif
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
193535 | 1997-04-28 | Henrik Grubbström (Grubba) | |
|
14179b | 1997-01-29 | Per Hedbor | | inherit "roxenlib";
|
3e44e6 | 1998-02-19 | Fredrik Noring | | public string real_file(string file, object id);
|
14179b | 1997-01-29 | Per Hedbor | |
function store = roxen->store;
function retrieve = roxen->retrieve;
function remove = roxen->remove;
function do_dest = roxen->do_dest;
function create_listen_socket = roxen->create_listen_socket;
|
b1fca0 | 1996-11-12 | Per Hedbor | | object parse_module;
object types_module;
object auth_module;
object dir_module;
function types_fun;
function auth_fun;
string name;
mapping variables = ([]);
|
14179b | 1997-01-29 | Per Hedbor | | public mixed query(string var)
{
if(var && variables[var])
return variables[var][ VAR_VALUE ];
if(!var) return variables;
|
383fa9 | 1997-01-29 | Per Hedbor | | error("query("+var+"): Unknown variable.\n");
|
14179b | 1997-01-29 | Per Hedbor | | }
mixed set(string var, mixed val)
{
#if DEBUG_LEVEL > 30
perror(sprintf("MAIN: set(\"%s\", %O)\n", var, val));
#endif
if(variables[var])
{
#if DEBUG_LEVEL > 28
perror("MAIN: Setting global variable.\n");
#endif
return variables[var][VAR_VALUE] = val;
}
error("set("+var+"). Unknown variable.\n");
}
int setvars( mapping (string:mixed) vars )
{
string v;
foreach( indices( vars ), v )
if(variables[v])
variables[v][ VAR_VALUE ] = vars[ v ];
return 1;
}
void killvar(string name)
{
m_delete(variables, name);
}
|
c85684 | 1998-01-21 | Henrik Grubbström (Grubba) | | int defvar(string var, mixed value, string name, int type,
string|void doc_str, mixed|void misc,
int|function|void not_in_config)
|
14179b | 1997-01-29 | Per Hedbor | | {
variables[var] = allocate( VAR_SIZE );
variables[var][ VAR_VALUE ] = value;
|
13ff62 | 1997-08-12 | Per Hedbor | | variables[var][ VAR_TYPE ] = type & VAR_TYPE_MASK;
|
14179b | 1997-01-29 | Per Hedbor | | variables[var][ VAR_DOC_STR ] = doc_str;
variables[var][ VAR_NAME ] = name;
variables[var][ VAR_MISC ] = misc;
|
9b9f70 | 1997-08-12 | Per Hedbor | |
if((type&~VAR_TYPE_MASK) & VAR_EXPERT)
variables[var][ VAR_CONFIGURABLE ] = VAR_EXPERT;
else if((type&~VAR_TYPE_MASK) & VAR_MORE)
variables[var][ VAR_CONFIGURABLE ] = VAR_MORE;
|
14179b | 1997-01-29 | Per Hedbor | | else
|
9b9f70 | 1997-08-12 | Per Hedbor | | if(intp(not_in_config))
variables[var][ VAR_CONFIGURABLE ]= !not_in_config;
else if(functionp(not_in_config))
variables[var][ VAR_CONFIGURABLE ]= not_in_config;
|
14179b | 1997-01-29 | Per Hedbor | | variables[var][ VAR_SHORTNAME ] = var;
}
int definvisvar(string var, mixed value, int type)
{
return defvar(var, value, "", type, "", 0, 1);
}
|
b1fca0 | 1996-11-12 | Per Hedbor | |
string query_name()
{
if(strlen(QUERY(name))) return QUERY(name);
return name;
}
string comment()
{
return QUERY(comment);
}
|
38dca8 | 1996-12-10 | Per Hedbor | | class Priority
|
27b0e1 | 1996-11-26 | Per Hedbor | | {
|
b1fca0 | 1996-11-12 | Per Hedbor | | array (object) url_modules = ({ });
array (object) logger_modules = ({ });
array (object) location_modules = ({ });
array (object) filter_modules = ({ });
array (object) last_modules = ({ });
array (object) first_modules = ({ });
mapping (string:array(object)) extension_modules = ([ ]);
mapping (string:array(object)) file_extension_modules = ([ ]);
|
ae32d0 | 1998-03-23 | David Hedbor | | mapping (object:multiset) provider_modules = ([ ]);
|
38dca8 | 1996-12-10 | Per Hedbor | |
void stop()
{
|
ae32d0 | 1998-03-23 | David Hedbor | | foreach(url_modules, object m) catch { m->stop(); };
foreach(logger_modules, object m) catch { m->stop(); };
foreach(filter_modules, object m) catch { m->stop(); };
foreach(location_modules, object m) catch { m->stop(); };
foreach(last_modules, object m) catch { m->stop(); };
foreach(first_modules, object m) catch { m->stop(); };
foreach(indices(provider_modules), object m) catch { m->stop(); };
|
38dca8 | 1996-12-10 | Per Hedbor | | }
}
|
b1fca0 | 1996-11-12 | Per Hedbor | |
array (object) allocate_pris()
{
int a;
array (object) tmp;
tmp=allocate(10);
|
27b0e1 | 1996-11-26 | Per Hedbor | | for(a=0; a<10; a++) tmp[a]=Priority();
|
b1fca0 | 1996-11-12 | Per Hedbor | | return tmp;
}
|
27b0e1 | 1996-11-26 | Per Hedbor | | class Bignum {
|
e8790b | 1998-02-19 | Per Hedbor | | #if constant(Gmp.mpz) // Perfect. :-)
object gmp = Gmp.mpz();
|
27b0e1 | 1996-11-26 | Per Hedbor | | float mb()
|
b1fca0 | 1996-11-12 | Per Hedbor | | {
|
e8790b | 1998-02-19 | Per Hedbor | | return (float)(gmp/1024)/1024.0;
}
object `+(int i)
{
gmp = gmp+i;
return this_object();
}
object `-(int i)
{
gmp = gmp-i;
return this_object();
|
b1fca0 | 1996-11-12 | Per Hedbor | | }
|
27b0e1 | 1996-11-26 | Per Hedbor | | #else
int msb;
int lsb=-0x7ffffffe;
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
6e925d | 1996-12-02 | Per Hedbor | | object `-(int i);
|
27b0e1 | 1996-11-26 | Per Hedbor | | object `+(int i)
{
|
14179b | 1997-01-29 | Per Hedbor | | if(!i) return this_object();
|
6e925d | 1996-12-02 | Per Hedbor | | if(i<0) return `-(-i);
|
14179b | 1997-01-29 | Per Hedbor | | object res = object_program(this_object())(lsb+i,msb,2);
|
27b0e1 | 1996-11-26 | Per Hedbor | | if(res->lsb < lsb) res->msb++;
return res;
}
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
27b0e1 | 1996-11-26 | Per Hedbor | | object `-(int i)
{
|
14179b | 1997-01-29 | Per Hedbor | | if(!i) return this_object();
|
6e925d | 1996-12-02 | Per Hedbor | | if(i<0) return `+(-i);
|
14179b | 1997-01-29 | Per Hedbor | | object res = object_program(this_object())(lsb-i,msb,2);
|
27b0e1 | 1996-11-26 | Per Hedbor | | if(res->lsb > lsb) res->msb--;
return res;
}
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
27b0e1 | 1996-11-26 | Per Hedbor | | float mb()
{
return ((((float)lsb/1024.0/1024.0)+2048.0)+(msb*4096.0));
}
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
f6d62d | 1997-03-26 | Per Hedbor | | void create(int|void num, int|void bnum, int|void d)
|
27b0e1 | 1996-11-26 | Per Hedbor | | {
if(!d)
lsb = num-0x7ffffffe;
else
lsb = num;
msb = bnum;
}
#endif
|
b1fca0 | 1996-11-12 | Per Hedbor | | }
|
27b0e1 | 1996-11-26 | Per Hedbor | |
int requests;
|
12a9c5 | 1997-08-11 | Henrik Grubbström (Grubba) | |
mapping(string:mixed) extra_statistics = ([]);
|
dc54c4 | 1997-08-28 | Henrik Grubbström (Grubba) | | mapping(string:mixed) misc = ([]);
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
27b0e1 | 1996-11-26 | Per Hedbor | | object sent=Bignum();
object hsent=Bignum();
object received=Bignum();
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
14179b | 1997-01-29 | Per Hedbor | | object this = this_object();
|
b1fca0 | 1996-11-12 | Per Hedbor | |
private object *_toparse_modules = ({});
private function log_function;
private mapping (string:string) log_format = ([]);
private array (object) pri = allocate_pris();
public mapping (string:mapping(string:mixed)) modules = ([]);
public mapping (object:string) otomod = ([]);
private array (function) url_module_cache, last_module_cache;
private array (function) logger_module_cache, first_module_cache;
private array (function) filter_module_cache;
private array (array (string|function)) location_module_cache;
private mapping (string:array (function)) extension_module_cache=([]);
private mapping (string:array (function)) file_extension_module_cache=([]);
|
ae32d0 | 1998-03-23 | David Hedbor | | private mapping (string:array (object)) provider_module_cache=([]);
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
38dca8 | 1996-12-10 | Per Hedbor | |
void stop()
{
catch { parse_module->stop(); };
catch { types_module->stop(); };
catch { auth_module->stop(); };
catch { dir_module->stop(); };
for(int i=0; i<10; i++) catch { pri[i]->stop(); };
}
|
c85684 | 1998-01-21 | Henrik Grubbström (Grubba) | | public string type_from_filename( string file, int|void to )
|
b1fca0 | 1996-11-12 | Per Hedbor | | {
|
14179b | 1997-01-29 | Per Hedbor | | mixed tmp;
object current_configuration;
string ext=extension(file);
if(!types_fun)
return to?({ "application/octet-stream", 0 }):"application/octet-stream";
|
ad987b | 1998-02-24 | Per Hedbor | |
|
14179b | 1997-01-29 | Per Hedbor | |
if(tmp = types_fun(ext))
{
mixed tmp2,nx;
if(tmp[0] == "strip")
{
tmp2=file/".";
if(sizeof(tmp2) > 2)
nx=tmp2[-2];
if(nx && (tmp2=types_fun(nx)))
tmp[0] = tmp2[0];
else
if(tmp2=types_fun("default"))
tmp[0] = tmp2[0];
else
tmp[0]="application/octet-stream";
}
return to?tmp:tmp[0];
} else {
if(!(tmp=types_fun("default")))
tmp=({ "application/octet-stream", 0 });
}
return 0;
|
b1fca0 | 1996-11-12 | Per Hedbor | | }
|
ae32d0 | 1998-03-23 | David Hedbor | |
array (object) get_providers(string provides)
{
if(!provider_module_cache[provides])
{
int i;
provider_module_cache[provides] = ({ });
for(i = 9; i >= 0; i--)
{
object d;
foreach(indices(pri[i]->provider_modules), d)
if(pri[i]->provider_modules[ d ][ provides ])
provider_module_cache[provides] += ({ d });
}
}
return provider_module_cache[provides];
}
|
14179b | 1997-01-29 | Per Hedbor | |
|
ae32d0 | 1998-03-23 | David Hedbor | |
object get_provider(string provides)
{
array (object) prov = get_providers(provides);
if(sizeof(prov))
return prov[0];
return 0;
}
void map_providers(string provides, string fun, mixed ... args)
{
array (object) prov = get_providers(provides);
array error;
foreach(prov, object mod) {
if(!objectp(mod))
continue;
if(functionp(mod[fun]))
error = catch(mod[fun](@args));
else
error = 0;
if(arrayp(error))
werror(describe_backtrace(error + ({ "Error in map_providers:"})));
}
}
mixed call_provider(string provides, string fun, mixed ... args)
{
array (object) prov = get_providers(provides);
array error;
mixed ret;
foreach(prov, object mod) {
if(!objectp(mod))
continue;
if(functionp(mod[fun]))
error = catch {
ret = mod[fun](@args);
};
else
error = ret = 0;
if(arrayp(error))
throw(error + ({ "Error in call_provider:"}));
if(ret)
return ret;
}
}
|
14179b | 1997-01-29 | Per Hedbor | |
|
b1fca0 | 1996-11-12 | Per Hedbor | | array (function) extension_modules(string ext, object id)
{
if(!extension_module_cache[ext])
{
int i;
extension_module_cache[ext] = ({ });
for(i=9; i>=0; i--)
{
object *d, p;
if(d = pri[i]->extension_modules[ext])
foreach(d, p)
extension_module_cache[ext] += ({ p->handle_extension });
}
}
return extension_module_cache[ext];
}
|
ae32d0 | 1998-03-23 | David Hedbor | |
|
b1fca0 | 1996-11-12 | Per Hedbor | | array (function) file_extension_modules(string ext, object id)
{
if(!file_extension_module_cache[ext])
{
int i;
file_extension_module_cache[ext] = ({ });
for(i=9; i>=0; i--)
{
object *d, p;
if(d = pri[i]->file_extension_modules[ext])
foreach(d, p)
file_extension_module_cache[ext] += ({ p->handle_file_extension });
}
}
return file_extension_module_cache[ext];
}
array (function) url_modules(object id)
{
if(!url_module_cache)
{
int i;
url_module_cache=({ });
for(i=9; i>=0; i--)
{
object *d, p;
if(d=pri[i]->url_modules)
foreach(d, p)
url_module_cache += ({ p->remap_url });
}
}
return url_module_cache;
}
|
4f4bc1 | 1998-02-04 | Per Hedbor | | mapping api_module_cache = ([]);
|
cf8aa8 | 1998-03-01 | David Hedbor | | mapping api_functions(object id)
|
4f4bc1 | 1998-02-04 | Per Hedbor | | {
return copy_value(api_module_cache);
}
|
b1fca0 | 1996-11-12 | Per Hedbor | | array (function) logger_modules(object id)
{
if(!logger_module_cache)
{
int i;
logger_module_cache=({ });
for(i=9; i>=0; i--)
{
object *d, p;
if(d=pri[i]->logger_modules)
foreach(d, p)
if(p->log)
logger_module_cache += ({ p->log });
}
}
return logger_module_cache;
}
array (function) last_modules(object id)
{
if(!last_module_cache)
{
int i;
last_module_cache=({ });
for(i=9; i>=0; i--)
{
object *d, p;
if(d=pri[i]->last_modules)
foreach(d, p)
if(p->last_resort)
last_module_cache += ({ p->last_resort });
}
}
return last_module_cache;
}
array (function) first_modules(object id)
{
if(!first_module_cache)
{
int i;
first_module_cache=({ });
for(i=9; i>=0; i--)
{
object *d, p;
|
f12890 | 1997-08-15 | Henrik Grubbström (Grubba) | | if(d=pri[i]->first_modules) {
foreach(d, p) {
if(p->first_try) {
|
b1fca0 | 1996-11-12 | Per Hedbor | | first_module_cache += ({ p->first_try });
|
f12890 | 1997-08-15 | Henrik Grubbström (Grubba) | | }
}
}
|
b1fca0 | 1996-11-12 | Per Hedbor | | }
}
|
f12890 | 1997-08-15 | Henrik Grubbström (Grubba) | |
|
b1fca0 | 1996-11-12 | Per Hedbor | | return first_module_cache;
}
array location_modules(object id)
{
if(!location_module_cache)
{
int i;
|
8cc31b | 1997-10-12 | Henrik Grubbström (Grubba) | | array new_location_module_cache=({ });
|
b1fca0 | 1996-11-12 | Per Hedbor | | for(i=9; i>=0; i--)
{
object *d, p;
|
8cc31b | 1997-10-12 | Henrik Grubbström (Grubba) | | if(d=pri[i]->location_modules) {
array level_find_files = ({});
array level_locations = ({});
foreach(d, p) {
string location;
if(p->find_file && (location = p->query_location())) {
level_find_files += ({ p->find_file });
level_locations += ({ location });
}
}
sort(level_locations, level_find_files);
int j;
for (j = sizeof(level_locations); j--;) {
new_location_module_cache += ({ ({ level_locations[j],
level_find_files[j] }) });
}
}
|
b1fca0 | 1996-11-12 | Per Hedbor | | }
|
8cc31b | 1997-10-12 | Henrik Grubbström (Grubba) | | location_module_cache = new_location_module_cache;
|
b1fca0 | 1996-11-12 | Per Hedbor | | }
return location_module_cache;
}
array filter_modules(object id)
{
if(!filter_module_cache)
{
int i;
filter_module_cache=({ });
for(i=9; i>=0; i--)
{
object *d, p;
if(d=pri[i]->filter_modules)
foreach(d, p)
if(p->filter)
filter_module_cache+=({ p->filter });
}
}
return filter_module_cache;
}
|
14179b | 1997-01-29 | Per Hedbor | |
void init_log_file()
|
b1fca0 | 1996-11-12 | Per Hedbor | | {
|
14179b | 1997-01-29 | Per Hedbor | | remove_call_out(init_log_file);
if(log_function)
|
b1fca0 | 1996-11-12 | Per Hedbor | | {
|
14179b | 1997-01-29 | Per Hedbor | | destruct(function_object(log_function));
|
b1fca0 | 1996-11-12 | Per Hedbor | | }
|
14179b | 1997-01-29 | Per Hedbor | | if(query("Log"))
|
b1fca0 | 1996-11-12 | Per Hedbor | | {
|
f7d981 | 1997-09-12 | Per Hedbor | | mapping m = localtime(time());
|
119e24 | 1997-05-24 | Henrik Grubbström (Grubba) | | string logfile = query("LogFile");
|
0a2122 | 1998-01-08 | Henrik Grubbström (Grubba) | | m->year += 1900;
m->mon++;
|
f7d981 | 1997-09-12 | Per Hedbor | | if(m->mon < 10) m->mon = "0"+m->mon;
|
0a2122 | 1998-01-08 | Henrik Grubbström (Grubba) | | if(m->mday < 10) m->mday = "0"+m->mday;
|
f7d981 | 1997-09-12 | Per Hedbor | | if(m->hour < 10) m->hour = "0"+m->hour;
logfile = replace(logfile,({"%d","%m","%y","%h" }),
|
0a2122 | 1998-01-08 | Henrik Grubbström (Grubba) | | ({ (string)m->mday, (string)(m->mon),
(string)(m->year),(string)m->hour,}));
|
f7d981 | 1997-09-12 | Per Hedbor | | if(strlen(logfile))
|
b1fca0 | 1996-11-12 | Per Hedbor | | {
|
f7d981 | 1997-09-12 | Per Hedbor | | do {
|
8afc81 | 1998-02-04 | Per Hedbor | | #ifndef THREADS
|
f7d981 | 1997-09-12 | Per Hedbor | | object privs = Privs("Opening logfile \""+logfile+"\"");
|
8afc81 | 1998-02-04 | Per Hedbor | | #endif
|
f7d981 | 1997-09-12 | Per Hedbor | | object lf=open( logfile, "wac");
|
8afc81 | 1998-02-04 | Per Hedbor | | #if efun(chmod)
|
c79b26 | 1998-02-05 | Johan Schön | | #if efun(geteuid)
|
8afc81 | 1998-02-04 | Per Hedbor | | if(geteuid() != getuid()) chmod(logfile,0666);
|
c79b26 | 1998-02-05 | Johan Schön | | #endif
|
8afc81 | 1998-02-04 | Per Hedbor | | #endif
|
f7d981 | 1997-09-12 | Per Hedbor | | if(!lf) {
mkdirhier(logfile);
if(!(lf=open( logfile, "wac"))) {
report_error("Failed to open logfile. ("+logfile+")\n" +
"No logging will take place!\n");
log_function=0;
break;
|
119e24 | 1997-05-24 | Henrik Grubbström (Grubba) | | }
|
f7d981 | 1997-09-12 | Per Hedbor | | }
log_function=lf->write;
lf=0;
} while(0);
} else
log_function=0;
|
14179b | 1997-01-29 | Per Hedbor | | call_out(init_log_file, 60);
} else
log_function=0;
|
b1fca0 | 1996-11-12 | Per Hedbor | | }
|
14179b | 1997-01-29 | Per Hedbor | |
private inline string fix_logging(string s)
|
b1fca0 | 1996-11-12 | Per Hedbor | | {
|
14179b | 1997-01-29 | Per Hedbor | | string pre, post, c;
sscanf(s, "%*[\t ]", s);
s = replace(s, ({"\\t", "\\n", "\\r" }), ({"\t", "\n", "\r" }));
|
62eac8 | 1997-10-03 | Henrik Grubbström (Grubba) | |
while(s[0] == ' ') s = s[1..];
while(s[0] == '\t') s = s[1..];
|
14179b | 1997-01-29 | Per Hedbor | | while(sscanf(s, "%s$char(%d)%s", pre, c, post)==3)
s=sprintf("%s%c%s", pre, c, post);
while(sscanf(s, "%s$wchar(%d)%s", pre, c, post)==3)
s=sprintf("%s%2c%s", pre, c, post);
while(sscanf(s, "%s$int(%d)%s", pre, c, post)==3)
s=sprintf("%s%4c%s", pre, c, post);
if(!sscanf(s, "%s$^%s", pre, post))
s+="\n";
else
s=pre+post;
return s;
|
b1fca0 | 1996-11-12 | Per Hedbor | | }
|
14179b | 1997-01-29 | Per Hedbor | | private void parse_log_formats()
{
string b;
array foo=query("LogFormat")/"\n";
foreach(foo, b)
if(strlen(b) && b[0] != '#' && sizeof(b/":")>1)
|
62eac8 | 1997-10-03 | Henrik Grubbström (Grubba) | | log_format[(b/":")[0]] = fix_logging((b/":")[1..]*":");
|
14179b | 1997-01-29 | Per Hedbor | | }
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
14179b | 1997-01-29 | Per Hedbor | |
private void write_to_log( string host, string rest, string oh, function fun )
|
b1fca0 | 1996-11-12 | Per Hedbor | | {
|
14179b | 1997-01-29 | Per Hedbor | | int s;
if(!host) host=oh;
if(!stringp(host))
host = "error:no_host";
|
71c7b1 | 1998-03-02 | Henrik Grubbström (Grubba) | | else
host = (host/" ")[0];
|
14179b | 1997-01-29 | Per Hedbor | | if(fun) fun(replace(rest, "$host", host));
|
b1fca0 | 1996-11-12 | Per Hedbor | | }
|
14179b | 1997-01-29 | Per Hedbor | |
nomask private inline string host_ip_to_int(string s)
{
int a, b, c, d;
sscanf(s, "%d.%d.%d.%d", a, b, c, d);
return sprintf("%c%c%c%c",a, b, c, d);
}
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
14179b | 1997-01-29 | Per Hedbor | | nomask private inline string unsigned_to_bin(int a)
{
return sprintf("%4c", a);
}
nomask private inline string unsigned_short_to_bin(int a)
{
return sprintf("%2c", a);
}
nomask private inline string extract_user(string from)
{
array tmp;
if (!from || sizeof(tmp = from/":")<2)
return "-";
return tmp[0];
}
public void log(mapping file, object request_id)
{
|
e5bad2 | 1998-02-10 | Per Hedbor | |
|
14179b | 1997-01-29 | Per Hedbor | | string a;
string form;
function f;
foreach(logger_modules(request_id), f)
if(f(request_id,file))return;
if(!log_function) return;
if(QUERY(NoLog) && _match(request_id->remoteaddr, QUERY(NoLog)))
return;
if(!(form=log_format[(string)file->error]))
form = log_format["*"];
if(!form) return;
form=replace(form,
({
"$ip_number", "$bin-ip_number", "$cern_date",
"$bin-date", "$method", "$resource", "$protocol",
"$response", "$bin-response", "$length", "$bin-length",
"$referer", "$user_agent", "$user", "$user_id",
|
d9624c | 1998-04-03 | Henrik Grubbström (Grubba) | | "$request-time"
|
14179b | 1997-01-29 | Per Hedbor | | }), ({
(string)request_id->remoteaddr,
|
71c7b1 | 1998-03-02 | Henrik Grubbström (Grubba) | | host_ip_to_int(request_id->remoteaddr),
cern_http_date(time(1)),
unsigned_to_bin(time(1)),
(string)request_id->method,
http_encode_string((string)request_id->not_query),
(string)request_id->prot,
(string)(file->error||200),
unsigned_short_to_bin(file->error||200),
(string)(file->len>=0?file->len:"?"),
unsigned_to_bin(file->len),
(string)
(sizeof(request_id->referer||({}))?request_id->referer[0]:"-"),
http_encode_string(sizeof(request_id->client||({}))?request_id->client*" ":"-"),
extract_user(request_id->realauth),
(string)request_id->cookies->RoxenUserID,
|
d9624c | 1998-04-03 | Henrik Grubbström (Grubba) | | (string)(time(1)-request_id->time)
|
71c7b1 | 1998-03-02 | Henrik Grubbström (Grubba) | | }));
|
14179b | 1997-01-29 | Per Hedbor | |
if(search(form, "host") != -1)
roxen->ip_to_host(request_id->remoteaddr, write_to_log, form,
request_id->remoteaddr, log_function);
else
log_function(form);
|
e5bad2 | 1998-02-10 | Per Hedbor | |
|
14179b | 1997-01-29 | Per Hedbor | | }
public string status()
|
b1fca0 | 1996-11-12 | Per Hedbor | | {
|
14179b | 1997-01-29 | Per Hedbor | | float tmp;
|
b1fca0 | 1996-11-12 | Per Hedbor | | string res="";
|
14179b | 1997-01-29 | Per Hedbor | |
if(!sent||!received||!hsent)
return "Fatal error in status(): Bignum object gone.\n";
tmp = (sent->mb()/(float)(time(1)-roxen->start_time+1));
res = sprintf("<table><tr align=right><td><b>Sent data:</b></td><td>%.2fMB"
"</td><td>%.2f Kbit/sec</td>",
sent->mb(),tmp * 8192.0);
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
dc54c4 | 1997-08-28 | Henrik Grubbström (Grubba) | | res += sprintf("<td><b>Sent headers:</b></td><td>%.2fMB</td></tr>\n",
|
14179b | 1997-01-29 | Per Hedbor | | hsent->mb());
tmp=(((float)requests*(float)600)/
(float)((time(1)-roxen->start_time)+1));
|
12a9c5 | 1997-08-11 | Henrik Grubbström (Grubba) | | res += sprintf("<tr align=right><td><b>Number of requests:</b></td>"
"<td>%8d</td><td>%.2f/min</td>"
|
dc54c4 | 1997-08-28 | Henrik Grubbström (Grubba) | | "<td><b>Received data:</b></td><td>%.2fMB</td></tr>\n",
|
12a9c5 | 1997-08-11 | Henrik Grubbström (Grubba) | | requests, (float)tmp/(float)10, received->mb());
|
dc54c4 | 1997-08-28 | Henrik Grubbström (Grubba) | |
if (!zero_type(misc->ftp_users)) {
tmp = (((float)misc->ftp_users*(float)600)/
(float)((time(1)-roxen->start_time)+1));
res += sprintf("<tr align=right><td><b>FTP users (total):</b></td>"
"<td>%8d</td><td>%.2f/min</td>"
"<td><b>FTP users (now):</b></td><td>%d</td></tr>\n",
misc->ftp_users, (float)tmp/(float)10, misc->ftp_users_now);
}
|
926d1a | 1997-08-31 | Henrik Grubbström (Grubba) | | res += "</table><p>\n\n";
|
12a9c5 | 1997-08-11 | Henrik Grubbström (Grubba) | |
|
e91166 | 1997-08-29 | Henrik Grubbström (Grubba) | | if ((roxen->configuration_interface()->more_mode) &&
(extra_statistics->ftp) && (extra_statistics->ftp->commands)) {
|
12a9c5 | 1997-08-11 | Henrik Grubbström (Grubba) | |
res += "<b>FTP statistics:</b><br>\n"
"<ul><table>\n";
foreach(sort(indices(extra_statistics->ftp->commands)), string cmd) {
res += sprintf("<tr align=right><td><b>%s</b></td>"
|
fdf36e | 1997-08-13 | Henrik Grubbström (Grubba) | | "<td align=right>%d</td><td> time%s</td></tr>\n",
|
12a9c5 | 1997-08-11 | Henrik Grubbström (Grubba) | | upper_case(cmd), extra_statistics->ftp->commands[cmd],
(extra_statistics->ftp->commands[cmd] == 1)?"":"s");
}
res += "</table></ul>\n";
}
|
14179b | 1997-01-29 | Per Hedbor | |
|
12a9c5 | 1997-08-11 | Henrik Grubbström (Grubba) | | return res;
|
14179b | 1997-01-29 | Per Hedbor | | }
|
a78a59 | 1997-04-28 | Henrik Grubbström (Grubba) | | public string *userinfo(string u, object|void id)
|
14179b | 1997-01-29 | Per Hedbor | | {
if(auth_module) return auth_module->userinfo(u);
}
|
a78a59 | 1997-04-28 | Henrik Grubbström (Grubba) | | public string *userlist(object|void id)
|
14179b | 1997-01-29 | Per Hedbor | | {
if(auth_module) return auth_module->userlist();
}
|
a78a59 | 1997-04-28 | Henrik Grubbström (Grubba) | | public string *user_from_uid(int u, object|void id)
|
14179b | 1997-01-29 | Per Hedbor | | {
if(auth_module)
return auth_module->user_from_uid(u);
}
private mapping internal_gopher_image(string from)
{
sscanf(from, "%s.gif", from);
sscanf(from, "%s.jpg", from);
from -= ".";
return (["file":open("roxen-images/dir/"+from+".gif","r"),
"type":"image/gif"]);
}
private static int nest = 0;
#ifdef MODULE_LEVEL_SECURITY
private mapping misc_cache=([]);
int|mapping check_security(function a, object id, void|int slevel)
{
array level;
array seclevels;
|
2028af | 1997-07-07 | Henrik Grubbström (Grubba) | | int ip_ok = 0;
|
12a9c5 | 1997-08-11 | Henrik Grubbström (Grubba) | | int auth_ok = 0;
|
193535 | 1997-04-28 | Henrik Grubbström (Grubba) | |
|
14179b | 1997-01-29 | Per Hedbor | | if(!(seclevels = misc_cache[ a ]))
misc_cache[ a ] = seclevels = ({
function_object(a)->query_seclevels(),
|
85a2e5 | 1997-06-23 | Per Hedbor | | function_object(a)->query("_seclvl"),
function_object(a)->query("_sec_group")
|
14179b | 1997-01-29 | Per Hedbor | | });
if(slevel && (seclevels[1] > slevel))
return 1;
if(!sizeof(seclevels[0]))
return 0;
|
2028af | 1997-07-07 | Henrik Grubbström (Grubba) | | catch {
foreach(seclevels[0], level) {
|
cc6d7c | 1997-07-22 | Henrik Grubbström (Grubba) | | switch(level[0]) {
case MOD_ALLOW:
|
2028af | 1997-07-07 | Henrik Grubbström (Grubba) | | if(level[1](id->remoteaddr)) {
|
cc6d7c | 1997-07-22 | Henrik Grubbström (Grubba) | | ip_ok = ~0;
|
2028af | 1997-07-07 | Henrik Grubbström (Grubba) | | } else {
|
cc6d7c | 1997-07-22 | Henrik Grubbström (Grubba) | | ip_ok |= 1;
|
2028af | 1997-07-07 | Henrik Grubbström (Grubba) | | }
|
12a9c5 | 1997-08-11 | Henrik Grubbström (Grubba) | | break;
|
14179b | 1997-01-29 | Per Hedbor | |
|
cc6d7c | 1997-07-22 | Henrik Grubbström (Grubba) | | case MOD_DENY:
|
a75a32 | 1997-05-14 | Henrik Grubbström (Grubba) | | if(level[1](id->remoteaddr))
return http_low_answer(403, "<h2>Access forbidden</h2>");
|
12a9c5 | 1997-08-11 | Henrik Grubbström (Grubba) | | break;
|
14179b | 1997-01-29 | Per Hedbor | |
|
cc6d7c | 1997-07-22 | Henrik Grubbström (Grubba) | | case MOD_USER:
|
12a9c5 | 1997-08-11 | Henrik Grubbström (Grubba) | | if(id->auth && id->auth[0] && level[1](id->auth[1])) {
auth_ok = ~0;
} else {
auth_ok |= 1;
}
break;
|
14179b | 1997-01-29 | Per Hedbor | |
|
cc6d7c | 1997-07-22 | Henrik Grubbström (Grubba) | | case MOD_PROXY_USER:
|
12a9c5 | 1997-08-11 | Henrik Grubbström (Grubba) | | if (ip_ok != 1) {
if(id->misc->proxyauth && id->misc->proxyauth[0] &&
level[1](id->misc->proxyauth[1])) return 0;
return http_proxy_auth_required(seclevels[2]);
} else {
return(1);
}
|
14179b | 1997-01-29 | Per Hedbor | | }
|
2028af | 1997-07-07 | Henrik Grubbström (Grubba) | | }
|
14179b | 1997-01-29 | Per Hedbor | | };
|
12a9c5 | 1997-08-11 | Henrik Grubbström (Grubba) | | if (ip_ok == 1) {
return(1);
} else {
if (auth_ok == 1) {
return(http_auth_failed(seclevels[2]));
} else {
return(0);
}
|
2028af | 1997-07-07 | Henrik Grubbström (Grubba) | | }
|
14179b | 1997-01-29 | Per Hedbor | | }
#endif
|
8cc31b | 1997-10-12 | Henrik Grubbström (Grubba) | | void invalidate_cache()
|
14179b | 1997-01-29 | Per Hedbor | | {
last_module_cache = 0;
filter_module_cache = 0;
first_module_cache = 0;
url_module_cache = 0;
location_module_cache = 0;
logger_module_cache = 0;
extension_module_cache = ([]);
file_extension_module_cache = ([]);
|
ae32d0 | 1998-03-23 | David Hedbor | | provider_module_cache = ([]);
|
14179b | 1997-01-29 | Per Hedbor | | #ifdef MODULE_LEVEL_SECURITY
if(misc_cache)
misc_cache = ([ ]);
#endif
}
|
fc9433 | 1997-10-25 | Per Hedbor | |
string draw_saturation_bar(int hue,int brightness, int where)
{
object bar=Image.image(30,256);
for(int i=0;i<128;i++)
{
int j = i*2;
bar->line(0,j,29,j,@hsv_to_rgb(hue,255-j,brightness));
bar->line(0,j+1,29,j+1,@hsv_to_rgb(hue,255-j,brightness));
}
where = 255-where;
bar->line(0,where,29,where, 255,255,255);
return bar->togif(255,255,255);
}
|
14179b | 1997-01-29 | Per Hedbor | |
private mapping internal_roxen_image(string from)
{
sscanf(from, "%s.gif", from);
sscanf(from, "%s.jpg", from);
|
fc9433 | 1997-10-25 | Per Hedbor | |
|
14179b | 1997-01-29 | Per Hedbor | |
|
fc9433 | 1997-10-25 | Per Hedbor | | from -= ".";
|
4154e6 | 1997-08-20 | Johan Schön | |
|
fc9433 | 1997-10-25 | Per Hedbor | |
int hue,bright,w;
if(sscanf(from, "%*s:%d,%d,%d", hue, bright,w)==4)
return http_string_answer(draw_saturation_bar(hue,bright,w),"image/gif");
|
4154e6 | 1997-08-20 | Johan Schön | | if(object f=open("roxen-images/"+from+".gif", "r"))
return (["file":f,"type":"image/gif"]);
else
return (["file":open("roxen-images/"+from+".jpg", "r"),"type":"image/jpeg"]);
|
14179b | 1997-01-29 | Per Hedbor | | }
mapping (mixed:function|int) locks = ([]);
public mapping|int get_file(object id, int|void no_magic);
#ifdef THREADS
|
e5bad2 | 1998-02-10 | Per Hedbor | |
|
e6aff0 | 1997-05-25 | Henrik Grubbström (Grubba) | |
|
55a89e | 1997-09-14 | Per Hedbor | | mapping locked = ([]), thread_safe = ([]);
|
14179b | 1997-01-29 | Per Hedbor | | object _lock(object|function f)
{
object key;
|
1fab6f | 1997-09-03 | Henrik Grubbström (Grubba) | | function|int l;
|
55a89e | 1997-09-14 | Per Hedbor | |
|
1fab6f | 1997-09-03 | Henrik Grubbström (Grubba) | | if (functionp(f)) {
f = function_object(f);
}
|
55a89e | 1997-09-14 | Per Hedbor | | if (l = locks[f])
{
if (l != -1)
{
|
1fab6f | 1997-09-03 | Henrik Grubbström (Grubba) | |
|
55a89e | 1997-09-14 | Per Hedbor | | catch
{
|
1fab6f | 1997-09-03 | Henrik Grubbström (Grubba) | |
|
55a89e | 1997-09-14 | Per Hedbor | | locked[f]++;
|
1fab6f | 1997-09-03 | Henrik Grubbström (Grubba) | | key = l();
};
|
55a89e | 1997-09-14 | Per Hedbor | | } else
thread_safe[f]++;
|
1fab6f | 1997-09-03 | Henrik Grubbström (Grubba) | | } else if (f->thread_safe) {
locks[f]=-1;
|
55a89e | 1997-09-14 | Per Hedbor | | thread_safe[f]++;
|
14179b | 1997-01-29 | Per Hedbor | | } else {
|
55a89e | 1997-09-14 | Per Hedbor | | if (!locks[f])
{
|
1fab6f | 1997-09-03 | Henrik Grubbström (Grubba) | |
|
e5bad2 | 1998-02-10 | Per Hedbor | | l = Thread.Mutex()->lock;
|
1fab6f | 1997-09-03 | Henrik Grubbström (Grubba) | | if (!locks[f]) {
locks[f]=l;
}
|
14179b | 1997-01-29 | Per Hedbor | | }
|
1fab6f | 1997-09-03 | Henrik Grubbström (Grubba) | |
|
55a89e | 1997-09-14 | Per Hedbor | | locked[f]++;
|
1fab6f | 1997-09-03 | Henrik Grubbström (Grubba) | | key = l();
|
b1fca0 | 1996-11-12 | Per Hedbor | | }
|
14179b | 1997-01-29 | Per Hedbor | | return key;
|
b1fca0 | 1996-11-12 | Per Hedbor | | }
|
14179b | 1997-01-29 | Per Hedbor | | #define LOCK(X) key=_lock(X)
|
d7b087 | 1997-08-31 | Per Hedbor | | #define UNLOCK() do{key=0;}while(0)
|
14179b | 1997-01-29 | Per Hedbor | | #else
#define LOCK(X)
|
c95bd5 | 1998-01-30 | Henrik Grubbström (Grubba) | | #define UNLOCK()
|
14179b | 1997-01-29 | Per Hedbor | | #endif
|
41d0f9 | 1998-02-20 | Per Hedbor | |
#define TRACE_ENTER(A,B) do{if(id->misc->trace_enter)id->misc->trace_enter((A),(B));}while(0)
#define TRACE_LEAVE(A) do{if(id->misc->trace_leave)id->misc->trace_leave((A));}while(0)
|
a1334f | 1998-02-20 | Mirar (Pontus Hagland) | | string examine_return_mapping(mapping m)
{
string res;
if (m->extra_heads)
m->extra_heads=mkmapping(Array.map(indices(m->extra_heads),
lower_case),
values(m->extra_heads));
else
m->extra_heads=([]);
switch (m->error||200)
{
case 302:
if (m->extra_heads &&
(m->extra_heads->location))
res
= "Returned <i><b>redirect</b></i>;<br> to "
"<a href="+(m->extra_heads->location)+">"
"<font color=darkgreen><tt>"+
(m->extra_heads->location)+
"</tt></font></a><br>";
else
res = "Returned redirect, but no location header\n";
break;
case 401:
if (m->extra_heads["www-authenticate"])
res
= "Returned <i><b>authentication failed</b></i>;"
"<br> <tt>"+
m->extra_heads["www-authenticate"]+"</tt><br>";
else
res
= "Returned <i><b>authentication failed</b></i>.<br>";
break;
case 200:
res
= "Returned <i><b>ok</b></i><br>\n";
break;
default:
res
= "Returned <b><tt>"+m->error+"</tt></b>.<br>\n";
}
if (!zero_type(m->len))
if (m->len<0)
res+="No data ";
else
res+=m->len+" bytes ";
else if (stringp(m->data))
res+=strlen(m->data)+" bytes";
else if (objectp(m->file))
if (catch {
array a=m->file->stat();
res+=(a[1]-m->file->tell())+" bytes ";
}) res+="? bytes";
if (m->data) res+=" (static)";
else if (m->file) res+="(open file)";
if (stringp(m->extra_heads["http-content-type"]))
res+=" of <tt>"+m->type+"</tt>\n";
else if (stringp(m->type))
res+=" of <tt>"+m->type+"</tt>\n";
res+="<br>";
return res;
}
|
f6d62d | 1997-03-26 | Per Hedbor | | mapping|int low_get_file(object id, int|void no_magic)
|
14179b | 1997-01-29 | Per Hedbor | | {
#ifdef MODULE_LEVEL_SECURITY
int slevel;
#endif
#ifdef THREADS
object key;
#endif
|
41d0f9 | 1998-02-20 | Per Hedbor | | TRACE_ENTER("Request for "+id->not_query, 0);
|
14179b | 1997-01-29 | Per Hedbor | |
string file=id->not_query;
string loc;
function funp;
mixed tmp, tmp2;
mapping|object fid;
|
41d0f9 | 1998-02-20 | Per Hedbor | |
|
14179b | 1997-01-29 | Per Hedbor | | if(!no_magic)
{
#ifndef NO_INTERNAL_HACK
|
09497b | 1997-08-18 | Henrik Grubbström (Grubba) | | if(sizeof(id->not_query) && (id->not_query[0] == '/') &&
sscanf(id->not_query, "%*s/internal-%s", loc))
|
14179b | 1997-01-29 | Per Hedbor | | {
if(sscanf(loc, "gopher-%[^/]", loc))
|
41d0f9 | 1998-02-20 | Per Hedbor | | {
TRACE_LEAVE("Magic internal gopher image");
|
14179b | 1997-01-29 | Per Hedbor | | return internal_gopher_image(loc);
|
41d0f9 | 1998-02-20 | Per Hedbor | | }
|
14179b | 1997-01-29 | Per Hedbor | | if(sscanf(loc, "spinner-%[^/]", loc)
||sscanf(loc, "roxen-%[^/]", loc))
|
41d0f9 | 1998-02-20 | Per Hedbor | | {
TRACE_LEAVE("Magic internal roxen image");
|
14179b | 1997-01-29 | Per Hedbor | | return internal_roxen_image(loc);
|
41d0f9 | 1998-02-20 | Per Hedbor | | }
|
14179b | 1997-01-29 | Per Hedbor | | }
#endif
if(id->prestate->diract && dir_module)
{
LOCK(dir_module);
|
41d0f9 | 1998-02-20 | Per Hedbor | | TRACE_ENTER("Directory module", dir_module);
|
14179b | 1997-01-29 | Per Hedbor | | tmp = dir_module->parse_directory(id);
UNLOCK();
|
41d0f9 | 1998-02-20 | Per Hedbor | | if(mappingp(tmp))
{
TRACE_LEAVE("");
TRACE_LEAVE("Returning data");
return tmp;
}
TRACE_LEAVE("");
|
14179b | 1997-01-29 | Per Hedbor | | }
}
#ifdef URL_MODULES
|
f12890 | 1997-08-15 | Henrik Grubbström (Grubba) | |
|
14179b | 1997-01-29 | Per Hedbor | | foreach(url_modules(id), funp)
{
LOCK(funp);
|
41d0f9 | 1998-02-20 | Per Hedbor | | TRACE_ENTER("URL Module", funp);
|
14179b | 1997-01-29 | Per Hedbor | | tmp=funp( id, file );
UNLOCK();
|
f12890 | 1997-08-15 | Henrik Grubbström (Grubba) | | if(mappingp(tmp))
|
41d0f9 | 1998-02-20 | Per Hedbor | | {
TRACE_LEAVE("");
TRACE_LEAVE("Returning data");
|
f12890 | 1997-08-15 | Henrik Grubbström (Grubba) | | return tmp;
|
41d0f9 | 1998-02-20 | Per Hedbor | | }
|
f12890 | 1997-08-15 | Henrik Grubbström (Grubba) | | if(objectp( tmp ))
|
14179b | 1997-01-29 | Per Hedbor | | {
array err;
nest ++;
err = catch {
if( nest < 20 )
|
2dd163 | 1997-08-06 | Marcus Comstedt | | tmp = (id->conf || this_object())->low_get_file( tmp, no_magic );
|
14179b | 1997-01-29 | Per Hedbor | | else
|
41d0f9 | 1998-02-20 | Per Hedbor | | {
TRACE_LEAVE("Too deep recursion");
|
14179b | 1997-01-29 | Per Hedbor | | error("Too deep recursion in roxen::get_file() while mapping "
+file+".\n");
|
41d0f9 | 1998-02-20 | Per Hedbor | | }
|
14179b | 1997-01-29 | Per Hedbor | | };
nest = 0;
|
41d0f9 | 1998-02-20 | Per Hedbor | | if(err) throw(err);
TRACE_LEAVE("");
TRACE_LEAVE("Returned data");
|
14179b | 1997-01-29 | Per Hedbor | | return tmp;
}
|
41d0f9 | 1998-02-20 | Per Hedbor | | TRACE_LEAVE("");
|
14179b | 1997-01-29 | Per Hedbor | | }
#endif
#ifdef EXTENSION_MODULES
if(tmp=extension_modules(loc=extension(file), id))
{
foreach(tmp, funp)
{
|
41d0f9 | 1998-02-20 | Per Hedbor | | TRACE_ENTER("Extension Module ["+loc+"] ", funp);
|
14179b | 1997-01-29 | Per Hedbor | | LOCK(funp);
tmp=funp(loc, id);
UNLOCK();
if(tmp)
{
if(!objectp(tmp))
|
41d0f9 | 1998-02-20 | Per Hedbor | | {
TRACE_LEAVE("Returing data");
|
14179b | 1997-01-29 | Per Hedbor | | return tmp;
|
41d0f9 | 1998-02-20 | Per Hedbor | | }
|
14179b | 1997-01-29 | Per Hedbor | | fid = tmp;
#ifdef MODULE_LEVEL_SECURITY
slevel = function_object(funp)->query("_seclvl");
|
41d0f9 | 1998-02-20 | Per Hedbor | | #endif
TRACE_LEAVE("Retured open filedescriptor."
#ifdef MODULE_LEVEL_SECURITY
+(slevel != id->misc->seclevel?
". The security level is now "+slevel:"")
#endif
);
#ifdef MODULE_LEVEL_SECURITY
|
28d38d | 1997-03-12 | Per Hedbor | | id->misc->seclevel = slevel;
|
14179b | 1997-01-29 | Per Hedbor | | #endif
break;
|
41d0f9 | 1998-02-20 | Per Hedbor | | } else
TRACE_LEAVE("");
|
14179b | 1997-01-29 | Per Hedbor | | }
}
#endif
foreach(location_modules(id), tmp)
{
loc = tmp[0];
if(!search(file, loc))
{
|
41d0f9 | 1998-02-20 | Per Hedbor | | TRACE_ENTER("Location Module ["+loc+"] ", tmp[1]);
|
df8d71 | 1998-02-27 | Per Hedbor | | #ifdef MODULE_LEVEL_SECURITY
|
14179b | 1997-01-29 | Per Hedbor | | if(tmp2 = check_security(tmp[1], id, slevel))
if(intp(tmp2))
{
|
41d0f9 | 1998-02-20 | Per Hedbor | | TRACE_LEAVE("Persmission to access module denied");
|
14179b | 1997-01-29 | Per Hedbor | | continue;
} else {
|
41d0f9 | 1998-02-20 | Per Hedbor | | TRACE_LEAVE("Request denied.");
|
14179b | 1997-01-29 | Per Hedbor | | return tmp2;
}
#endif
|
d9624c | 1998-04-03 | Henrik Grubbström (Grubba) | | TRACE_ENTER("Calling find_file()...", 0);
|
14179b | 1997-01-29 | Per Hedbor | | LOCK(tmp[1]);
fid=tmp[1]( file[ strlen(loc) ..] + id->extra_extension, id);
UNLOCK();
|
d9624c | 1998-04-03 | Henrik Grubbström (Grubba) | | TRACE_LEAVE(sprintf("find_file has returned %O", fid));
|
14179b | 1997-01-29 | Per Hedbor | | if(fid)
{
id->virtfile = loc;
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
14179b | 1997-01-29 | Per Hedbor | | if(mappingp(fid))
|
41d0f9 | 1998-02-20 | Per Hedbor | | {
|
a1334f | 1998-02-20 | Mirar (Pontus Hagland) | | TRACE_LEAVE("");
TRACE_LEAVE(examine_return_mapping(fid));
|
14179b | 1997-01-29 | Per Hedbor | | return fid;
|
41d0f9 | 1998-02-20 | Per Hedbor | | }
|
14179b | 1997-01-29 | Per Hedbor | | else
{
#ifdef MODULE_LEVEL_SECURITY
|
df8d71 | 1998-02-27 | Per Hedbor | | int oslevel = slevel;
|
14179b | 1997-01-29 | Per Hedbor | | slevel = misc_cache[ tmp[1] ][1];
#endif
|
41d0f9 | 1998-02-20 | Per Hedbor | | if(objectp(fid))
TRACE_LEAVE("Returned open file"
#ifdef MODULE_LEVEL_SECURITY
+(slevel != oslevel?
". The security level is now "+slevel:"")
#endif
+".");
else
TRACE_LEAVE("Returned directory indicator"
#ifdef MODULE_LEVEL_SECURITY
+(oslevel != slevel?
". The security level is now "+slevel:"")
#endif
);
|
14179b | 1997-01-29 | Per Hedbor | | break;
}
|
41d0f9 | 1998-02-20 | Per Hedbor | | } else
TRACE_LEAVE("");
|
14179b | 1997-01-29 | Per Hedbor | | } else if(strlen(loc)-1==strlen(file)) {
if(file+"/" == loc)
|
41d0f9 | 1998-02-20 | Per Hedbor | | {
TRACE_ENTER("Automatic redirect to location module", tmp[1]);
TRACE_LEAVE("Returning data");
|
14179b | 1997-01-29 | Per Hedbor | | return http_redirect(id->not_query + "/", id);
|
41d0f9 | 1998-02-20 | Per Hedbor | | }
|
14179b | 1997-01-29 | Per Hedbor | | }
}
if(fid == -1)
{
|
41d0f9 | 1998-02-20 | Per Hedbor | | if(no_magic)
{
TRACE_LEAVE("No magic requested. Returning -1");
return -1;
}
|
14179b | 1997-01-29 | Per Hedbor | | if(dir_module)
{
LOCK(dir_module);
|
41d0f9 | 1998-02-20 | Per Hedbor | | TRACE_ENTER("Directory module", dir_module);
|
14179b | 1997-01-29 | Per Hedbor | | fid = dir_module->parse_directory(id);
UNLOCK();
}
else
|
41d0f9 | 1998-02-20 | Per Hedbor | | {
TRACE_LEAVE("No directory module. Returning 'no such file'");
|
14179b | 1997-01-29 | Per Hedbor | | return 0;
|
41d0f9 | 1998-02-20 | Per Hedbor | | }
if(mappingp(fid))
{
TRACE_LEAVE("Returned data");
return (mapping)fid;
}
|
14179b | 1997-01-29 | Per Hedbor | | }
if(objectp(fid)&&
(tmp=file_extension_modules(loc=extension(id->not_query), id)))
foreach(tmp, funp)
{
|
41d0f9 | 1998-02-20 | Per Hedbor | | TRACE_ENTER("Extension module", funp);
|
14179b | 1997-01-29 | Per Hedbor | | #ifdef MODULE_LEVEL_SECURITY
if(tmp=check_security(funp, id, slevel))
if(intp(tmp))
{
|
41d0f9 | 1998-02-20 | Per Hedbor | | TRACE_LEAVE("Permission to access module denied");
|
14179b | 1997-01-29 | Per Hedbor | | continue;
}
else
|
41d0f9 | 1998-02-20 | Per Hedbor | | {
TRACE_LEAVE("");
TRACE_LEAVE("Permission denied");
|
14179b | 1997-01-29 | Per Hedbor | | return tmp;
|
41d0f9 | 1998-02-20 | Per Hedbor | | }
|
14179b | 1997-01-29 | Per Hedbor | | #endif
LOCK(funp);
tmp=funp(fid, loc, id);
UNLOCK();
if(tmp)
{
if(!objectp(tmp))
|
41d0f9 | 1998-02-20 | Per Hedbor | | {
TRACE_LEAVE("");
TRACE_LEAVE("Returning data");
|
14179b | 1997-01-29 | Per Hedbor | | return tmp;
|
41d0f9 | 1998-02-20 | Per Hedbor | | }
|
14179b | 1997-01-29 | Per Hedbor | | if(fid)
destruct(fid);
|
41d0f9 | 1998-02-20 | Per Hedbor | | TRACE_LEAVE("Returned new open file");
|
14179b | 1997-01-29 | Per Hedbor | | fid = tmp;
break;
|
41d0f9 | 1998-02-20 | Per Hedbor | | } else
TRACE_LEAVE("");
|
14179b | 1997-01-29 | Per Hedbor | | }
if(objectp(fid))
{
if(stringp(id->extension))
id->not_query += id->extension;
|
41d0f9 | 1998-02-20 | Per Hedbor | |
TRACE_ENTER("Content-type mapping module", types_module);
|
14179b | 1997-01-29 | Per Hedbor | | tmp=type_from_filename(id->not_query, 1);
|
41d0f9 | 1998-02-20 | Per Hedbor | | TRACE_LEAVE(tmp?"Returned type "+tmp[0]+" "+tmp[1]:"Missing");
|
14179b | 1997-01-29 | Per Hedbor | | if(tmp)
|
41d0f9 | 1998-02-20 | Per Hedbor | | {
TRACE_LEAVE("");
|
14179b | 1997-01-29 | Per Hedbor | | return ([ "file":fid, "type":tmp[0], "encoding":tmp[1] ]);
|
41d0f9 | 1998-02-20 | Per Hedbor | | }
TRACE_LEAVE("");
|
14179b | 1997-01-29 | Per Hedbor | | return ([ "file":fid, ]);
}
|
41d0f9 | 1998-02-20 | Per Hedbor | | if(!fid)
TRACE_LEAVE("Returning 'no such file'");
else
TRACE_LEAVE("Returning data");
|
14179b | 1997-01-29 | Per Hedbor | | return fid;
}
mixed get_file(object id, int|void no_magic)
{
mixed res, res2;
function tmp;
res = low_get_file(id, no_magic);
foreach(filter_modules(id), tmp)
|
41d0f9 | 1998-02-20 | Per Hedbor | | {
TRACE_ENTER("Filter module", tmp);
|
14179b | 1997-01-29 | Per Hedbor | | if(res2=tmp(res,id))
{
if(res && res->file && (res2->file != res->file))
destruct(res->file);
|
41d0f9 | 1998-02-20 | Per Hedbor | | TRACE_LEAVE("Rewrote result");
|
14179b | 1997-01-29 | Per Hedbor | | res=res2;
|
41d0f9 | 1998-02-20 | Per Hedbor | | } else
TRACE_LEAVE("");
}
|
14179b | 1997-01-29 | Per Hedbor | | return res;
}
public array find_dir(string file, object id)
{
string loc;
array dir = ({ }), d, tmp;
|
41d0f9 | 1998-02-20 | Per Hedbor | | TRACE_ENTER("List directory "+file, 0);
|
14179b | 1997-01-29 | Per Hedbor | | file=replace(file, "//", "/");
|
193535 | 1997-04-28 | Henrik Grubbström (Grubba) | | if(file[0] != '/')
file = "/" + file;
|
f12890 | 1997-08-15 | Henrik Grubbström (Grubba) | | #ifdef URL_MODULES
|
fc0e5d | 1997-08-26 | Henrik Grubbström (Grubba) | | #ifdef THREADS
object key;
#endif
|
f12890 | 1997-08-15 | Henrik Grubbström (Grubba) | |
foreach(url_modules(id), function funp)
{
string of = id->not_query;
id->not_query = file;
LOCK(funp);
|
41d0f9 | 1998-02-20 | Per Hedbor | | TRACE_ENTER("URL module", funp);
|
f12890 | 1997-08-15 | Henrik Grubbström (Grubba) | | tmp=funp( id, file );
UNLOCK();
if(mappingp( tmp ))
{
id->not_query=of;
|
41d0f9 | 1998-02-20 | Per Hedbor | | TRACE_LEAVE("Returned 'no thanks'");
TRACE_LEAVE("");
|
f12890 | 1997-08-15 | Henrik Grubbström (Grubba) | | return 0;
}
if(objectp( tmp ))
{
array err;
nest ++;
|
41d0f9 | 1998-02-20 | Per Hedbor | | TRACE_LEAVE("Recursing");
|
f12890 | 1997-08-15 | Henrik Grubbström (Grubba) | | file = id->not_query;
err = catch {
if( nest < 20 )
tmp = (id->conf || this_object())->find_dir( file, id );
else
error("Too deep recursion in roxen::find_dir() while mapping "
+file+".\n");
};
nest = 0;
|
41d0f9 | 1998-02-20 | Per Hedbor | | TRACE_LEAVE("");
|
f12890 | 1997-08-15 | Henrik Grubbström (Grubba) | | if(err)
throw(err);
return tmp;
}
id->not_query=of;
}
|
a86c6c | 1997-09-22 | Henrik Grubbström (Grubba) | | #endif /* URL_MODULES */
|
f12890 | 1997-08-15 | Henrik Grubbström (Grubba) | |
|
14179b | 1997-01-29 | Per Hedbor | | foreach(location_modules(id), tmp)
{
loc = tmp[0];
|
a47671 | 1997-10-20 | Henrik Grubbström (Grubba) | | if(!search(file, loc)) {
|
8fd51f | 1998-03-01 | Per Hedbor | | TRACE_ENTER("Location module", tmp[1]);
|
a78a59 | 1997-04-28 | Henrik Grubbström (Grubba) | | #ifdef MODULE_LEVEL_SECURITY
|
41d0f9 | 1998-02-20 | Per Hedbor | | if(check_security(tmp[1], id)) {
TRACE_LEAVE("Permission denied");
continue;
}
|
a78a59 | 1997-04-28 | Henrik Grubbström (Grubba) | | #endif
|
8dbe2d | 1997-05-26 | Henrik Grubbström (Grubba) | | if(d=function_object(tmp[1])->find_dir(file[strlen(loc)..], id))
|
41d0f9 | 1998-02-20 | Per Hedbor | | {
TRACE_LEAVE("Got files");
|
14179b | 1997-01-29 | Per Hedbor | | dir |= d;
|
41d0f9 | 1998-02-20 | Per Hedbor | | } else
TRACE_LEAVE("");
|
a47671 | 1997-10-20 | Henrik Grubbström (Grubba) | | } else if((search(loc, file)==0) && (loc[strlen(file)-1]=='/') &&
(loc[0]==loc[-1]) && (loc[-1]=='/') &&
|
6c67c8 | 1998-02-28 | Johan Schön | | (function_object(tmp[1])->stat_file(".", id))) {
|
a47671 | 1997-10-20 | Henrik Grubbström (Grubba) | | |
24fa08 | 1998-02-28 | Henrik Grubbström (Grubba) | | * and stat_file(".") returns non-zero.
|
a47671 | 1997-10-20 | Henrik Grubbström (Grubba) | | */
|
8fd51f | 1998-03-01 | Per Hedbor | | TRACE_ENTER("Location module", tmp[1]);
|
a47671 | 1997-10-20 | Henrik Grubbström (Grubba) | | loc=loc[strlen(file)..];
sscanf(loc, "%s/", loc);
dir += ({ loc });
|
8fd51f | 1998-03-01 | Per Hedbor | | TRACE_LEAVE("Added module mountpoint");
|
14179b | 1997-01-29 | Per Hedbor | | }
}
if(sizeof(dir))
|
41d0f9 | 1998-02-20 | Per Hedbor | | {
TRACE_LEAVE("Returning list of "+sizeof(dir)+" files");
|
14179b | 1997-01-29 | Per Hedbor | | return dir;
|
41d0f9 | 1998-02-20 | Per Hedbor | | }
TRACE_LEAVE("Returning 'no such directory'");
|
14179b | 1997-01-29 | Per Hedbor | | }
public array stat_file(string file, object id)
{
string loc;
array s, tmp;
|
41d0f9 | 1998-02-20 | Per Hedbor | | TRACE_ENTER("Stat file"+file, 0);
|
14179b | 1997-01-29 | Per Hedbor | |
file=replace(file, "//", "/");
|
f12890 | 1997-08-15 | Henrik Grubbström (Grubba) | |
#ifdef URL_MODULES
|
fc0e5d | 1997-08-26 | Henrik Grubbström (Grubba) | | #ifdef THREADS
object key;
#endif
|
f12890 | 1997-08-15 | Henrik Grubbström (Grubba) | |
foreach(url_modules(id), function funp)
{
string of = id->not_query;
id->not_query = file;
|
41d0f9 | 1998-02-20 | Per Hedbor | | TRACE_ENTER("URL module", funp);
|
f12890 | 1997-08-15 | Henrik Grubbström (Grubba) | | LOCK(funp);
tmp=funp( id, file );
UNLOCK();
if(mappingp( tmp )) {
id->not_query = of;
|
41d0f9 | 1998-02-20 | Per Hedbor | | TRACE_LEAVE("");
TRACE_LEAVE("said 'No thanks'");
|
f12890 | 1997-08-15 | Henrik Grubbström (Grubba) | | return 0;
}
if(objectp( tmp ))
{
file = id->not_query;
array err;
nest ++;
|
41d0f9 | 1998-02-20 | Per Hedbor | | TRACE_LEAVE("Recursing");
|
f12890 | 1997-08-15 | Henrik Grubbström (Grubba) | | err = catch {
if( nest < 20 )
tmp = (id->conf || this_object())->stat_file( file, id );
else
error("Too deep recursion in roxen::stat_file() while mapping "
+file+".\n");
};
nest = 0;
if(err)
throw(err);
|
8fd51f | 1998-03-01 | Per Hedbor | | TRACE_LEAVE("");
|
41d0f9 | 1998-02-20 | Per Hedbor | | TRACE_LEAVE("Returning data");
|
f12890 | 1997-08-15 | Henrik Grubbström (Grubba) | | return tmp;
}
|
8fd51f | 1998-03-01 | Per Hedbor | | TRACE_LEAVE("");
|
f12890 | 1997-08-15 | Henrik Grubbström (Grubba) | | id->not_query = of;
}
#endif
|
14179b | 1997-01-29 | Per Hedbor | |
foreach(location_modules(id), tmp)
{
loc = tmp[0];
if((file == loc) || ((file+"/")==loc))
|
41d0f9 | 1998-02-20 | Per Hedbor | | {
TRACE_ENTER("Location module", tmp[1]);
TRACE_LEAVE("Exact match");
TRACE_LEAVE("");
|
d0a47d | 1997-04-29 | Henrik Grubbström (Grubba) | | return ({ 0775, -3, 0, 0, 0, 0, 0, 0, 0, 0, 0 });
|
41d0f9 | 1998-02-20 | Per Hedbor | | }
|
14179b | 1997-01-29 | Per Hedbor | | if(!search(file, loc))
{
|
41d0f9 | 1998-02-20 | Per Hedbor | | TRACE_ENTER("Location module", tmp[1]);
|
a78a59 | 1997-04-28 | Henrik Grubbström (Grubba) | | #ifdef MODULE_LEVEL_SECURITY
|
41d0f9 | 1998-02-20 | Per Hedbor | | if(check_security(tmp[1], id)) {
|
8fd51f | 1998-03-01 | Per Hedbor | | TRACE_LEAVE("");
|
41d0f9 | 1998-02-20 | Per Hedbor | | TRACE_LEAVE("Permission denied");
continue;
}
|
a78a59 | 1997-04-28 | Henrik Grubbström (Grubba) | | #endif
|
14179b | 1997-01-29 | Per Hedbor | | if(s=function_object(tmp[1])->stat_file(file[strlen(loc)..], id))
|
41d0f9 | 1998-02-20 | Per Hedbor | | {
TRACE_LEAVE("");
TRACE_LEAVE("Stat ok");
|
14179b | 1997-01-29 | Per Hedbor | | return s;
|
41d0f9 | 1998-02-20 | Per Hedbor | | }
TRACE_LEAVE("");
|
14179b | 1997-01-29 | Per Hedbor | | }
}
|
41d0f9 | 1998-02-20 | Per Hedbor | | TRACE_LEAVE("Returning 'no such file'");
|
14179b | 1997-01-29 | Per Hedbor | | }
|
e8790b | 1998-02-19 | Per Hedbor | | class StringFile
{
string data;
int offset;
string read(int nbytes)
{
|
41d0f9 | 1998-02-20 | Per Hedbor | | string d = data[offset..offset+nbytes-1];
|
e8790b | 1998-02-19 | Per Hedbor | | offset += strlen(d);
return d;
}
void write(mixed ... args)
{
throw( ({ "File not open for write", backtrace() }) );
}
void seek(int to)
{
offset = to;
}
void create(string d)
{
data = d;
}
|
41d0f9 | 1998-02-20 | Per Hedbor | |
|
e8790b | 1998-02-19 | Per Hedbor | | }
public array open_file(string fname, string mode, object id)
{
object oc = id->conf;
string oq = id->not_query;
function funp;
mapping file;
foreach(oc->first_modules(), funp)
if(file = funp( id ))
break;
else if(id->conf != oc)
{
id->not_query = fname;
return open_file(fname, mode,id);
}
fname = id->not_query;
if(search(mode, "R")!=-1)
{
string f;
mode -= "R";
if(f = real_file(fname, id))
|
41d0f9 | 1998-02-20 | Per Hedbor | | {
|
238083 | 1998-02-22 | Per Hedbor | | werror("opening "+fname+" in raw mode.\n");
|
e8790b | 1998-02-19 | Per Hedbor | | return ({ open(f, mode), ([]) });
|
41d0f9 | 1998-02-20 | Per Hedbor | | }
|
238083 | 1998-02-22 | Per Hedbor | |
|
e8790b | 1998-02-19 | Per Hedbor | | }
if(mode=="r")
{
if(!file)
{
file = oc->get_file( id );
if(!file)
|
41d0f9 | 1998-02-20 | Per Hedbor | | foreach(oc->last_modules(), funp) if(file = funp( id ))
|
e8790b | 1998-02-19 | Per Hedbor | | break;
}
if(!mappingp(file))
{
if(id->misc->error_code)
|
41d0f9 | 1998-02-20 | Per Hedbor | | file = http_low_answer(id->misc->error_code,"Failed" );
|
238083 | 1998-02-22 | Per Hedbor | | else if(id->method!="GET"&&id->method != "HEAD"&&id->method!="POST")
|
e8790b | 1998-02-19 | Per Hedbor | | file = http_low_answer(501, "Not implemented.");
else
file=http_low_answer(404,replace(parse_rxml(query("ZNoSuchFile"),id),
({"$File", "$Me"}),
({fname,query("MyWorldLocation")})));
id->not_query = oq;
return ({ 0, file });
}
if(file->data)
{
file->file = StringFile(file->data);
m_delete(file, "data");
|
238083 | 1998-02-22 | Per Hedbor | | }
|
e8790b | 1998-02-19 | Per Hedbor | | id->not_query = oq;
return ({ file->file, file });
}
id->not_query = oq;
return ({ 0,(["error":501,"data":"Not implemented"]) });
}
|
a47671 | 1997-10-20 | Henrik Grubbström (Grubba) | | public mapping(string:array(mixed)) find_dir_stat(string file, object id)
|
a86c6c | 1997-09-22 | Henrik Grubbström (Grubba) | | {
string loc;
|
a47671 | 1997-10-20 | Henrik Grubbström (Grubba) | | mapping(string:array(mixed)) dir = ([]);
mixed d, tmp;
|
a86c6c | 1997-09-22 | Henrik Grubbström (Grubba) | |
file=replace(file, "//", "/");
if(file[0] != '/')
file = "/" + file;
#ifdef URL_MODULES
#ifdef THREADS
object key;
#endif
foreach(url_modules(id), function funp)
{
string of = id->not_query;
id->not_query = file;
LOCK(funp);
tmp=funp( id, file );
UNLOCK();
if(mappingp( tmp ))
{
id->not_query=of;
|
3510fb | 1997-11-09 | Henrik Grubbström (Grubba) | | #ifdef MODULE_DEBUG
roxen_perror(sprintf("conf->find_dir_stat(\"%s\"): url_module returned mapping:%O\n",
file, tmp));
#endif /* MODULE_DEBUG */
|
a86c6c | 1997-09-22 | Henrik Grubbström (Grubba) | | return 0;
}
if(objectp( tmp ))
{
array err;
nest ++;
file = id->not_query;
err = catch {
if( nest < 20 )
tmp = (id->conf || this_object())->find_dir_stat( file, id );
else
error("Too deep recursion in roxen::find_dir_stat() while mapping "
+file+".\n");
};
nest = 0;
if(err)
throw(err);
|
3510fb | 1997-11-09 | Henrik Grubbström (Grubba) | | #ifdef MODULE_DEBUG
roxen_perror(sprintf("conf->find_dir_stat(\"%s\"): url_module returned object:\n",
file));
#endif /* MODULE_DEBUG */
|
a86c6c | 1997-09-22 | Henrik Grubbström (Grubba) | | return tmp;
}
id->not_query=of;
}
#endif /* URL_MODULES */
foreach(location_modules(id), tmp)
{
loc = tmp[0];
|
a47671 | 1997-10-20 | Henrik Grubbström (Grubba) | |
|
a86c6c | 1997-09-22 | Henrik Grubbström (Grubba) | | if(!search(file, loc))
{
|
a47671 | 1997-10-20 | Henrik Grubbström (Grubba) | |
|
a86c6c | 1997-09-22 | Henrik Grubbström (Grubba) | | #ifdef MODULE_LEVEL_SECURITY
if(check_security(tmp[1], id)) continue;
#endif
object c = function_object(tmp[1]);
string f = file[strlen(loc)..];
if (c->find_dir_stat) {
if (d = c->find_dir_stat(f, id)) {
|
a47671 | 1997-10-20 | Henrik Grubbström (Grubba) | | dir = d | dir;
|
a86c6c | 1997-09-22 | Henrik Grubbström (Grubba) | | }
} else if(d = c->find_dir(f, id)) {
|
e5bad2 | 1998-02-10 | Per Hedbor | | dir = mkmapping(d, Array.map(d, lambda(string f, string base,
|
a47671 | 1997-10-20 | Henrik Grubbström (Grubba) | | object c, object id) {
return(c->stat_file(base + f, id));
}, f, c, id)) | dir;
|
a86c6c | 1997-09-22 | Henrik Grubbström (Grubba) | | }
|
a47671 | 1997-10-20 | Henrik Grubbström (Grubba) | | } else if(search(loc, file)==0 && loc[strlen(file)-1]=='/' &&
(loc[0]==loc[-1]) && loc[-1]=='/' &&
|
8935ad | 1998-03-30 | Johan Schön | | (function_object(tmp[1])->stat_file(".", id))) {
|
a47671 | 1997-10-20 | Henrik Grubbström (Grubba) | | |
8935ad | 1998-03-30 | Johan Schön | | * and stat_file(".") returns non-zero.
|
a47671 | 1997-10-20 | Henrik Grubbström (Grubba) | | */
loc=loc[strlen(file)..];
sscanf(loc, "%s/", loc);
if (!dir[loc]) {
dir[loc] = ({ 0775, -3, 0, 0, 0, 0, 0, 0, 0, 0, 0 });
|
a86c6c | 1997-09-22 | Henrik Grubbström (Grubba) | | }
}
}
if(sizeof(dir))
return dir;
}
|
14179b | 1997-01-29 | Per Hedbor | |
public array access(string file, object id)
{
string loc;
array s, tmp;
file=replace(file, "//", "/");
foreach(location_modules(id), tmp)
{
loc = tmp[0];
if((file+"/")==loc)
return file+="/";
if(!search(file, loc))
{
#ifdef MODULE_LEVEL_SECURITY
if(check_security(tmp[1], id)) continue;
#endif
if(s=function_object(tmp[1])->access(file[strlen(loc)..], id))
return s;
}
}
}
public string real_file(string file, object id)
{
string loc;
string s;
array tmp;
file=replace(file, "//", "/");
if(!id) error("No id passed to real_file");
foreach(location_modules(id), tmp)
{
loc = tmp[0];
if(!search(file, loc))
{
#ifdef MODULE_LEVEL_SECURITY
if(check_security(tmp[1], id)) continue;
#endif
|
62eac8 | 1997-10-03 | Henrik Grubbström (Grubba) | |
|
14179b | 1997-01-29 | Per Hedbor | | if(s=function_object(tmp[1])->real_file(file[strlen(loc)..1000000], id))
return s;
}
}
}
public mixed try_get_file(string s, object id, int|void status, int|void nocache)
{
string res, q;
object fake_id;
mapping m;
if(objectp(id))
fake_id = id->clone_me();
else
error("No ID passed to 'try_get_file'\n");
if(!id->pragma["no-cache"] )
if(res = cache_lookup("file:"+id->conf->name, s))
return res;
if(sscanf(s, "%s?%s", s, q))
{
string v, name, value;
foreach(q/"&", v)
|
4bf5f9 | 1997-03-13 | David KÃ¥gedal | | if(sscanf(v, "%s=%s", name, value))
|
14179b | 1997-01-29 | Per Hedbor | | fake_id->variables[http_decode_string(name)]=value;
fake_id->query=q;
}
fake_id->raw_url=s;
fake_id->not_query=s;
fake_id->misc->internal_get=1;
if(!(m = get_file(fake_id)))
{
fake_id->end();
return 0;
}
fake_id->end();
|
3510fb | 1997-11-09 | Henrik Grubbström (Grubba) | | if (!(< 0, 200, 201, 202, 203 >)[m->error]) return 0;
|
14179b | 1997-01-29 | Per Hedbor | |
|
3510fb | 1997-11-09 | Henrik Grubbström (Grubba) | | if(status) return 1;
|
14179b | 1997-01-29 | Per Hedbor | | #ifdef COMPAT
if(m["string"]) res = m["string"];
|
d9624c | 1998-04-03 | Henrik Grubbström (Grubba) | | else
|
14179b | 1997-01-29 | Per Hedbor | | #endif
|
d9624c | 1998-04-03 | Henrik Grubbström (Grubba) | | if(m->data) res = m->data;
|
14179b | 1997-01-29 | Per Hedbor | | else res="";
m->data = 0;
if(m->file)
{
|
3a4d7e | 1997-09-03 | Per Hedbor | | res += m->file->read();
|
14179b | 1997-01-29 | Per Hedbor | | destruct(m->file);
m->file = 0;
}
if(m->raw)
{
res -= "\r";
if(!sscanf(res, "%*s\n\n%s", res))
sscanf(res, "%*s\n%s", res);
}
cache_set("file:"+id->conf->name, s, res);
return res;
}
public int is_file(string what, object id)
{
return !!stat_file(what, id);
}
mapping (object:array) open_ports = ([]);
|
4f4bc1 | 1998-02-04 | Per Hedbor | | int ports_changed = 1;
|
14179b | 1997-01-29 | Per Hedbor | | void start(int num)
{
|
eb7a4f | 1997-08-25 | Henrik Grubbström (Grubba) | | array port;
|
14179b | 1997-01-29 | Per Hedbor | | int err=0;
object lf;
mapping new=([]), o2;
parse_log_formats();
init_log_file();
|
4f4bc1 | 1998-02-04 | Per Hedbor | |
if(ports_changed)
{
ports_changed=0;
perror("Opening ports for "+query_name()+"... ");
foreach(query("Ports"), port ) {
int already_open;
foreach(values(open_ports), array op)
if(equal(op,port)) { already_open=1;break; }
if(already_open) continue;
array old = port;
mixed erro;
erro = catch {
array tmp;
function rp;
object o;
|
14179b | 1997-01-29 | Per Hedbor | |
|
4f4bc1 | 1998-02-04 | Per Hedbor | | if ((< "ssl", "ssleay" >)[port[1]]) {
report_warning("Obsolete SSL protocol-module \""+port[1]+"\".\n"
"Converted to SSL3.\n");
port[1] = "ssl3";
}
perror(port[0]+" "+port[2]+" ("+port[1]+")... ");
if(rp = ((object)("protocols/"+port[1]))->real_port) {
if(tmp = rp(port, this_object()))
port = tmp;
}
object privs;
if(port[0] < 1024)
privs = Privs("Opening listen port below 1024");
if(!(o=create_listen_socket(port[0], this, port[2],
(program)("protocols/"+port[1]))))
{
report_error("I failed to open the port "+old[0]+" at "+old[2]+
" ("+old[1]+")\n");
err++;
} else
open_ports[o]=old;
|
ddf7e6 | 1998-02-24 | Henrik Grubbström (Grubba) | | if (privs) {
destruct(privs);
}
|
4f4bc1 | 1998-02-04 | Per Hedbor | | };
if(erro) {
report_error("Failed to open port "+old[0]+" at "+old[2]+
" ("+old[1]+"): "+
(stringp(erro)?erro:describe_backtrace(erro)));
|
eb7a4f | 1997-08-25 | Henrik Grubbström (Grubba) | | }
|
4f4bc1 | 1998-02-04 | Per Hedbor | | perror("\n");
|
14179b | 1997-01-29 | Per Hedbor | | }
}
if(!num && sizeof(query("Ports")))
{
if(err == sizeof(query("Ports")))
{
report_error("No ports available for "+name+"\n"
"Tried:\n"
"Port Protocol IP-Number \n"
"---------------------------\n"
|
e5bad2 | 1998-02-10 | Per Hedbor | | + Array.map(query("Ports"), lambda(array p) {
|
14179b | 1997-01-29 | Per Hedbor | | return sprintf("%5d %-10s %-20s\n", @p);
})*"");
}
}
}
void save(int|void all)
{
mapping mod;
if(all)
{
store("spider.lpc#0", variables, 0, this);
start(2);
}
foreach(values(modules), mod)
{
if(mod->enabled)
{
store(mod->sname+"#0", mod->master->query(), 0, this);
mod->enabled->start(2, this);
} else if(mod->copies) {
int i;
foreach(indices(mod->copies), i)
{
store(mod->sname+"#"+i, mod->copies[i]->query(), 0, this);
mod->copies[i]->start(2, this);
}
}
}
|
8cc31b | 1997-10-12 | Henrik Grubbström (Grubba) | | invalidate_cache();
|
14179b | 1997-01-29 | Per Hedbor | | }
int save_one( object o )
{
mapping mod;
if(!o)
{
store("spider#0", variables, 0, this);
start(2);
return 1;
}
foreach(values(modules), mod)
{
if( mod->enabled == o)
{
store(mod->sname+"#0", o->query(), 0, this);
o->start(2, this);
|
8cc31b | 1997-10-12 | Henrik Grubbström (Grubba) | | invalidate_cache();
|
14179b | 1997-01-29 | Per Hedbor | | return 1;
} else if(mod->copies) {
int i;
foreach(indices(mod->copies), i)
{
if(mod->copies[i] == o)
{
store(mod->sname+"#"+i, o->query(), 0, this);
o->start(2, this);
|
8cc31b | 1997-10-12 | Henrik Grubbström (Grubba) | | invalidate_cache();
|
14179b | 1997-01-29 | Per Hedbor | | return 1;
}
}
}
}
}
mapping _hooks=([ ]);
void hooks_for( string modname, object mod )
{
array hook;
if(_hooks[modname])
{
#ifdef MODULE_DEBUG
perror("Module hooks...");
#endif
foreach(_hooks[modname], hook)
hook[0]( @hook[1], mod );
}
}
int unload_module( string modname );
int load_module( string modname );
object enable_module( string modname )
{
string id;
mapping module;
mapping enabled_modules;
roxen->current_configuration = this_object();
modname = replace(modname, ".lpc#","#");
sscanf(modname, "%s#%s", modname, id );
module = modules[ modname ];
if(!module)
{
load_module(modname);
module = modules[ modname ];
}
|
ae32d0 | 1998-03-23 | David Hedbor | | #if constant(gethrtime)
|
7f0008 | 1998-03-20 | Per Hedbor | | int start_time = gethrtime();
|
ae32d0 | 1998-03-23 | David Hedbor | | #endif
|
14179b | 1997-01-29 | Per Hedbor | | if( module )
{
object me;
mapping tmp;
int pr;
|
3bbda8 | 1997-06-11 | Henrik Grubbström (Grubba) | | array err;
|
14179b | 1997-01-29 | Per Hedbor | |
#ifdef MODULE_DEBUG
|
7f0008 | 1998-03-20 | Per Hedbor | | perror("Enabling "+module->name+" # "+id+" ... ");
|
14179b | 1997-01-29 | Per Hedbor | | #endif
if(module->copies)
{
|
3bbda8 | 1997-06-11 | Henrik Grubbström (Grubba) | | if (err = catch(me = module["program"]())) {
report_error("Couldn't clone module \"" + module->name + "\"\n" +
describe_backtrace(err));
if (module->copies[id]) {
#ifdef MODULE_DEBUG
perror("Keeping old copy\n");
#endif
}
return(module->copies[id]);
}
if(module->copies[id]) {
#ifdef MODULE_DEBUG
perror("Disabling old copy ... ");
#endif
if (err = catch{
module->copies[id]->stop();
}) {
report_error("Error during disabling of module \"" + module->name +
"\"\n" + describe_backtrace(err));
}
|
14179b | 1997-01-29 | Per Hedbor | | destruct(module->copies[id]);
}
} else {
|
3bbda8 | 1997-06-11 | Henrik Grubbström (Grubba) | | if(objectp(module->master)) {
|
14179b | 1997-01-29 | Per Hedbor | | me = module->master;
|
3bbda8 | 1997-06-11 | Henrik Grubbström (Grubba) | | } else {
if (err = catch(me = module["program"]())) {
report_error("Couldn't clone module \"" + module->name + "\"\n" +
describe_backtrace(err));
return(0);
}
}
|
14179b | 1997-01-29 | Per Hedbor | | }
|
3bbda8 | 1997-06-11 | Henrik Grubbström (Grubba) | | #ifdef MODULE_DEBUG
|
7f0008 | 1998-03-20 | Per Hedbor | |
|
3bbda8 | 1997-06-11 | Henrik Grubbström (Grubba) | | #endif
if (module->type & (MODULE_LOCATION | MODULE_EXTENSION |
MODULE_FILE_EXTENSION | MODULE_LOGGER |
|
ae32d0 | 1998-03-23 | David Hedbor | | MODULE_URL | MODULE_LAST | MODULE_PROVIDER |
|
3bbda8 | 1997-06-11 | Henrik Grubbström (Grubba) | | MODULE_FILTER | MODULE_PARSER | MODULE_FIRST))
|
14179b | 1997-01-29 | Per Hedbor | | {
me->defvar("_priority", 5, "Priority", TYPE_INT_LIST,
"The priority of the module. 9 is highest and 0 is lowest."
" Modules with the same priority can be assumed to be "
"called in random order",
({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}));
|
ae32d0 | 1998-03-23 | David Hedbor | | if(module->type != MODULE_LOGGER &&
module->type != MODULE_PROVIDER)
|
14179b | 1997-01-29 | Per Hedbor | | {
if(!(module->type & MODULE_PROXY))
{
|
85a2e5 | 1997-06-23 | Per Hedbor | | me->defvar("_sec_group", "user", "Security: Realm", TYPE_STRING,
"The realm to use when requesting password from the "
"client. Usually used as an informative message to the "
"user.");
|
14179b | 1997-01-29 | Per Hedbor | | me->defvar("_seclvl", 0, "Security: Trust level", TYPE_INT,
"When a location module find a file, that file will get "
"a 'Trust level' that equals the level of the module."
" This file will then only be sent to modules with a higher "
" or equal 'Trust level'. <p>As an example: If the trust "
" level of a User filesystem is one, and the CGI module"
" have trust level two, the file will never get passed to"
" the CGI module. A trust level of zero is the same thing as"
" free access.\n");
me->defvar("_seclevels", "", "Security: Patterns", TYPE_TEXT_FIELD,
"This is the 'security level=value' list.<br>"
"Each security level can be any or more from this list:"
"<hr noshade>"
|
a87195 | 1997-08-13 | Henrik Grubbström (Grubba) | | "allow ip=<i>IP</i>/<i>bits</i><br>"
"allow ip=<i>IP</i>:<i>mask</i><br>"
"allow ip=<i>pattern</i><br>"
"allow user=<i>username</i>,...<br>"
"deny ip=<i>IP</i>/<i>bits</i><br>"
"deny ip=<i>IP</i>:<i>mask</i><br>"
"deny ip=<i>pattern</i><br>"
|
14179b | 1997-01-29 | Per Hedbor | | "<hr noshade>"
|
a87195 | 1997-08-13 | Henrik Grubbström (Grubba) | | "In patterns: * matches one or more characters, "
"and ? matches one character.<p>"
|
14179b | 1997-01-29 | Per Hedbor | | "In username: 'any' stands for any valid account "
"(from .htaccess"
" or auth-module. The default (used when _no_ "
"entries are present) is 'allow ip=*', allowing"
" everyone to access the module");
} else {
me->definvisvar("_seclvl", -10, TYPE_INT);
|
85a2e5 | 1997-06-23 | Per Hedbor | | me->defvar("_sec_group", "user", "Proxy Security: Realm", TYPE_STRING,
"The realm to use when requesting password from the "
"client. Usually used as an informative message to the "
"user.");
|
14179b | 1997-01-29 | Per Hedbor | | me->defvar("_seclevels", "", "Proxy security: Patterns",
TYPE_TEXT_FIELD,
"This is the 'security level=value' list.<br>"
"Each security level can be any or more from "
"this list:<br>"
"<hr noshade>"
"allow ip=pattern<br>"
"allow user=username,...<br>"
"deny ip=pattern<br>"
"<hr noshade>"
"In patterns: * is on or more characters, ? is one "
" character.<p>"
"In username: 'any' stands for any valid account"
" (from .htaccess"
" or auth-module. The default is 'deny ip=*'");
}
}
|
3bbda8 | 1997-06-11 | Henrik Grubbström (Grubba) | | } else {
|
14179b | 1997-01-29 | Per Hedbor | | me->defvar("_priority", 0, "", TYPE_INT, "", 0, 1);
|
3bbda8 | 1997-06-11 | Henrik Grubbström (Grubba) | | }
|
14179b | 1997-01-29 | Per Hedbor | |
|
9b9f70 | 1997-08-12 | Per Hedbor | | me->defvar("_comment", "", " Comment", TYPE_TEXT_FIELD|VAR_MORE,
|
14179b | 1997-01-29 | Per Hedbor | | "An optional comment. This has no effect on the module, it "
"is only a text field for comments that the administrator "
"might have (why the module are here, etc.)");
|
9b9f70 | 1997-08-12 | Per Hedbor | | me->defvar("_name", "", " Module name", TYPE_STRING|VAR_MORE,
|
14179b | 1997-01-29 | Per Hedbor | | "An optional name. Set to something to remaind you what "
"the module really does.");
me->setvars(retrieve(modname + "#" + id, this));
|
33e635 | 1998-02-28 | Martin Stjernholm | |
if(module->copies)
module->copies[(int)id] = me;
else
module->enabled = me;
otomod[ me ] = modname;
|
14179b | 1997-01-29 | Per Hedbor | |
mixed err;
|
3bbda8 | 1997-06-11 | Henrik Grubbström (Grubba) | | if((me->start) && (err = catch{
me->start(0, this);
})) {
report_error("Error while initiating module copy of " +
module->name + "\n" + describe_backtrace(err));
|
14179b | 1997-01-29 | Per Hedbor | | destruct(me);
return 0;
}
|
3bbda8 | 1997-06-11 | Henrik Grubbström (Grubba) | |
if (err = catch(pr = me->query("_priority"))) {
report_error("Error while initiating module copy of " +
module->name + "\n" + describe_backtrace(err));
pr = 3;
}
|
14179b | 1997-01-29 | Per Hedbor | |
|
4f4bc1 | 1998-02-04 | Per Hedbor | | api_module_cache |= me->api_functions();
|
3bbda8 | 1997-06-11 | Henrik Grubbström (Grubba) | | if(module->type & MODULE_EXTENSION) {
if (err = catch {
array arr = me->query_extensions();
if (arrayp(arr)) {
string foo;
foreach( arr, foo )
if(pri[pr]->extension_modules[ foo ])
pri[pr]->extension_modules[foo] += ({ me });
else
pri[pr]->extension_modules[foo] = ({ me });
}
}) {
report_error("Error while initiating module copy of " +
module->name + "\n" + describe_backtrace(err));
}
|
14179b | 1997-01-29 | Per Hedbor | | }
|
3bbda8 | 1997-06-11 | Henrik Grubbström (Grubba) | | if(module->type & MODULE_FILE_EXTENSION) {
if (err = catch {
array arr = me->query_file_extensions();
if (arrayp(arr)) {
string foo;
foreach( me->query_file_extensions(), foo )
if(pri[pr]->file_extension_modules[foo] )
pri[pr]->file_extension_modules[foo]+=({me});
else
pri[pr]->file_extension_modules[foo]=({me});
}
}) {
report_error("Error while initiating module copy of " +
module->name + "\n" + describe_backtrace(err));
}
|
14179b | 1997-01-29 | Per Hedbor | | }
|
ae32d0 | 1998-03-23 | David Hedbor | | if(module->type & MODULE_PROVIDER) {
if (err = catch {
mixed provs = me->query_provides();
if(stringp(provs))
provs = (< provs >);
if(arrayp(provs))
provs = mkmultiset(provs);
if (multisetp(provs)) {
pri[pr]->provider_modules [ me ] = provs;
}
}) {
report_error("Error while initiating module copy of " +
module->name + "\n" + describe_backtrace(err));
}
}
|
14179b | 1997-01-29 | Per Hedbor | | if(module->type & MODULE_TYPES)
{
types_module = me;
types_fun = me->type_from_extension;
}
if((module->type & MODULE_MAIN_PARSER))
{
parse_module = me;
|
3bbda8 | 1997-06-11 | Henrik Grubbström (Grubba) | | if (_toparse_modules) {
|
e5bad2 | 1998-02-10 | Per Hedbor | | Array.map(_toparse_modules, lambda(object o, object me, mapping module)
{
|
3bbda8 | 1997-06-11 | Henrik Grubbström (Grubba) | | array err;
if (err = catch{me->add_parse_module(o);}) {
report_error("Error while initiating module copy of " +
module->name + "\n" + describe_backtrace(err));
}
}, me, module);
}
|
14179b | 1997-01-29 | Per Hedbor | | }
if(module->type & MODULE_PARSER)
{
|
3bbda8 | 1997-06-11 | Henrik Grubbström (Grubba) | | if(parse_module) {
if (err = catch {
parse_module->add_parse_module( me );
}) {
report_error("Error while initiating module copy of " +
module->name + "\n" + describe_backtrace(err));
}
}
|
14179b | 1997-01-29 | Per Hedbor | | _toparse_modules += ({ me });
}
if(module->type & MODULE_AUTH)
{
auth_module = me;
auth_fun = me->auth;
}
if(module->type & MODULE_DIRECTORIES)
dir_module = me;
if(module->type & MODULE_LOCATION)
pri[pr]->location_modules += ({ me });
if(module->type & MODULE_LOGGER)
pri[pr]->logger_modules += ({ me });
if(module->type & MODULE_URL)
pri[pr]->url_modules += ({ me });
if(module->type & MODULE_LAST)
pri[pr]->last_modules += ({ me });
if(module->type & MODULE_FILTER)
pri[pr]->filter_modules += ({ me });
|
f12890 | 1997-08-15 | Henrik Grubbström (Grubba) | | if(module->type & MODULE_FIRST) {
|
14179b | 1997-01-29 | Per Hedbor | | pri[pr]->first_modules += ({ me });
|
f12890 | 1997-08-15 | Henrik Grubbström (Grubba) | | }
|
14179b | 1997-01-29 | Per Hedbor | |
hooks_for(module->sname+"#"+id, me);
enabled_modules=retrieve("EnabledModules", this);
if(!enabled_modules[modname+"#"+id])
{
#ifdef MODULE_DEBUG
perror("New module...");
#endif
enabled_modules[modname+"#"+id] = 1;
|
3bbda8 | 1997-06-11 | Henrik Grubbström (Grubba) | | store( "EnabledModules", enabled_modules, 1, this);
|
14179b | 1997-01-29 | Per Hedbor | | }
|
8cc31b | 1997-10-12 | Henrik Grubbström (Grubba) | | invalidate_cache();
|
7f0008 | 1998-03-20 | Per Hedbor | | #ifdef MODULE_DEBUG
|
ae32d0 | 1998-03-23 | David Hedbor | | #if constant(gethrtime)
|
7f0008 | 1998-03-20 | Per Hedbor | | perror(" Done (%3.3f seconds).\n", (gethrtime()-start_time)/1000000.0);
#else
perror(" Done.\n");
#endif
#endif
|
14179b | 1997-01-29 | Per Hedbor | | return me;
}
return 0;
}
string check_variable(string name, string value)
{
switch(name)
{
|
4f4bc1 | 1998-02-04 | Per Hedbor | | case "Ports":
ports_changed=1;
return 0;
|
14179b | 1997-01-29 | Per Hedbor | | case "MyWorldLocation":
if(strlen(value)<7 || value[-1] != '/' ||
!(sscanf(value,"%*s://%*s/")==2))
return "The URL should follow this format: protocol://computer[:port]/";
|
4f4bc1 | 1998-02-04 | Per Hedbor | | return 0;
|
14179b | 1997-01-29 | Per Hedbor | | }
}
#define perr(X) do { report += X; perror(X); } while(0)
private void update_vars(int from)
{
string report = "";
int i;
string modname;
mapping redir;
mapping enabled_modules = retrieve("EnabledModules");
array p, res=({});
perr("Updating configuration file....\n");
perr("----------------------------------------------------\n");
switch(from)
{
case 0:
|
1e5ee8 | 1997-08-21 | Per Hedbor | |
|
14179b | 1997-01-29 | Per Hedbor | | case 1:
case 2:
perr("The 'No directory lists' variable is yet again available.\n");
case 3:
if(query(".htaccess"))
{
perr("The 'HTACCESS' support has been moved to a module.\n");
enable_module("htaccess#0");
}
case 4:
case 5:
while(sizeof(redir = retrieve(modname = "lpcscript#"+i)))
{
remove( modname, this );
if(search(redir->exts, "pike") == -1)
redir->exts += ({"pike"});
if(enabled_modules[modname] )
m_delete( enabled_modules, modname );
store("pikescript#"+i, redir, 1);
enable_module("pikescript#"+i);
perr("Renaming "+modname+" to pikescript#"+i+"\n");
i++;
}
store( "EnabledModules", enabled_modules, 1 );
case 6:
}
perr("----------------------------------------------------\n");
report_debug(report);
}
int log_is_not_enabled()
{
return !query("Log");
}
|
1e5ee8 | 1997-08-21 | Per Hedbor | |
|
14179b | 1997-01-29 | Per Hedbor | | private string get_domain(int|void l)
{
array f;
string t, s;
|
ef7af2 | 1997-09-05 | Henrik Grubbström (Grubba) | | if (!l) {
f = (roxen->QUERY(ConfigurationURL)/"://");
if (sizeof(f) > 1) {
t = (replace(f[1], ({ ":", "/" }), ({ "\0", "\0" }))/"\0")[0];
f = t/".";
if (sizeof(f) > 1) {
s = f[1..]*".";
}
}
}
|
c79b26 | 1998-02-05 | Johan Schön | | #if efun(gethostbyname)
#if efun(gethostname)
|
ef7af2 | 1997-09-05 | Henrik Grubbström (Grubba) | | if(!s) {
|
14179b | 1997-01-29 | Per Hedbor | | f = gethostbyname(gethostname());
if(f)
|
ef7af2 | 1997-09-05 | Henrik Grubbström (Grubba) | | foreach(f, f) {
if (arrayp(f)) {
foreach(f, t) {
f = t/".";
if ((sizeof(f) > 1) &&
(replace(t, ({ "0", "1", "2", "3", "4", "5",
"6", "7", "8", "9", "." }),
({ "","","","","","","","","","","" })) != "")) {
t = f[1..]*".";
if(!s || strlen(s) < strlen(t))
s=t;
}
}
}
|
14179b | 1997-01-29 | Per Hedbor | | }
|
ef7af2 | 1997-09-05 | Henrik Grubbström (Grubba) | | }
|
c79b26 | 1998-02-05 | Johan Schön | | #endif
|
ef7af2 | 1997-09-05 | Henrik Grubbström (Grubba) | | #endif
if(!s) {
t = Stdio.read_bytes("/etc/resolv.conf");
if(t) {
if(!sscanf(t, "domain %s\n", s))
if(!sscanf(t, "search %s%*[ \t\n]", s))
s="nowhere";
|
3d4b71 | 1997-09-05 | Henrik Grubbström (Grubba) | | } else {
|
ef7af2 | 1997-09-05 | Henrik Grubbström (Grubba) | | s="nowhere";
|
14179b | 1997-01-29 | Per Hedbor | | }
}
if(s && strlen(s))
{
if(s[-1] == '.') s=s[..strlen(s)-2];
if(s[0] == '.') s=s[1..];
} else {
s="unknown";
}
return s;
}
int disable_module( string modname )
{
mapping module;
mapping enabled_modules;
object me;
int pr;
int id;
sscanf(modname, "%s#%d", modname, id );
module = modules[ modname ];
if(!module)
{
|
7f0008 | 1998-03-20 | Per Hedbor | | report_error("Failed to disable module\n"
"No module by that name: \""+modname+"\".\n");
|
14179b | 1997-01-29 | Per Hedbor | | return 0;
}
if(module->copies)
{
me = module->copies[id];
m_delete(module->copies, id);
if(!sizeof(module->copies))
unload_module(modname);
} else {
me = module->enabled || module->master;
module->enabled=module->master = 0;
unload_module(modname);
}
|
8cc31b | 1997-10-12 | Henrik Grubbström (Grubba) | | invalidate_cache();
|
14179b | 1997-01-29 | Per Hedbor | |
if(!me)
{
|
7f0008 | 1998-03-20 | Per Hedbor | | report_error("Failed to Disable "+module->name+" # "+id+"\n");
|
14179b | 1997-01-29 | Per Hedbor | | return 0;
}
if(me->stop) me->stop();
#ifdef MODULE_DEBUG
|
7f0008 | 1998-03-20 | Per Hedbor | | perror("Disabling "+module->name+" # "+id+"\n");
|
14179b | 1997-01-29 | Per Hedbor | | #endif
if(module["type"] & MODULE_EXTENSION
&& arrayp( me -> query_extensions()))
{
string foo;
foreach( me -> query_extensions(), foo )
for(pr=0; pr<10; pr++)
if( pri[pr]->extension_modules[ foo ] )
pri[pr]->extension_modules[ foo ]-= ({ me });
}
if(module["type"] & MODULE_FILE_EXTENSION
&& arrayp( me -> query_file_extensions()))
{
string foo;
foreach( me -> query_file_extensions(), foo )
for(pr=0; pr<10; pr++)
if(pri[pr]->file_extension_modules[ foo ] )
pri[pr]->file_extension_modules[foo]-=({me});
}
|
ae32d0 | 1998-03-23 | David Hedbor | | if(module->type & MODULE_PROVIDER) {
for(pr=0; pr<10; pr++)
m_delete(pri[pr]->provider_modules, me);
}
|
14179b | 1997-01-29 | Per Hedbor | | if(module["type"] & MODULE_TYPES)
{
types_module = 0;
types_fun = 0;
}
if(module->type & MODULE_MAIN_PARSER)
parse_module = 0;
if(module->type & MODULE_PARSER)
{
if(parse_module)
parse_module->remove_parse_module( me );
_toparse_modules -= ({ me, 0 });
}
if( module->type & MODULE_AUTH )
{
auth_module = 0;
auth_fun = 0;
}
if( module->type & MODULE_DIRECTORIES )
dir_module = 0;
if( module->type & MODULE_LOCATION )
for(pr=0; pr<10; pr++)
pri[pr]->location_modules -= ({ me });
if( module->type & MODULE_URL )
for(pr=0; pr<10; pr++)
pri[pr]->url_modules -= ({ me });
if( module->type & MODULE_LAST )
for(pr=0; pr<10; pr++)
pri[pr]->last_modules -= ({ me });
if( module->type & MODULE_FILTER )
for(pr=0; pr<10; pr++)
pri[pr]->filter_modules -= ({ me });
|
f12890 | 1997-08-15 | Henrik Grubbström (Grubba) | | if( module->type & MODULE_FIRST ) {
|
14179b | 1997-01-29 | Per Hedbor | | for(pr=0; pr<10; pr++)
pri[pr]->first_modules -= ({ me });
|
f12890 | 1997-08-15 | Henrik Grubbström (Grubba) | | }
|
14179b | 1997-01-29 | Per Hedbor | |
if( module->type & MODULE_LOGGER )
for(pr=0; pr<10; pr++)
pri[pr]->logger_modules -= ({ me });
enabled_modules=retrieve("EnabledModules", this);
if(enabled_modules[modname+"#"+id])
{
m_delete( enabled_modules, modname + "#" + id );
store( "EnabledModules",enabled_modules, 1, this);
}
destruct(me);
return 1;
}
object|string find_module(string name)
{
int id;
sscanf(name, "%s#%d", name, id);
if(modules[name])
{
if(modules[name]->copies)
return modules[name]->copies[id];
else
if(modules[name]->enabled)
return modules[name]->enabled;
}
return 0;
}
void register_module_load_hook( string modname, function fun, mixed ... args )
{
object o;
#ifdef MODULE_DEBUG
perror("Registering a hook for the module "+modname+"\n");
#endif
if(o=find_module(modname))
{
#ifdef MODULE_DEBUG
perror("Already there!\n");
#endif
fun( @args, o );
} else
if(!_hooks[modname])
_hooks[modname] = ({ ({ fun, args }) });
else
_hooks[modname] += ({ ({ fun, args }) });
}
int load_module(string module_file)
{
int foo, disablep;
mixed err;
mixed *module_data;
mapping loaded_modules;
object obj;
program prog;
|
7f0008 | 1998-03-20 | Per Hedbor | | #if efun(gethrtime)
int start_time = gethrtime();
#endif
|
8c6222 | 1997-08-06 | Henrik Grubbström (Grubba) | |
|
14179b | 1997-01-29 | Per Hedbor | | roxen->current_configuration = this_object();
#ifdef MODULE_DEBUG
|
7f0008 | 1998-03-20 | Per Hedbor | | perror("\nLoading " + module_file + "... ");
|
14179b | 1997-01-29 | Per Hedbor | | #endif
|
246cff | 1997-07-16 | Henrik Grubbström (Grubba) | | if(prog=cache_lookup("modules", module_file)) {
err = catch {
|
36086b | 1997-08-07 | Mirar (Pontus Hagland) | | obj = prog(this_object());
|
246cff | 1997-07-16 | Henrik Grubbström (Grubba) | | };
} else {
|
14179b | 1997-01-29 | Per Hedbor | | string dir;
|
619322 | 1997-05-31 | Henrik Grubbström (Grubba) | | _master->set_inhibit_compile_errors("");
|
14179b | 1997-01-29 | Per Hedbor | |
|
246cff | 1997-07-16 | Henrik Grubbström (Grubba) | | err = catch {
|
8c6222 | 1997-08-06 | Henrik Grubbström (Grubba) | | obj = roxen->load_from_dirs(roxen->QUERY(ModuleDirs), module_file,
this_object());
|
246cff | 1997-07-16 | Henrik Grubbström (Grubba) | | };
|
14179b | 1997-01-29 | Per Hedbor | |
|
7f0008 | 1998-03-20 | Per Hedbor | | string errors = (string)_master->errors;
|
619322 | 1997-05-31 | Henrik Grubbström (Grubba) | |
|
246cff | 1997-07-16 | Henrik Grubbström (Grubba) | | _master->set_inhibit_compile_errors(0);
if (sizeof(errors)) {
|
619322 | 1997-05-31 | Henrik Grubbström (Grubba) | | report_error(sprintf("While compiling module (\"%s\"):\n%s\n",
|
246cff | 1997-07-16 | Henrik Grubbström (Grubba) | | module_file, errors));
return(0);
|
14179b | 1997-01-29 | Per Hedbor | | }
prog = roxen->last_loaded();
}
|
246cff | 1997-07-16 | Henrik Grubbström (Grubba) | | if (err) {
report_error("While enabling module (" + module_file + "):\n" +
describe_backtrace(err) + "\n");
return(0);
}
|
14179b | 1997-01-29 | Per Hedbor | |
if(!obj)
{
|
246cff | 1997-07-16 | Henrik Grubbström (Grubba) | | report_error("Module load failed (" + module_file + ") (not found).\n");
|
14179b | 1997-01-29 | Per Hedbor | | return 0;
}
|
09497b | 1997-08-18 | Henrik Grubbström (Grubba) | | if (err = catch (module_data = obj->register_module(this_object()))) {
|
14179b | 1997-01-29 | Per Hedbor | | #ifdef MODULE_DEBUG
perror("FAILED\n" + describe_backtrace( err ));
#endif
|
246cff | 1997-07-16 | Henrik Grubbström (Grubba) | | report_error("Module loaded, but register_module() failed ("
|
14179b | 1997-01-29 | Per Hedbor | | + module_file + ").\n" +
|
246cff | 1997-07-16 | Henrik Grubbström (Grubba) | | describe_backtrace( err ));
|
14179b | 1997-01-29 | Per Hedbor | | return 0;
}
err = "";
|
e493e8 | 1997-07-11 | Per Hedbor | | roxen->somemodules[module_file]=
({ module_data[1], module_data[2]+"<p><i>"+
replace(obj->file_name_and_stuff(),"0<br>", module_file+"<br>")
+"</i>", module_data[0] });
|
14179b | 1997-01-29 | Per Hedbor | | if (!arrayp( module_data ))
err = "Register_module didn't return an array.\n";
else
switch (sizeof( module_data ))
{
case 5:
|
57fbf2 | 1997-07-31 | Marcus Comstedt | | foo=module_data[4];
|
14179b | 1997-01-29 | Per Hedbor | | module_data=module_data[0..3];
case 4:
if (module_data[3] && !arrayp( module_data[3] ))
err = "The fourth element of the array register_module returned "
|
246cff | 1997-07-16 | Henrik Grubbström (Grubba) | | "(extra_buttons) wasn't an array.\n" + err;
|
14179b | 1997-01-29 | Per Hedbor | | case 3:
if (!stringp( module_data[2] ))
err = "The third element of the array register_module returned "
|
246cff | 1997-07-16 | Henrik Grubbström (Grubba) | | "(documentation) wasn't a string.\n" + err;
|
14179b | 1997-01-29 | Per Hedbor | | if (!stringp( module_data[1] ))
err = "The second element of the array register_module returned "
|
246cff | 1997-07-16 | Henrik Grubbström (Grubba) | | "(name) wasn't a string.\n" + err;
|
14179b | 1997-01-29 | Per Hedbor | | if (!intp( module_data[0] ))
err = "The first element of the array register_module returned "
|
246cff | 1997-07-16 | Henrik Grubbström (Grubba) | | "(type) wasn't an integer.\n" + err;
|
14179b | 1997-01-29 | Per Hedbor | | break;
default:
|
246cff | 1997-07-16 | Henrik Grubbström (Grubba) | | err = "The array register_module returned was too small/large. "
"It should have been three or four elements (type, name, "
"documentation and extra buttons (optional))\n";
|
14179b | 1997-01-29 | Per Hedbor | | }
if (err != "")
{
#ifdef MODULE_DEBUG
perror("FAILED\n"+err);
#endif
report_error( "Tried to load module " + module_file + ", but:\n" + err );
if(obj)
destruct( obj );
return 0;
}
if (sizeof(module_data) == 3)
module_data += ({ 0 });
if(!foo)
{
destruct(obj);
obj=0;
} else {
otomod[obj] = module_file;
}
if(!modules[ module_file ])
modules[ module_file ] = ([]);
mapping tmpp = modules[ module_file ];
tmpp->type=module_data[0];
tmpp->name=module_data[1];
tmpp->doc=module_data[2];
tmpp->extra=module_data[3];
tmpp["program"]=prog;
tmpp->master=obj;
tmpp->copies=(foo ? 0 : (tmpp->copies||([])));
tmpp->sname=module_file;
#ifdef MODULE_DEBUG
|
7f0008 | 1998-03-20 | Per Hedbor | | #if efun(gethrtime)
perror(" Done (%3.3f seconds).\n", (gethrtime()-start_time)/1000000.0);
#else
perror(" Done.\n");
#endif
|
14179b | 1997-01-29 | Per Hedbor | | #endif
cache_set("modules", module_file, modules[module_file]["program"]);
|
8cc31b | 1997-10-12 | Henrik Grubbström (Grubba) | |
|
14179b | 1997-01-29 | Per Hedbor | |
return 1;
}
int unload_module(string module_file)
{
mapping module;
int id;
module = modules[ module_file ];
if(!module)
return 0;
if(objectp(module->master))
destruct(module->master);
cache_remove("modules", module_file);
m_delete(modules, module_file);
return 1;
}
int port_open(array prt)
{
array v;
foreach(values(open_ports), v)
if(equal(v, prt)) return 1;
return 0;
}
string desc()
{
string res="";
array (string|int) port;
|
953ca3 | 1997-08-18 | Per Hedbor | |
if(!sizeof(QUERY(Ports)))
{
|
d24d29 | 1997-08-19 | Per Hedbor | |
array handlers = ({});
foreach(roxen->configurations, object c)
if(c->modules["ip-less_hosts"])
handlers+=({({http_encode_string("/Configurations/"+c->name),
strlen(c->query("name"))?c->query("name"):c->name})});
if(sizeof(handlers)==1)
{
res = "This server is handled by the ports in <a href=\""+handlers[0][0]+
"\">"+handlers[0][1]+"</a><br>\n";
} else if(sizeof(handlers)) {
res = "This server is handled by the ports in any of the following servers:<br>";
foreach(handlers, array h)
res += "<a href=\""+h[0]+"\">"+h[1]+"</a><br>\n";
} else
res=("There are no ports configured, and no virtual server seems "
"to have support for ip-less virtual hosting enabled<br>\n");
|
953ca3 | 1997-08-18 | Per Hedbor | | }
|
14179b | 1997-01-29 | Per Hedbor | |
foreach(QUERY(Ports), port)
{
string prt;
|
9f46de | 1997-04-08 | Per Hedbor | | switch(port[1][0..2])
|
14179b | 1997-01-29 | Per Hedbor | | {
case "ssl":
prt = "https://";
break;
default:
prt = port[1]+"://";
}
if(port[2] && port[2]!="ANY")
prt += port[2];
else
|
c79b26 | 1998-02-05 | Johan Schön | | #if efun(gethostname)
|
14179b | 1997-01-29 | Per Hedbor | | prt += (gethostname()/".")[0] + "." + QUERY(Domain);
|
c79b26 | 1998-02-05 | Johan Schön | | #else
;
#endif
|
0f28da | 1997-08-13 | Per Hedbor | | prt += ":"+port[0]+"/";
|
14179b | 1997-01-29 | Per Hedbor | | if(port_open( port ))
|
d24d29 | 1997-08-19 | Per Hedbor | | res += "<font color=darkblue><b>Open:</b></font> <a target=server_view href=\""+prt+"\">"+prt+"</a> \n<br>";
|
14179b | 1997-01-29 | Per Hedbor | | else
|
45165f | 1997-08-13 | Peter Bortas | | res += "<font color=red><b>Not open:</b> <a target=server_view href=\""+
|
d24d29 | 1997-08-19 | Per Hedbor | | prt+"\">"+prt+"</a></font> <br>\n";
|
14179b | 1997-01-29 | Per Hedbor | | }
|
953ca3 | 1997-08-18 | Per Hedbor | | return (res+"<font color=darkgreen>Server URL:</font> <a target=server_view "
"href=\""+query("MyWorldLocation")+"\">"+query("MyWorldLocation")+"</a><p>");
|
14179b | 1997-01-29 | Per Hedbor | | }
|
279a0c | 1997-11-26 | Henrik Grubbström (Grubba) | |
|
14179b | 1997-01-29 | Per Hedbor | |
|
279a0c | 1997-11-26 | Henrik Grubbström (Grubba) | | mapping(string:string) sql_urls = ([]);
object sql_connect(string db)
{
if (sql_urls[db]) {
return(Sql.sql(sql_urls[db]));
} else {
return(Sql.sql(db));
}
}
|
14179b | 1997-01-29 | Per Hedbor | |
|
1e5ee8 | 1997-08-21 | Per Hedbor | |
|
14179b | 1997-01-29 | Per Hedbor | |
private string get_my_url()
{
string s;
|
c79b26 | 1998-02-05 | Johan Schön | | #if efun(gethostname)
|
14179b | 1997-01-29 | Per Hedbor | | s = (gethostname()/".")[0] + "." + query("Domain");
s -= "\n";
|
c79b26 | 1998-02-05 | Johan Schön | | #else
s = "localhost";
#endif
|
14179b | 1997-01-29 | Per Hedbor | | return "http://" + s + "/";
}
|
0f28da | 1997-08-13 | Per Hedbor | | void enable_all_modules()
|
14179b | 1997-01-29 | Per Hedbor | | {
|
7f0008 | 1998-03-20 | Per Hedbor | | #if efun(gethrtime)
int start_time = gethrtime();
#endif
|
1e5ee8 | 1997-08-21 | Per Hedbor | | array modules_to_process=sort(indices(retrieve("EnabledModules",this)));
|
14179b | 1997-01-29 | Per Hedbor | | string tmp_string;
|
ce4ac8 | 1997-09-08 | David Hedbor | | perror("\nEnabling all modules for "+query_name()+"... \n");
|
0f28da | 1997-08-13 | Per Hedbor | |
if(search(modules_to_process, "userdb#0")>-1)
modules_to_process = (({"userdb#0"})+(modules_to_process-({"userdb#0"})));
array err;
foreach( modules_to_process, tmp_string )
if(err = catch( enable_module( tmp_string ) ))
report_error("Failed to enable the module "+tmp_string+". Skipping\n"
#ifdef MODULE_DEBUG
+describe_backtrace(err)+"\n"
#endif
);
roxen->current_configuration = 0;
|
7f0008 | 1998-03-20 | Per Hedbor | | #if efun(gethrtime)
perror("\nAll modules for %s enabled in %4.3f seconds\n\n", query_name(),
(gethrtime()-start_time)/1000000.0);
#endif
|
0f28da | 1997-08-13 | Per Hedbor | | }
void create(string config)
{
|
14179b | 1997-01-29 | Per Hedbor | | roxen->current_configuration = this;
name=config;
|
ce4ac8 | 1997-09-08 | David Hedbor | | perror("Creating virtual server '"+config+"'\n");
|
14179b | 1997-01-29 | Per Hedbor | |
|
5d8780 | 1997-11-29 | Henrik Grubbström (Grubba) | | defvar("ZNoSuchFile", "<title>Sorry. I cannot find this resource</title>\n"
"<body bgcolor='#ffffff' text='#000000' alink='#ff0000' "
"vlink='#00007f' link='#0000ff'>\n"
"<h2 align=center><configimage src=roxen.gif alt=\"File not found\">\n"
|
14179b | 1997-01-29 | Per Hedbor | | "<p><hr noshade>"
"\n<i>Sorry</i></h2>\n"
|
45165f | 1997-08-13 | Peter Bortas | | "<br clear>\n<font size=\"+2\">The resource requested "
|
14179b | 1997-01-29 | Per Hedbor | | "<i>$File</i>\ncannot be found.<p>\n\nIf you feel that this is a "
"configuration error, please contact "
|
5d8780 | 1997-11-29 | Henrik Grubbström (Grubba) | | "the administrators or the author of the\n"
"<if referrer>"
"<a href=\"<referrer>\">referring</a>"
"</if>\n"
"<else>referring</else>\n"
"page."
|
14179b | 1997-01-29 | Per Hedbor | | "<p>\n</font>\n"
"<hr noshade>"
|
5d8780 | 1997-11-29 | Henrik Grubbström (Grubba) | | "<version>, at <a href=\"$Me\">$Me</a>.\n"
"</body>\n",
|
14179b | 1997-01-29 | Per Hedbor | |
"Messages: No such file", TYPE_TEXT_FIELD,
"What to return when there is no resource or file available "
"at a certain location. $File will be replaced with the name "
"of the resource requested, and $Me with the URL of this server ");
|
9b9f70 | 1997-08-12 | Per Hedbor | | defvar("comment", "", "Virtual server comment",
TYPE_TEXT_FIELD|VAR_MORE,
|
14179b | 1997-01-29 | Per Hedbor | | "This text will be visible in the configuration interface, it "
" can be quite useful to use as a memory helper.");
|
9b9f70 | 1997-08-12 | Per Hedbor | | defvar("name", "", "Virtual server name",
TYPE_STRING|VAR_MORE,
|
14179b | 1997-01-29 | Per Hedbor | | "This is the name that will be used in the configuration "
"interface. If this is left empty, the actual name of the "
"virtual server will be used");
defvar("LogFormat",
"404: $host $referer - [$cern_date] \"$method $resource $protocol\" 404 -\n"
|
2d4d4f | 1997-08-01 | Fredrik Noring | | "500: $host $referer ERROR [$cern_date] \"$method $resource $protocol\" 500 -\n"
|
14179b | 1997-01-29 | Per Hedbor | | "*: $host - - [$cern_date] \"$method $resource $protocol\" $response $length"
,
"Logging: Format",
|
9b9f70 | 1997-08-12 | Per Hedbor | | TYPE_TEXT_FIELD|VAR_MORE,
|
14179b | 1997-01-29 | Per Hedbor | |
"What format to use for logging. The syntax is:\n"
"<pre>"
"response-code or *: Log format for that response acode\n\n"
"Log format is normal characters, or one or more of the "
"variables below:\n"
"\n"
"\\n \\t \\r -- As in C, newline, tab and linefeed\n"
"$char(int) -- Insert the (1 byte) character specified by the integer.\n"
"$wchar(int) -- Insert the (2 byte) word specified by the integer.\n"
"$int(int) -- Insert the (4 byte) word specified by the integer.\n"
"$^ -- Supress newline at the end of the logentry\n"
"$host -- The remote host name, or ip number.\n"
"$ip_number -- The remote ip number.\n"
"$bin-ip_number -- The remote host id as a binary integer number.\n"
"\n"
"$cern_date -- Cern Common Log file format date.\n"
"$bin-date -- Time, but as an 32 bit iteger in network byteorder\n"
"\n"
"$method -- Request method\n"
"$resource -- Resource identifier\n"
"$protocol -- The protocol used (normally HTTP/1.0)\n"
"$response -- The response code sent\n"
"$bin-response -- The response code sent as a binary short number\n"
"$length -- The length of the data section of the reply\n"
"$bin-length -- Same, but as an 32 bit iteger in network byteorder\n"
|
0bf5a1 | 1998-04-03 | Henrik Grubbström (Grubba) | | "$request-time -- The time the request took (seconds)\n"
|
14179b | 1997-01-29 | Per Hedbor | | "$referer -- the header 'referer' from the request, or '-'.\n"
"$user_agent -- the header 'User-Agent' from the request, or '-'.\n\n"
"$user -- the name of the auth user used, if any\n"
"$user_id -- A unique user ID, if cookies are supported,\n"
" by the client, otherwise '0'\n"
"</pre>", 0, log_is_not_enabled);
defvar("Log", 1, "Logging: Enabled", TYPE_FLAG, "Log requests");
defvar("LogFile", roxen->QUERY(logdirprefix)+
short_name(name)+"/Log",
"Logging: Log file", TYPE_FILE, "The log file. "
|
f7d981 | 1997-09-12 | Per Hedbor | | ""
"A file name. May be relative to "+getcwd()+"."
" Some substitutions will be done:"
"<pre>"
"%y Year (i.e. '1997')\n"
"%m Month (i.e. '08')\n"
"%d Date (i.e. '10' for the tenth)\n"
"%h Hour (i.e. '00')\n</pre>"
,0, log_is_not_enabled);
|
14179b | 1997-01-29 | Per Hedbor | |
defvar("NoLog", ({ }),
|
9b9f70 | 1997-08-12 | Per Hedbor | | "Logging: No Logging for", TYPE_STRING_LIST|VAR_MORE,
|
14179b | 1997-01-29 | Per Hedbor | | "Don't log requests from hosts with an IP number which matches any "
"of the patterns in this list. This also affects the access counter "
"log.\n",0, log_is_not_enabled);
|
1e5ee8 | 1997-08-21 | Per Hedbor | | defvar("Domain", get_domain(), "Domain", TYPE_STRING,
|
14179b | 1997-01-29 | Per Hedbor | | "Your domainname, should be set automatically, if not, "
|
3d4b71 | 1997-09-05 | Henrik Grubbström (Grubba) | | "enter the correct domain name here, and send a bug report to "
|
0247a3 | 1998-03-11 | David Hedbor | | "<a href=\"mailto:roxen-bugs@idonex.se\">roxen-bugs@idonex.se"
|
14179b | 1997-01-29 | Per Hedbor | | "</a>");
|
1e5ee8 | 1997-08-21 | Per Hedbor | | defvar("Ports", ({ }),
|
14179b | 1997-01-29 | Per Hedbor | | "Listen ports", TYPE_PORTS,
"The ports this virtual instance of Roxen will bind to.\n");
defvar("MyWorldLocation", get_my_url(),
"Server URL", TYPE_STRING,
"This is where your start page is located.");
defvar("FTPWelcome",
" +-------------------------------------------------\n"
" +-- Welcome to the Roxen Challenger FTP server ---\n"
" +-------------------------------------------------\n",
"Messages: FTP Welcome",
|
9b9f70 | 1997-08-12 | Per Hedbor | | TYPE_TEXT_FIELD|VAR_MORE,
|
14179b | 1997-01-29 | Per Hedbor | | "FTP Welcome answer; transmitted to new FTP connections if the file "
"<i>/welcome.msg</i> doesn't exist.\n");
|
9b9f70 | 1997-08-12 | Per Hedbor | | defvar("named_ftp", 0, "Allow named FTP", TYPE_FLAG|VAR_MORE,
|
de37d3 | 1997-04-09 | Marcus Comstedt | | "Allow ftp to normal user-accounts (requires auth-module).\n");
|
a0a52b | 1997-08-23 | Henrik Grubbström (Grubba) | | defvar("anonymous_ftp", 1, "Allow anonymous FTP", TYPE_FLAG|VAR_MORE,
|
3d4b71 | 1997-09-05 | Henrik Grubbström (Grubba) | | "Allows anonymous ftp.\n");
|
a0a52b | 1997-08-23 | Henrik Grubbström (Grubba) | |
|
d9aa7c | 1998-03-27 | Henrik Grubbström (Grubba) | | defvar("guest_ftp", 0, "Allow FTP guest users", TYPE_FLAG|VAR_MORE,
"Allows FTP guest users.\n");
|
9b9f70 | 1997-08-12 | Per Hedbor | | defvar("shells", "/etc/shells", "Shell database", TYPE_FILE|VAR_MORE,
|
de37d3 | 1997-04-09 | Marcus Comstedt | | "File which contains a list of all valid shells.\n"
"Usually /etc/shells\n");
|
14179b | 1997-01-29 | Per Hedbor | |
defvar("_v", CONFIGURATION_FILE_LEVEL, 0, TYPE_INT, 0, 0, 1);
setvars(retrieve("spider#0", this));
if((sizeof(retrieve("spider#0", this)) &&
(!retrieve("spider#0",this)->_v)
|| (query("_v") < CONFIGURATION_FILE_LEVEL)))
{
update_vars(retrieve("spider#0",this)->_v?query("_v"):0);
killvar("PEther");
variables->_v[VAR_VALUE] = CONFIGURATION_FILE_LEVEL;
store("spider#0", variables, 0);
}
set("_v", CONFIGURATION_FILE_LEVEL);
}
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|