dfc05d2002-06-14Johan Sundström // This file is part of Internet Server.
835c6c2001-06-17Martin Nilsson // Copyright © 1996 - 2001, Roxen IS.
88d0922002-09-27Martin Nilsson // $Id: global_variables.pike,v 1.95 2002/09/26 22:12:24 nilsson Exp $
9bb83f2002-06-13Martin Nilsson  // NGSERVER: Move protocol settings to their own files.
e35de22000-03-10Martin Nilsson 
835c6c2001-06-17Martin Nilsson // #pragma strict_types
55a8662000-11-20Per Hedbor #define DEFVAR mixed...:object #define BDEFVAR mixed...:object
24c6c12000-02-20Martin Nilsson 
55a8662000-11-20Per Hedbor #define IN_ROXEN
690adf1999-08-30Per Hedbor inherit "read_config";
3bb11d2000-07-09Per Hedbor inherit "basic_defvar";
7d2baf2000-02-02Martin Stjernholm #include <version.h>
9bb83f2002-06-13Martin Nilsson #include <module.h>
f498ed2000-07-11Martin Nilsson 
3bb11d2000-07-09Per Hedbor mixed save() { store( "Variables", variables, 0, 0 ); }
690adf1999-08-30Per Hedbor // The following three functions are used to hide variables when they // are not used. This makes the user-interface clearer and quite a lot // less clobbered.
f4b6251999-09-02Per Hedbor 
8552d92001-01-13Martin Nilsson private int(0..1) cache_disabled_p() { return !query("cache"); } private int(0..1) syslog_disabled() { return query("LogA")!="syslog"; } private int(0..1) ident_disabled_p() { return [int(0..1)]query("default_ident"); }
690adf1999-08-30Per Hedbor 
6897c92001-06-27Honza Petrous #ifdef SNMP_AGENT private int(0..1) snmp_disabled() { return !query("snmp_agent"); }
6f669a2001-08-14Honza Petrous private string snmp_get_cif_domain() { //return(Standards.URI(roxenp()->configurations[0]->get_url()||"http://0.0.0.0")->host); return(""); }
6897c92001-06-27Honza Petrous #endif
934b3f2000-02-04Per Hedbor 
434bac2000-07-14Andreas Lange // And why put these functions here, you might righfully ask.
934b3f2000-02-04Per Hedbor  // The answer is that there is actually a reason for it, it's for // performance reasons. This file is dumped to a .o file, roxen.pike // is not.
3e3bab2001-01-19Per Hedbor void set_up_hilfe_variables( Protocol o )
e056e92000-10-19Per Hedbor {
de4b592001-01-21Martin Nilsson  function(DEFVAR) defvar = o->defvar;
e056e92000-10-19Per Hedbor  defvar( "require_auth", 1,
9bb83f2002-06-13Martin Nilsson  "Require user with the 'hilfe' permission", TYPE_FLAG, ("If yes, require a user with the hilfe permission "
0fa67e2002-06-15Martin Nilsson  "set, otherwise, any administration interface user will "
9bb83f2002-06-13Martin Nilsson  "be allowed, even one with only the view settings permission." ) );
e056e92000-10-19Per Hedbor }
934b3f2000-02-04Per Hedbor 
3e3bab2001-01-19Per Hedbor void set_up_ftp_variables( Protocol o )
934b3f2000-02-04Per Hedbor {
de4b592001-01-21Martin Nilsson  function(DEFVAR) defvar = o->defvar;
934b3f2000-02-04Per Hedbor  defvar( "FTPWelcome", " +------------------------------------------------\n" " +-- Welcome to the Roxen FTP server ---\n" " +------------------------------------------------\n",
9bb83f2002-06-13Martin Nilsson  "Welcome text", TYPE_TEXT, "The text shown to the user on connect." );
934b3f2000-02-04Per Hedbor 
9bb83f2002-06-13Martin Nilsson  defvar( "ftp_user_session_limit", 0, "User session limit",
434bac2000-07-14Andreas Lange  TYPE_INT,
9bb83f2002-06-13Martin Nilsson  "The maximum number of times a user can connect at once." " 0 means unlimited." );
934b3f2000-02-04Per Hedbor 
9bb83f2002-06-13Martin Nilsson  defvar( "named_ftp", 1, "Allow named ftp", TYPE_FLAG, "If yes, non-anonymous users can connect." );
934b3f2000-02-04Per Hedbor 
434bac2000-07-14Andreas Lange  defvar( "guest_ftp", 1,
9bb83f2002-06-13Martin Nilsson  "Allow login with incorrect password/user",
434bac2000-07-14Andreas Lange  TYPE_FLAG,
9bb83f2002-06-13Martin Nilsson  ("If yes, users can connect with the wrong password " "and/or username. This is useful since things like .htaccess " "files can later on authenticate the user."));
934b3f2000-02-04Per Hedbor 
9bb83f2002-06-13Martin Nilsson  defvar( "anonymous_ftp", 1, "Allow anonymous ftp", TYPE_FLAG, "If yes, anonymous users are allowed to connect." );
934b3f2000-02-04Per Hedbor 
9bb83f2002-06-13Martin Nilsson  defvar( "shells", "", "Shell database",
434bac2000-07-14Andreas Lange  TYPE_FILE,
9bb83f2002-06-13Martin Nilsson  ("If this string is set to anything but the empty string, " "it should specify a file containing a list of valid shells. " "Users with shells that are not in this list will not " "be allowed to log in.") );
965a6d2001-04-14Henrik Grubbström (Grubba) 
9bb83f2002-06-13Martin Nilsson  defvar( "passive_port_min", 0, "Passive port minimum", TYPE_INT, "Minimum port number to use in the PASV/EPSV response." );
965a6d2001-04-14Henrik Grubbström (Grubba) 
9bb83f2002-06-13Martin Nilsson  defvar( "passive_port_max", 65535, "Passive port maximum", TYPE_INT, "Maximum port number to use in the PASV/EPSV response." );
934b3f2000-02-04Per Hedbor }
bc0dec2001-08-05Martin Nilsson void set_up_http_variables( Protocol o )
934b3f2000-02-04Per Hedbor {
de4b592001-01-21Martin Nilsson  function(DEFVAR) defvar = o->defvar;
472b152000-02-08Per Hedbor 
3ea9f32001-01-29Per Hedbor  function do_set_cookie(Protocol o) { return lambda() { return o->query("set_cookie") == 0; }; };
9bb83f2002-06-13Martin Nilsson  defvar( "minimum_bitrate", 0, "Minimum allowed bitrate",
9c19002001-02-27Per Hedbor  TYPE_INT,
9bb83f2002-06-13Martin Nilsson  ("The minimum allowed bitrate, in bits/second. If the " "client is slower than this set bitrate, it will be " "disconnected (after a timeout). Setting this higher than " "14000 is not recommended if you have modem users.") );
9c19002001-02-27Per Hedbor 
9bb83f2002-06-13Martin Nilsson  defvar("show_internals", 0, "Show internal errors",
434bac2000-07-14Andreas Lange  TYPE_FLAG,
9bb83f2002-06-13Martin Nilsson  ("Show 'Internal server error' messages to the user. " "This is very useful if you are debugging your own modules " "or writing Pike scripts."));
472b152000-02-08Per Hedbor 
9bb83f2002-06-13Martin Nilsson  defvar("set_cookie", 0, "Logging: Set unique browser id cookies",
bc0dec2001-08-05Martin Nilsson  TYPE_FLAG,
9bb83f2002-06-13Martin Nilsson  ("If set to Yes, all clients that accepts cookies will get " "a unique 'user-id-cookie', which can then be used in the log " "and in scripts to track individual users."));
472b152000-02-08Per Hedbor 
9bb83f2002-06-13Martin Nilsson  defvar("set_cookie_only_once", 1, "Logging: Set ID cookies only once",
bc0dec2001-08-05Martin Nilsson  TYPE_FLAG,
9bb83f2002-06-13Martin Nilsson  ("If set to Yes, Roxen will attempt to set unique browser " "ID cookies only upon receiving the first request (and " "again after some minutes). Thus, if the user doesn't allow " "the cookie to be set, she won't be bothered with " "multiple requests."), 0, do_set_cookie( o ));
472b152000-02-08Per Hedbor }
3e3bab2001-01-19Per Hedbor void set_up_ssl_variables( Protocol o )
472b152000-02-08Per Hedbor {
de4b592001-01-21Martin Nilsson  function(DEFVAR) defvar = o->defvar;
472b152000-02-08Per Hedbor 
9bb83f2002-06-13Martin Nilsson  defvar( "ssl_cert_file", "demo_certificate.pem", "SSL certificate file",
434bac2000-07-14Andreas Lange  TYPE_STRING,
9bb83f2002-06-13Martin Nilsson  "The SSL certificate file to use. The path is relative to "+getcwd()+".\n" );
434bac2000-07-14Andreas Lange 
9bb83f2002-06-13Martin Nilsson  defvar( "ssl_key_file", "", "SSL key file",
434bac2000-07-14Andreas Lange  TYPE_STRING,
9bb83f2002-06-13Martin Nilsson  ("The SSL key file to use. The path is " "relative to "+getcwd()+", you do not have to specify a key " "file, leave this field empty to use the certificate " "file only.\n") );
934b3f2000-02-04Per Hedbor }
f4b6251999-09-02Per Hedbor // Get the current domain. This is not as easy as one could think. string get_domain(int|void l) { array f; string t, s;
c5e0961999-10-04Per Hedbor  // FIXME: NT support.
f4b6251999-09-02Per Hedbor 
c5e0961999-10-04Per Hedbor  t = Stdio.read_bytes("/etc/resolv.conf");
5ffd492000-02-02Per Hedbor  if(t)
c5e0961999-10-04Per Hedbor  { if(!sscanf(t, "domain %s\n", s)) if(!sscanf(t, "search %s%*[ \t\n]", s)) s="nowhere"; } else { s="nowhere";
f4b6251999-09-02Per Hedbor  }
c5e0961999-10-04Per Hedbor  s = "host."+s;
f4b6251999-09-02Per Hedbor  sscanf(s, "%*s.%s", s); if(s && strlen(s)) { if(s[-1] == '.') s=s[..strlen(s)-2]; if(s[0] == '.') s=s[1..]; } else {
5ffd492000-02-02Per Hedbor  s="unknown";
f4b6251999-09-02Per Hedbor  } return s; }
a59d252000-07-04Per Hedbor class PortOptions { inherit Variable.Variable; constant type = "PortOptions";
3e3bab2001-01-19Per Hedbor  int check_visibility(RequestID id, int a, int b, int c, int d) { return 0; } void set_from_form(RequestID id ) { return; }
a59d252000-07-04Per Hedbor  void create() { ::create( ([]), 0, 0, 0 ); } };
40889a2000-09-19Per Hedbor array(string) old_module_dirs; void zap_all_module_caches( Variable.Variable v ) { if( !equal( v->query(), old_module_dirs ) ) { report_notice( "Module path changed - clearing all module caches\n" ); catch(this_object()->clear_all_modules_cache()); catch(map( this_object()->module_cache->list(), this_object()->module_cache->delete )); catch { string f = dirname( master()->make_ofilename( "tmp" ) ); foreach( glob("*.o",get_dir( f )), string ofile ) catch(rm( ofile )); }; old_module_dirs = v->query(); } }
3bb11d2000-07-09Per Hedbor void define_global_variables( )
690adf1999-08-30Per Hedbor { int p;
a59d252000-07-04Per Hedbor  defvar("port_options", PortOptions()); defvar("RestoreConnLogFull", 0,
9bb83f2002-06-13Martin Nilsson  "Logging: Log entire file length in restored connections",
434bac2000-07-14Andreas Lange  TYPE_FLAG,
9bb83f2002-06-13Martin Nilsson  ("If this toggle is enabled log entries for restored connections " "will log the amount of sent data plus the restoration location. " "Ie if a user has downloaded 100 bytes of a file already, and makes " "a Range request fetching the remaining 900 bytes, the log entry " "will log it as if the entire 1000 bytes were downloaded. " "<p>This is useful if you want to know if downloads were successful " "(the user has the complete file downloaded). The drawback is that " "bandwidth statistics on the log file will be incorrect. The " "statistics in Roxen will still be correct.</p>")); defvar("default_font", "roxen builtin", "Default font",
434bac2000-07-14Andreas Lange  TYPE_FONT,
9bb83f2002-06-13Martin Nilsson  "The default font to use when modules request a font.");
690adf1999-08-30Per Hedbor 
b5fce52002-06-05Martin Nilsson  defvar("font_dirs", ({"../local/fonts/", "data/fonts/" })+
7600962000-12-16Per Hedbor #ifdef __NT__ ({combine_path(replace(getenv("SystemRoot"),"\\","/"),"fonts/")}) #else ((getenv("RX_FONTPATH")||"")/","-({""})) #endif
9bb83f2002-06-13Martin Nilsson  , "Font directories",
434bac2000-07-14Andreas Lange  TYPE_DIR_LIST,
9bb83f2002-06-13Martin Nilsson  "This is where the fonts are located.");
690adf1999-08-30Per Hedbor 
88d0922002-09-27Martin Nilsson  defvar("font_oversampling", 1, "Font oversampling", TYPE_FLAG, "If set to Yes, fonts will be oversampled resulting " "in higher quality but more fuzz. This will require clearing " "of various graphics caches like the Graphic text and " "GButton caches to take full effect.");
9bb83f2002-06-13Martin Nilsson  defvar("logdirprefix", "../logs/", "Logging: Log directory prefix",
434bac2000-07-14Andreas Lange  TYPE_STRING|VAR_MORE,
9bb83f2002-06-13Martin Nilsson  ("This is the default file path that will be prepended " "to the log file path in all the default modules and the " "site."));
f498ed2000-07-11Martin Nilsson 
9bb83f2002-06-13Martin Nilsson  defvar("cache", 0, "Cache: Proxy Disk Cache Enabled",
434bac2000-07-14Andreas Lange  TYPE_FLAG,
9bb83f2002-06-13Martin Nilsson  "If set to Yes, caching will be enabled.");
f498ed2000-07-11Martin Nilsson 
9bb83f2002-06-13Martin Nilsson  defvar("garb_min_garb", 1, "Cache: Proxy Disk Cache Clean size",
434bac2000-07-14Andreas Lange  TYPE_INT,
9bb83f2002-06-13Martin Nilsson  "Minimum number of Megabytes removed when a garbage collect is done.",
690adf1999-08-30Per Hedbor  0, cache_disabled_p);
f498ed2000-07-11Martin Nilsson 
b9a7022000-07-15Andreas Lange  defvar("cache_minimum_left", 5,
9bb83f2002-06-13Martin Nilsson  "Cache: Proxy Disk Cache Minimum available free space and inodes (in %)",
434bac2000-07-14Andreas Lange  TYPE_INT,
9bb83f2002-06-13Martin Nilsson  ("If less than this amount of disk space or inodes (in %) " "is left, the cache will remove a few files. This check may " "work half-hearted if the diskcache is spread over several " "filesystems."),
f498ed2000-07-11Martin Nilsson  0,
690adf1999-08-30Per Hedbor #if constant(filesystem_stat)
f498ed2000-07-11Martin Nilsson  cache_disabled_p
690adf1999-08-30Per Hedbor #else
f498ed2000-07-11Martin Nilsson  1
690adf1999-08-30Per Hedbor #endif /* filesystem_stat */
f498ed2000-07-11Martin Nilsson  );
9bb83f2002-06-13Martin Nilsson  defvar("cache_size", 25, "Cache: Proxy Disk Cache Size",
434bac2000-07-14Andreas Lange  TYPE_INT,
9bb83f2002-06-13Martin Nilsson  "How many MB may the cache grow to before a garbage collect is done?",
434bac2000-07-14Andreas Lange  0, cache_disabled_p);
b9a7022000-07-15Andreas Lange  defvar("cache_max_num_files", 0,
9bb83f2002-06-13Martin Nilsson  "Cache: Proxy Disk Cache Maximum number of files",
434bac2000-07-14Andreas Lange  TYPE_INT,
9bb83f2002-06-13Martin Nilsson  ("How many cache files (inodes) may be on disk before " "a garbage collect is done? May be left at zero to disable " "this check."),
434bac2000-07-14Andreas Lange  0, cache_disabled_p);
9bb83f2002-06-13Martin Nilsson  defvar("bytes_per_second", 50, "Cache: Proxy Disk Cache bytes per second",
434bac2000-07-14Andreas Lange  TYPE_INT,
9bb83f2002-06-13Martin Nilsson  ("How file size should be treated during garbage collect. "
edab552002-01-11Henrik Grubbström (Grubba)  "Each X bytes count as a second, so that larger files will "
434bac2000-07-14Andreas Lange  "be removed first."),
690adf1999-08-30Per Hedbor  0, cache_disabled_p);
a59d252000-07-04Per Hedbor  defvar("cachedir", "/tmp/roxen_cache/",
9bb83f2002-06-13Martin Nilsson  "Cache: Proxy Disk Cache Base Cache Dir", TYPE_DIR, ("This is the base directory where cached files will " "reside. To avoid mishaps, 'roxen_cache/' is always " "appended to this variable."),
434bac2000-07-14Andreas Lange  0, cache_disabled_p);
690adf1999-08-30Per Hedbor 
a59d252000-07-04Per Hedbor  defvar("hash_num_dirs", 500,
9bb83f2002-06-13Martin Nilsson  "Cache: Proxy Disk Cache Number of hash directories",
434bac2000-07-14Andreas Lange  TYPE_INT|VAR_MORE,
9bb83f2002-06-13Martin Nilsson  ("This is the number of directories to hash the contents " "of the disk cache into. Changing this value currently " "invalidates the whole cache, since the cache cannot find " "the old files. In the future, the cache will be " "recalculated when this value is changed."),
434bac2000-07-14Andreas Lange  0, cache_disabled_p);
b9a7022000-07-15Andreas Lange  defvar("cache_keep_without_content_length", 1,
9bb83f2002-06-13Martin Nilsson  "Cache: Proxy Disk Cache Keep without Content-Length", TYPE_FLAG, "Keep files without Content-Length header information in the cache?",
434bac2000-07-14Andreas Lange  0, cache_disabled_p);
b9a7022000-07-15Andreas Lange  defvar("cache_check_last_modified", 0,
9bb83f2002-06-13Martin Nilsson  "Cache: Proxy Disk Cache Refreshes on Last-Modified",
434bac2000-07-14Andreas Lange  TYPE_FLAG,
9bb83f2002-06-13Martin Nilsson  ("If set, refreshes files without Expire header " "information when they have reached double the age they had " "when they got cached. This may be useful for some regularly " "updated docs as online newspapers."),
434bac2000-07-14Andreas Lange  0, cache_disabled_p);
b9a7022000-07-15Andreas Lange  defvar("cache_last_resort", 0,
9bb83f2002-06-13Martin Nilsson  "Cache: Proxy Disk Cache Last resort (in days)",
434bac2000-07-14Andreas Lange  TYPE_INT,
9bb83f2002-06-13Martin Nilsson  ("How many days shall files without Expires and without " "Last-Modified header information be kept?"),
434bac2000-07-14Andreas Lange  0, cache_disabled_p);
690adf1999-08-30Per Hedbor 
a59d252000-07-04Per Hedbor  defvar("cache_gc_logfile", "",
9bb83f2002-06-13Martin Nilsson  "Cache: Proxy Disk Cache Garbage collector logfile",
434bac2000-07-14Andreas Lange  TYPE_FILE,
9bb83f2002-06-13Martin Nilsson  ("Information about garbage collector runs, removed and " "refreshed files, cache and disk status goes here."),
434bac2000-07-14Andreas Lange  0, cache_disabled_p);
690adf1999-08-30Per Hedbor  /// End of cache variables..
f498ed2000-07-11Martin Nilsson  // FIXME: Should mention real_version.
434bac2000-07-14Andreas Lange  defvar("default_ident", 1,
9bb83f2002-06-13Martin Nilsson  "Identify, Use default identification string",
434bac2000-07-14Andreas Lange  TYPE_FLAG|VAR_MORE,
9bb83f2002-06-13Martin Nilsson  ("Setting this variable to No will display the " "\"Identify as\" node where you can state what Roxen " "should call itself when talking to clients.<br />" "It is possible to disable this so that you can enter an " "identification-string that does not include the actual " "version of Roxen, as recommended by the HTTP/1.0 and " "HTTP/1.1 RFCs:" "<p><blockquote><i>" "Note: Revealing the specific software version of the server " "may allow the server machine to become more vulnerable to " "attacks against software that is known to contain security " "holes. Server implementors are encouraged to make this field " "a configurable option." "</i></blockquote></p>"));
8148ed2000-09-13Andreas Lange 
9bb83f2002-06-13Martin Nilsson  defvar("ident", replace(real_version," ","·"), "Identify, Identify as",
434bac2000-07-14Andreas Lange  TYPE_STRING /* |VAR_MORE */,
9bb83f2002-06-13Martin Nilsson  "Enter the name that Roxen should use when talking to clients. ",
434bac2000-07-14Andreas Lange  0, ident_disabled_p);
9bb83f2002-06-13Martin Nilsson  defvar("User", "", "Change uid and gid to",
434bac2000-07-14Andreas Lange  TYPE_STRING,
9bb83f2002-06-13Martin Nilsson  #"\
b39ccb2001-08-24Martin Stjernholm When Roxen is run as root, to be able to open port 80 for listening, change to this user-id and group-id when the port has been opened. If you specify a symbolic username, the default group of that user will be used. The syntax is user[:group]. <p>A server restart is necessary for a change of this variable to take effect. Note that it also can lead to file permission errors if the
edab552002-01-11Henrik Grubbström (Grubba) Roxen process no longer can read files it previously has written.
9bb83f2002-06-13Martin Nilsson The start script attempts to fix this for the standard file locations.</p>");
434bac2000-07-14Andreas Lange 
9bb83f2002-06-13Martin Nilsson  defvar("permanent_uid", 0, "Change uid and gid permanently",
434bac2000-07-14Andreas Lange  TYPE_FLAG,
9bb83f2002-06-13Martin Nilsson  ("If this variable is set, Roxen will set it's uid and gid "
8148ed2000-09-13Andreas Lange  "permanently. This disables the 'exec script as user' features " "for CGI, and also 'access files as user' in the filesystems, but "
f498ed2000-07-11Martin Nilsson  "it gives better security."));
690adf1999-08-30Per Hedbor 
a59d252000-07-04Per Hedbor  defvar("ModuleDirs", ({ "../local/modules/", "modules/" }),
9bb83f2002-06-13Martin Nilsson  "Module directories",
434bac2000-07-14Andreas Lange  TYPE_DIR_LIST,
9bb83f2002-06-13Martin Nilsson  ("This is a list of directories where Roxen should look " "for modules. Can be relative paths, from the " "directory you started Roxen. " "The directories are searched in order for modules."));
690adf1999-08-30Per Hedbor 
ab6f292000-11-18Martin Nilsson  defvar("Supports",
dacef22002-06-05Martin Nilsson  Variable.Text( "#include <data/supports>\n",
9bb83f2002-06-13Martin Nilsson  VAR_MORE, "Client supports regexps", ("What do the different clients support?\n<br />" "The default information is normally fetched from the file " "server/data/supports in your Roxen directory.") ) )
ab6f292000-11-18Martin Nilsson  -> add_changed_callback( lambda(Variable.Text s) { roxenp()->initiate_supports(); cache.cache_expire("supports"); } );
f498ed2000-07-11Martin Nilsson 
9bb83f2002-06-13Martin Nilsson  defvar("audit", 0, "Logging: Audit trail",
434bac2000-07-14Andreas Lange  TYPE_FLAG,
9bb83f2002-06-13Martin Nilsson  ("If Audit trail is set to Yes, all changes of uid will be " "logged in the Event log."));
690adf1999-08-30Per Hedbor 
5ffd492000-02-02Per Hedbor #if efun(syslog)
9bb83f2002-06-13Martin Nilsson  defvar("LogA", "file", "Logging: Debug log method",
434bac2000-07-14Andreas Lange  TYPE_STRING_LIST|VAR_MORE,
9bb83f2002-06-13Martin Nilsson  ("What method to use for the debug log, default is file, but "
690adf1999-08-30Per Hedbor  "syslog is also available. When using file, the output is really" " sent to stdout and stderr, but this is handled by the "
f498ed2000-07-11Martin Nilsson  "start script."),
434bac2000-07-14Andreas Lange  ({ "file", "syslog" }));
f498ed2000-07-11Martin Nilsson 
9bb83f2002-06-13Martin Nilsson  defvar("LogSP", 1, "Logging: Log PID",
434bac2000-07-14Andreas Lange  TYPE_FLAG,
9bb83f2002-06-13Martin Nilsson  "If set, the PID will be included in the syslog.", 0,
434bac2000-07-14Andreas Lange  syslog_disabled);
f498ed2000-07-11Martin Nilsson 
9bb83f2002-06-13Martin Nilsson  defvar("LogCO", 0, "Logging: Log to system console",
434bac2000-07-14Andreas Lange  TYPE_FLAG,
9bb83f2002-06-13Martin Nilsson  ("If set and syslog is used, the error/debug message " "will be printed to the system console as well as to the " "system log."),
690adf1999-08-30Per Hedbor  0, syslog_disabled);
f498ed2000-07-11Martin Nilsson 
9bb83f2002-06-13Martin Nilsson  defvar("LogST", "Daemon", "Logging: Syslog type",
434bac2000-07-14Andreas Lange  TYPE_STRING_LIST,
9bb83f2002-06-13Martin Nilsson  "When using SYSLOG, which log type should be used.",
434bac2000-07-14Andreas Lange  ({ "Daemon", "Local 0", "Local 1", "Local 2", "Local 3", "Local 4", "Local 5", "Local 6", "Local 7", "User" }), syslog_disabled);
9bb83f2002-06-13Martin Nilsson  defvar("LogWH", "Errors", "Logging: Log what to syslog",
434bac2000-07-14Andreas Lange  TYPE_STRING_LIST,
9bb83f2002-06-13Martin Nilsson  ("When syslog is used, how much should be sent to it?<br /><hr />" "Fatal: Only messages about fatal errors<br />" "Errors: Only error or fatal messages<br />" "Warning: Warning messages as well<br />" "Debug: Debug messager as well<br />" "All: Everything<br />"),
434bac2000-07-14Andreas Lange  ({ "Fatal", "Errors", "Warnings", "Debug", "All" }), syslog_disabled);
9bb83f2002-06-13Martin Nilsson  defvar("LogNA", "Roxen", "Logging: Log as",
434bac2000-07-14Andreas Lange  TYPE_STRING,
9bb83f2002-06-13Martin Nilsson  ("When syslog is used, this will be the identification " "of the Roxen daemon. The entered value will be appended to " "all logs."),
434bac2000-07-14Andreas Lange  0, syslog_disabled);
ab6f292000-11-18Martin Nilsson #endif // efun(syslog)
690adf1999-08-30Per Hedbor  #ifdef THREADS
9bb83f2002-06-13Martin Nilsson  defvar("numthreads", 5, "Number of threads to run",
434bac2000-07-14Andreas Lange  TYPE_INT,
9bb83f2002-06-13Martin Nilsson  ("The number of simultaneous threads Roxen will use.\n"
690adf1999-08-30Per Hedbor  "<p>Please note that even if this is one, Roxen will still " "be able to serve multiple requests, using a select loop based " "system.\n" "<i>This is quite useful if you have more than one CPU in "
b98c022001-07-31Per Hedbor  "your machine, or if you have a lot of slow NFS accesses.</i></p>" "<p>Do not increase this over 20 unless you have a " "very good reason to do so.</p>"));
ab6f292000-11-18Martin Nilsson #endif // THREADS
690adf1999-08-30Per Hedbor 
5627f12000-04-13Per Hedbor #ifndef __NT__
9bb83f2002-06-13Martin Nilsson  defvar("abs_engage", 0, "Auto Restart: Enable Anti-Block-System",
434bac2000-07-14Andreas Lange  TYPE_FLAG|VAR_MORE,
9bb83f2002-06-13Martin Nilsson  ("If set, the anti-block-system will be enabled. " "This will restart the server after a configurable number of minutes if it " "locks up. If you are running in a single threaded environment heavy " "calculations will also halt the server. In multi-threaded mode bugs such as " "eternal loops will not cause the server to reboot, since only one thread is " "blocked. In general there is no harm in having this option enabled. ")); defvar("abs_timeout", 5, "Auto Restart: ABS Timeout",
434bac2000-07-14Andreas Lange  TYPE_INT_LIST|VAR_MORE,
9bb83f2002-06-13Martin Nilsson  ("If the server is unable to accept connection for this many " "minutes, it will be restarted. You need to find a balance: " "if set too low, the server will be restarted even if it's doing " "legal things (like generating many images), if set too high you might " "get a long downtime if the server for some reason locks up."),
f498ed2000-07-11Martin Nilsson  ({1,2,3,4,5,10,15}),
8552d92001-01-13Martin Nilsson  lambda() {return !query("abs_engage");});
ab6f292000-11-18Martin Nilsson #endif // __NT__
690adf1999-08-30Per Hedbor 
9bb83f2002-06-13Martin Nilsson  // Keep for now...
dac5692000-09-19Andreas Lange  defvar("locale", Variable.Language("Standard", ({ "Standard" }) +
f9f2992002-06-14Martin Nilsson  Locale.list_languages("roxen_""config"),
9bb83f2002-06-13Martin Nilsson  0, "Default language", ("Locale, used to localize some " "messages in Roxen. Standard means using " "the default locale, which varies " "according to the value of " "the 'LANG' environment variable.")))
dac5692000-09-19Andreas Lange  ->set_changed_callback( lambda(Variable.Variable s) {
8552d92001-01-13Martin Nilsson  roxenp()->set_default_locale(query("locale"));
dac5692000-09-19Andreas Lange  roxenp()->set_locale(); } );
f498ed2000-07-11Martin Nilsson 
38b81e2001-01-06Martin Nilsson  string secret=Crypto.md5()->update(""+time(1)+random(100000))->digest(); secret = MIME.encode_base64(secret,1);
9bb83f2002-06-13Martin Nilsson  defvar("server_salt", secret[..sizeof(secret)-3], "Server secret",
b98c022001-07-31Per Hedbor  TYPE_STRING|VAR_MORE|VAR_NO_DEFAULT,
9bb83f2002-06-13Martin Nilsson  ("The server secret is a string used in some " "cryptographic functions, such as calculating " "unique, non-guessable session id's. Change this " "value into something that is hard to guess, unless " "you are satisfied with what your computers random " "generator has produced.") );
38b81e2001-01-06Martin Nilsson 
387fa62001-03-05Per Hedbor  secret = Crypto.md5()->update(""+time(1)+random(100000)+"x"+gethrtime()) ->digest();
b98c022001-07-31Per Hedbor  definvisvar("argcache_secret","",TYPE_STRING|VAR_NO_DEFAULT);
4d92a62001-03-16Per Hedbor  set( "argcache_secret", secret ); // force save.
9bb83f2002-06-13Martin Nilsson  defvar("suicide_engage", 0, "Auto Restart: Enable Automatic Restart",
f498ed2000-07-11Martin Nilsson  TYPE_FLAG|VAR_MORE,
9bb83f2002-06-13Martin Nilsson  ("If set, Roxen will automatically restart after a " "configurable number of days. Since Roxen uses a monolith, " "non-forking server model the process tends to grow in size " "over time. This is mainly due to heap fragmentation but " "may also sometimes be because of memory leaks.")
690adf1999-08-30Per Hedbor  );
f498ed2000-07-11Martin Nilsson 
d873a62001-08-22Per Hedbor  definvisvar( "last_suicide", 0, TYPE_INT ); defvar("suicide_schedule",
9bb83f2002-06-13Martin Nilsson  Variable.Schedule( ({ 2, 1, 1, 0, 4 }), 0, "Auto Restart: Schedule", "Automatically restart the " "server according to this schedule." ) )
d873a62001-08-22Per Hedbor  ->set_invisibility_check_callback ( lambda(RequestID id, Variable.Variable f) {return !query("suicide_engage");} );
690adf1999-08-30Per Hedbor 
95843d2000-12-01Martin Nilsson  defvar("mem_cache_gc",
9bb83f2002-06-13Martin Nilsson  Variable.Int(300, 0, "Cache: Memory Cache Garbage Collect Interval", ("The number of seconds between every garbage collect " "(removal of old content) from the memory cache. The " "memory cache is used for various tasks like remembering " "what supports flags matches what client."))) ->set_range(1, 60*60*24); // Note that the upper limit is arbitrary. defvar("replicate", 0, "Enable replication system",
e082212001-08-28Per Hedbor  TYPE_FLAG,
9bb83f2002-06-13Martin Nilsson  ("If enabled, Roxen will enable various replication systems " "needed to set up multiple frontend systems. You will need " "a database named 'replicate' that recides in a shared mysql " "server for this to work. Also, all servers has to have this " "flag set. Roxen must be restarted before changes to this " "variable takes effect." ) );
e082212001-08-28Per Hedbor 
9bb83f2002-06-13Martin Nilsson  defvar("config_file_comments", 0, "Commented config files",
f498ed2000-07-11Martin Nilsson  TYPE_FLAG,
9bb83f2002-06-13Martin Nilsson  ("Save the variable documentation strings as comments " "in the configuration files. Only useful if you read or " "edit the config files directly."));
6897c92001-06-27Honza Petrous  #ifdef SNMP_AGENT // SNMP stuffs
9bb83f2002-06-13Martin Nilsson  defvar("snmp_agent", 0, "SNMP: Enable SNMP agent",
6897c92001-06-27Honza Petrous  TYPE_FLAG|VAR_MORE,
9bb83f2002-06-13Martin Nilsson  "If set, the Roxen SNMP agent will be anabled.");
6897c92001-06-27Honza Petrous  defvar("snmp_community", ({"public:ro"}), "SNMP: Community string", TYPE_STRING_LIST, "One community name per line. Default permissions are 'read-only'. "
edab552002-01-11Henrik Grubbström (Grubba)  "'Read-write' permissions can be specified by appending :rw to the " "community name (for example mypub:rw).",
6897c92001-06-27Honza Petrous  0, snmp_disabled); /* defvar("snmp_mode", "smart", "SNMP: Agent mode", TYPE_STRING_LIST, "Standard SNMP server mode, muxed SNMP mode, " "proxy, agentx or automatic (smart) mode.", ({"smart", "agent", "agentx", "smux", "proxy" })); */
6f669a2001-08-14Honza Petrous  defvar("snmp_hostport", snmp_get_cif_domain(), "SNMP: IP address and port",
6897c92001-06-27Honza Petrous  TYPE_STRING,
edab552002-01-11Henrik Grubbström (Grubba)  "Agent listening IP adress and port. Format: [[host]:port] "
0fa67e2002-06-15Martin Nilsson  "If host isn't set then the IP address of the administration interface "
edab552002-01-11Henrik Grubbström (Grubba)  "will be used.",
6897c92001-06-27Honza Petrous  0, snmp_disabled);
77efe62001-09-11Honza Petrous  defvar("snmp_global_traphosts", ({}),"SNMP: Trap destinations", TYPE_STRING_LIST, "The SNMP traphost URL for sending common traps (like coldstart).",
6897c92001-06-27Honza Petrous  0, snmp_disabled);
77efe62001-09-11Honza Petrous 
6897c92001-06-27Honza Petrous  defvar("snmp_syscontact","","SNMP: System MIB - Contact", TYPE_STRING, "The textual identification of the contact person for this managed " "node, together with information on how to contact this person.", 0, snmp_disabled); defvar("snmp_sysname","","SNMP: System MIB - Name", TYPE_STRING, "An administratively-assigned name for this managed node. By " "convention, this is the node's fully-qualified domain name.", 0, snmp_disabled); defvar("snmp_syslocation","","SNMP: System MIB - Location", TYPE_STRING, "The physical location of this node (e.g., `telephone closet, 3rd " "floor').", 0, snmp_disabled); defvar("snmp_sysservices",72,"SNMP: System MIB - Services", TYPE_INT, "A value which indicates the set of services that this entity " "primarily offers.", 0, snmp_disabled); #endif // SNMP_AGENT
6f669a2001-08-14Honza Petrous  defvar("global_position", Variable.Variable(0, VAR_INVISIBLE));
690adf1999-08-30Per Hedbor }
f4b6251999-09-02Per Hedbor 
3bb11d2000-07-09Per Hedbor void restore_global_variables() {
4d92a62001-03-16Per Hedbor  mapping m = retrieve("Variables", 0);
3bb11d2000-07-09Per Hedbor  setvars(retrieve("Variables", 0));
4d92a62001-03-16Per Hedbor  if( !m->argcache_secret ) save();
40889a2000-09-19Per Hedbor  old_module_dirs = query( "ModuleDirs" ); getvar( "ModuleDirs" )->add_changed_callback( zap_all_module_caches );
3bb11d2000-07-09Per Hedbor }
e35de22000-03-10Martin Nilsson static mapping(string:mixed) __vars = ([ ]);
f4b6251999-09-02Per Hedbor  // These two should be documented somewhere. They are to be used to
c5e0961999-10-04Per Hedbor // set global, but non-persistent, variables in Roxen.
f4b6251999-09-02Per Hedbor mixed set_var(string var, mixed to) { return __vars[var] = to; } mixed query_var(string var) { return __vars[var]; }