24c6c12000-02-20Martin Nilsson // This file is part of Roxen Webserver. // Copyright © 1996 - 2000, Roxen IS.
387fa62001-03-05Per Hedbor // $Id: global_variables.pike,v 1.65 2001/03/05 18:18:41 per Exp $
e35de22000-03-10Martin Nilsson 
a59d252000-07-04Per Hedbor /*
e35de22000-03-10Martin Nilsson #pragma strict_types
a59d252000-07-04Per Hedbor */
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 #include <module.h> inherit "read_config";
3bb11d2000-07-09Per Hedbor inherit "basic_defvar";
7d2baf2000-02-02Martin Stjernholm #include <version.h>
23414a2000-07-21Andreas Lange //<locale-token project="roxen_config">LOCALE</locale-token> #define LOCALE(X,Y) _DEF_LOCALE("roxen_config",X,Y)
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 
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,
55a8662000-11-20Per Hedbor  LOCALE(309,"Require user with the 'hilfe' permission"), TYPE_FLAG, LOCALE(310,"If yes, require a user with the hilfe permission "
e056e92000-10-19Per Hedbor  "set, otherwise, any configuration interface user will " "work, even one with only the view settings permission" ) ); }
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",
23414a2000-07-21Andreas Lange  LOCALE(60, "Welcome text"), TYPE_TEXT, LOCALE(61, "The text shown to the user on connect") );
934b3f2000-02-04Per Hedbor 
23414a2000-07-21Andreas Lange  defvar( "ftp_user_session_limit", 0, LOCALE(62, "User session limit"),
434bac2000-07-14Andreas Lange  TYPE_INT,
23414a2000-07-21Andreas Lange  LOCALE(63, "The maximum number of times a user can connect at once."
f498ed2000-07-11Martin Nilsson  " 0 means unlimited.") );
934b3f2000-02-04Per Hedbor 
23414a2000-07-21Andreas Lange  defvar( "named_ftp", 1, LOCALE(64, "Allow named ftp"), TYPE_FLAG, LOCALE(65, "If yes, non-anonymous users can connect") );
934b3f2000-02-04Per Hedbor 
434bac2000-07-14Andreas Lange  defvar( "guest_ftp", 1,
23414a2000-07-21Andreas Lange  LOCALE(66, "Allow login with incorrect password/user"),
434bac2000-07-14Andreas Lange  TYPE_FLAG,
23414a2000-07-21Andreas Lange  LOCALE(67, "If yes, users can connect with the wrong password "
434bac2000-07-14Andreas Lange  "and/or username. This is useful since things like .htaccess " "files can later on authenticate the user."));
934b3f2000-02-04Per Hedbor 
23414a2000-07-21Andreas Lange  defvar( "anonymous_ftp", 1, LOCALE(68, "Allow anonymous ftp"),
434bac2000-07-14Andreas Lange  TYPE_FLAG,
23414a2000-07-21Andreas Lange  LOCALE(69, "If yes, anonymous users is allowed to connect.") );
934b3f2000-02-04Per Hedbor 
23414a2000-07-21Andreas Lange  defvar( "shells", "", LOCALE(70, "Shell database"),
434bac2000-07-14Andreas Lange  TYPE_FILE,
23414a2000-07-21Andreas Lange  LOCALE(71, "If this string is set to anything but the empty string, "
934b3f2000-02-04Per Hedbor  "it should point to a file containing a list of valid shells. " "Users with shells that does not figure in this list will not "
f498ed2000-07-11Martin Nilsson  "be allowed to log in.") );
934b3f2000-02-04Per Hedbor }
3e3bab2001-01-19Per Hedbor void set_up_http_variables( Protocol o, int|void fhttp )
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; }; };
c96d642001-03-05Martin Nilsson  defvar( "minimum_bitrate", 0, LOCALE(205, "Minumum allowed bitrate" ),
9c19002001-02-27Per Hedbor  TYPE_INT,
c96d642001-03-05Martin Nilsson  LOCALE(215, "The minimum allowed bitrate, in Kbits/second. If the "
9c19002001-02-27Per Hedbor  "client is slower than this set bitrate, it will be " "disconnected (after a timeout). Setting this higher than " "14 is not recommended if you have modem users."));
23414a2000-07-21Andreas Lange  defvar("show_internals", 1, LOCALE(72, "Show internal errors"),
434bac2000-07-14Andreas Lange  TYPE_FLAG,
23414a2000-07-21Andreas Lange  LOCALE(73, "Show 'Internal server error' messages to the user. "
f498ed2000-07-11Martin Nilsson  "This is very useful if you are debugging your own modules " "or writing Pike scripts."));
472b152000-02-08Per Hedbor  if(!fhttp) {
23414a2000-07-21Andreas Lange  defvar("set_cookie", 0, LOCALE(74, "Logging: Set unique user id cookies"),
434bac2000-07-14Andreas Lange  TYPE_FLAG,
23414a2000-07-21Andreas Lange  LOCALE(75, "If set to Yes, all users of your server whose clients "
434bac2000-07-14Andreas Lange  "support cookies will get a unique 'user-id-cookie', this " "can then be used in the log and in scripts to track " "individual users.")); defvar("set_cookie_only_once", 1,
23414a2000-07-21Andreas Lange  LOCALE(76, "Logging: Set ID cookies only once"),
472b152000-02-08Per Hedbor  TYPE_FLAG,
23414a2000-07-21Andreas Lange  LOCALE(77, "If set to Yes, Roxen will attempt to set unique user "
434bac2000-07-14Andreas Lange  "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 "
3ea9f32001-01-29Per Hedbor  "multiple requests."),0, do_set_cookie( o ));
472b152000-02-08Per Hedbor  } }
3e3bab2001-01-19Per Hedbor void set_up_fhttp_variables( Protocol o )
472b152000-02-08Per Hedbor {
de4b592001-01-21Martin Nilsson  function(BDEFVAR) defvar = o->defvar;
434bac2000-07-14Andreas Lange 
23414a2000-07-21Andreas Lange  defvar( "log", "None", LOCALE(78, "Logging method"),
434bac2000-07-14Andreas Lange  TYPE_STRING_LIST,
23414a2000-07-21Andreas Lange  LOCALE(79, "None - No log<br />"
434bac2000-07-14Andreas Lange  "CommonLog - A common log in a file<br />"
23414a2000-07-21Andreas Lange  "Compat - Log through Roxen's normal logging format.<br />" "<p>Please note that compat limits Roxen to less than 1k "
434bac2000-07-14Andreas Lange  "requests/second.</p>"), ({ "None", "CommonLog", "Compat" }));
472b152000-02-08Per Hedbor 
de4b592001-01-21Martin Nilsson  defvar( "log_file", "$LOGDIR/clog-"+o->ip+":"+o->port,
23414a2000-07-21Andreas Lange  LOCALE(80, "Log file"),
434bac2000-07-14Andreas Lange  TYPE_FILE,
23414a2000-07-21Andreas Lange  LOCALE(81, "This file is used if logging is done using the "
434bac2000-07-14Andreas Lange  "CommonLog method."));
23414a2000-07-21Andreas Lange  defvar( "ram_cache", 20, LOCALE(82, "Ram cache"),
434bac2000-07-14Andreas Lange  TYPE_INT,
23414a2000-07-21Andreas Lange  LOCALE(83, "The size of the ram cache, in MegaBytes"));
472b152000-02-08Per Hedbor 
23414a2000-07-21Andreas Lange  defvar( "read_timeout", 120, LOCALE(84, "Client timeout"),
434bac2000-07-14Andreas Lange  TYPE_INT,
23414a2000-07-21Andreas Lange  LOCALE(85, "The maximum time Roxen will wait for a client "
434bac2000-07-14Andreas Lange  "before giving up, and close the connection, in seconds"));
472b152000-02-08Per Hedbor  set_up_http_variables( o,1 ); }
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  defvar( "ssl_cert_file", "demo_certificate.pem",
23414a2000-07-21Andreas Lange  LOCALE(86, "SSL certificate file"),
434bac2000-07-14Andreas Lange  TYPE_STRING,
23414a2000-07-21Andreas Lange  sprintf(LOCALE(87, "The SSL certificate file to use. The path " "is relative to %s")+"\n", getcwd() ));
434bac2000-07-14Andreas Lange 
23414a2000-07-21Andreas Lange  defvar( "ssl_key_file", "", LOCALE(88, "SSL key file"),
434bac2000-07-14Andreas Lange  TYPE_STRING,
23414a2000-07-21Andreas Lange  sprintf(LOCALE(89, "The SSL key file to use. The path is "
434bac2000-07-14Andreas Lange  "relative to %s, you do not have to specify a key " "file, leave this field empty to use the certificate "
23414a2000-07-21Andreas Lange  "file only")+"\n", getcwd() ));
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,
23414a2000-07-21Andreas Lange  LOCALE(90, "Logging: Log entire file length in restored connections"),
434bac2000-07-14Andreas Lange  TYPE_FLAG,
23414a2000-07-21Andreas Lange  LOCALE(91, "If this toggle is enabled log entries for restored connections "
690adf1999-08-30Per Hedbor  "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 "
1dd64a2000-09-19Mattias Wingstedt  "statistics in Roxen will still be correct."));
e6f83d2000-03-06Peter Bortas 
8d04b22000-09-19Per Hedbor  defvar("default_font", "roxen builtin", LOCALE(92, "Default font"),
434bac2000-07-14Andreas Lange  TYPE_FONT,
23414a2000-07-21Andreas Lange  LOCALE(93, "The default font to use when modules request a font."));
690adf1999-08-30Per Hedbor 
390d342000-12-12Per Hedbor  defvar("font_dirs", ({"../local/nfonts/", "nfonts/" })+
7600962000-12-16Per Hedbor #ifdef __NT__ ({combine_path(replace(getenv("SystemRoot"),"\\","/"),"fonts/")}) #else ((getenv("RX_FONTPATH")||"")/","-({""})) #endif , LOCALE(94, "Font directories"),
434bac2000-07-14Andreas Lange  TYPE_DIR_LIST,
23414a2000-07-21Andreas Lange  LOCALE(95, "This is where the fonts are located."));
690adf1999-08-30Per Hedbor 
434bac2000-07-14Andreas Lange  defvar("logdirprefix", "../logs/",
23414a2000-07-21Andreas Lange  LOCALE(96, "Logging: Log directory prefix"),
434bac2000-07-14Andreas Lange  TYPE_STRING|VAR_MORE,
23414a2000-07-21Andreas Lange  LOCALE(97, "This is the default file path that will be prepended "
434bac2000-07-14Andreas Lange  "to the log file path in all the default modules and the "
1dd64a2000-09-19Mattias Wingstedt  "site."));
f498ed2000-07-11Martin Nilsson 
23414a2000-07-21Andreas Lange  defvar("cache", 0, LOCALE(98, "Cache: Proxy Disk Cache Enabled"),
434bac2000-07-14Andreas Lange  TYPE_FLAG,
23414a2000-07-21Andreas Lange  LOCALE(99, "If set to Yes, caching will be enabled."));
f498ed2000-07-11Martin Nilsson 
b9a7022000-07-15Andreas Lange  defvar("garb_min_garb", 1,
23414a2000-07-21Andreas Lange  LOCALE(100, "Cache: Proxy Disk Cache Clean size"),
434bac2000-07-14Andreas Lange  TYPE_INT,
23414a2000-07-21Andreas Lange  LOCALE(101, "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,
23414a2000-07-21Andreas Lange  LOCALE(102, "Cache: Proxy Disk Cache Minimum available free space and inodes (in %)"),
434bac2000-07-14Andreas Lange  TYPE_INT,
23414a2000-07-21Andreas Lange  LOCALE(103, "If less than this amount of disk space or inodes (in %) "
434bac2000-07-14Andreas Lange  "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  );
23414a2000-07-21Andreas Lange  defvar("cache_size", 25, LOCALE(104, "Cache: Proxy Disk Cache Size"),
434bac2000-07-14Andreas Lange  TYPE_INT,
23414a2000-07-21Andreas Lange  LOCALE(105, "How many MB may the cache grow to before a garbage "
434bac2000-07-14Andreas Lange  "collect is done?"), 0, cache_disabled_p);
b9a7022000-07-15Andreas Lange  defvar("cache_max_num_files", 0,
23414a2000-07-21Andreas Lange  LOCALE(106, "Cache: Proxy Disk Cache Maximum number of files"),
434bac2000-07-14Andreas Lange  TYPE_INT,
23414a2000-07-21Andreas Lange  LOCALE(107, "How many cache files (inodes) may be on disk before "
434bac2000-07-14Andreas Lange  "a garbage collect is done ? May be left zero to disable " "this check."), 0, cache_disabled_p);
b9a7022000-07-15Andreas Lange  defvar("bytes_per_second", 50,
23414a2000-07-21Andreas Lange  LOCALE(108, "Cache: Proxy Disk Cache bytes per second"),
434bac2000-07-14Andreas Lange  TYPE_INT,
23414a2000-07-21Andreas Lange  LOCALE(109, "How file size should be treated during garbage collect. "
434bac2000-07-14Andreas Lange  "Each X bytes counts as a second, so that larger files will " "be removed first."),
690adf1999-08-30Per Hedbor  0, cache_disabled_p);
a59d252000-07-04Per Hedbor  defvar("cachedir", "/tmp/roxen_cache/",
23414a2000-07-21Andreas Lange  LOCALE(110, "Cache: Proxy Disk Cache Base Cache Dir"),
690adf1999-08-30Per Hedbor  TYPE_DIR,
23414a2000-07-21Andreas Lange  LOCALE(111, "This is the base directory where cached files will "
434bac2000-07-14Andreas Lange  "reside. To avoid mishaps, 'roxen_cache/' is always " "prepended to this variable."), 0, cache_disabled_p);
690adf1999-08-30Per Hedbor 
a59d252000-07-04Per Hedbor  defvar("hash_num_dirs", 500,
23414a2000-07-21Andreas Lange  LOCALE(112, "Cache: Proxy Disk Cache Number of hash directories"),
434bac2000-07-14Andreas Lange  TYPE_INT|VAR_MORE,
23414a2000-07-21Andreas Lange  LOCALE(113, "This is the number of directories to hash the contents "
434bac2000-07-14Andreas Lange  "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."), 0, cache_disabled_p);
b9a7022000-07-15Andreas Lange  defvar("cache_keep_without_content_length", 1,
23414a2000-07-21Andreas Lange  LOCALE(114, "Cache: Proxy Disk Cache Keep without Content-Length"),
434bac2000-07-14Andreas Lange  TYPE_FLAG,
23414a2000-07-21Andreas Lange  LOCALE(115, "Keep files without Content-Length header information "
434bac2000-07-14Andreas Lange  "in the cache?"), 0, cache_disabled_p);
b9a7022000-07-15Andreas Lange  defvar("cache_check_last_modified", 0,
23414a2000-07-21Andreas Lange  LOCALE(116, "Cache: Proxy Disk Cache Refreshes on Last-Modified"),
434bac2000-07-14Andreas Lange  TYPE_FLAG,
23414a2000-07-21Andreas Lange  LOCALE(117, "If set, refreshes files without Expire header "
434bac2000-07-14Andreas Lange  "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."), 0, cache_disabled_p);
b9a7022000-07-15Andreas Lange  defvar("cache_last_resort", 0,
23414a2000-07-21Andreas Lange  LOCALE(118, "Cache: Proxy Disk Cache Last resort (in days)"),
434bac2000-07-14Andreas Lange  TYPE_INT,
23414a2000-07-21Andreas Lange  LOCALE(119, "How many days shall files without Expires and without "
434bac2000-07-14Andreas Lange  "Last-Modified header information be kept?"), 0, cache_disabled_p);
690adf1999-08-30Per Hedbor 
a59d252000-07-04Per Hedbor  defvar("cache_gc_logfile", "",
23414a2000-07-21Andreas Lange  LOCALE(120, "Cache: Proxy Disk Cache Garbage collector logfile"),
434bac2000-07-14Andreas Lange  TYPE_FILE,
23414a2000-07-21Andreas Lange  LOCALE(121, "Information about garbage collector runs, removed and "
434bac2000-07-14Andreas Lange  "refreshed files, cache and disk status goes here."), 0, cache_disabled_p);
690adf1999-08-30Per Hedbor  /// End of cache variables..
23414a2000-07-21Andreas Lange  defvar("pidfile", "/tmp/roxen_pid_$uid", LOCALE(122, "PID file"),
434bac2000-07-14Andreas Lange  TYPE_FILE|VAR_MORE,
23414a2000-07-21Andreas Lange  LOCALE(123, "In this file, the server will write out it's PID, and "
434bac2000-07-14Andreas Lange  "the PID of the start script. $pid will be replaced with the " "pid, and $uid with the uid of the user running the process.\n"
23414a2000-07-21Andreas Lange  "<br />Note: It can be overridden by the command line option."));
434bac2000-07-14Andreas Lange 
f498ed2000-07-11Martin Nilsson  // FIXME: Should mention real_version.
434bac2000-07-14Andreas Lange  defvar("default_ident", 1,
23414a2000-07-21Andreas Lange  LOCALE(124, "Identify, Use default identification string"),
434bac2000-07-14Andreas Lange  TYPE_FLAG|VAR_MORE,
8148ed2000-09-13Andreas Lange  LOCALE(125, "Setting this variable to No will display the " "\"Identify as\" node where you can state what Roxen "
434bac2000-07-14Andreas Lange  "should call itself when talking to clients.<br />"
8148ed2000-09-13Andreas Lange  "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>"));
434bac2000-07-14Andreas Lange  defvar("ident", replace(real_version," ","·"),
23414a2000-07-21Andreas Lange  LOCALE(126, "Identify, Identify as"),
434bac2000-07-14Andreas Lange  TYPE_STRING /* |VAR_MORE */,
23414a2000-07-21Andreas Lange  LOCALE(127, "Enter the name that Roxen should use when talking to clients. "),
434bac2000-07-14Andreas Lange  0, ident_disabled_p);
23414a2000-07-21Andreas Lange  defvar("User", "", LOCALE(128, "Change uid and gid to"),
434bac2000-07-14Andreas Lange  TYPE_STRING,
8148ed2000-09-13Andreas Lange  LOCALE(129, "When Roxen is run as root, to be able to open port 80 "
434bac2000-07-14Andreas Lange  "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]."));
23414a2000-07-21Andreas Lange  defvar("permanent_uid", 0, LOCALE(130, "Change uid and gid permanently"),
434bac2000-07-14Andreas Lange  TYPE_FLAG,
8148ed2000-09-13Andreas Lange  LOCALE(131, "If this variable is set, Roxen will set it's uid and gid " "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 
f498ed2000-07-11Martin Nilsson  // FIXME: Should mention getcwd()
a59d252000-07-04Per Hedbor  defvar("ModuleDirs", ({ "../local/modules/", "modules/" }),
23414a2000-07-21Andreas Lange  LOCALE(132, "Module directories"),
434bac2000-07-14Andreas Lange  TYPE_DIR_LIST,
23414a2000-07-21Andreas Lange  LOCALE(133, "This is a list of directories where Roxen should look "
434bac2000-07-14Andreas Lange  "for modules. Can be relative paths, from the "
23414a2000-07-21Andreas Lange  "directory you started Roxen. "
434bac2000-07-14Andreas Lange  "The directories are searched in order for modules."));
690adf1999-08-30Per Hedbor 
ab6f292000-11-18Martin Nilsson  defvar("Supports", Variable.Text( "#include <etc/supports>\n", VAR_MORE, LOCALE(134, "Client supports regexps"), LOCALE(135, "What do the different clients support?\n<br />" "The default information is normally fetched from the file " "server/etc/supports in your Roxen directory.") ) ) -> add_changed_callback( lambda(Variable.Text s) { roxenp()->initiate_supports(); cache.cache_expire("supports"); } );
f498ed2000-07-11Martin Nilsson 
23414a2000-07-21Andreas Lange  defvar("audit", 0, LOCALE(136, "Logging: Audit trail"),
434bac2000-07-14Andreas Lange  TYPE_FLAG,
23414a2000-07-21Andreas Lange  LOCALE(137, "If Audit trail is set to Yes, all changes of uid will be "
434bac2000-07-14Andreas Lange  "logged in the Event log."));
690adf1999-08-30Per Hedbor 
5ffd492000-02-02Per Hedbor #if efun(syslog)
1dd64a2000-09-19Mattias Wingstedt  defvar("LogA", "file", LOCALE(138, "Logging: Debug log method"),
434bac2000-07-14Andreas Lange  TYPE_STRING_LIST|VAR_MORE,
1dd64a2000-09-19Mattias Wingstedt  LOCALE(139, "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 
23414a2000-07-21Andreas Lange  defvar("LogSP", 1, LOCALE(140, "Logging: Log PID"),
434bac2000-07-14Andreas Lange  TYPE_FLAG,
23414a2000-07-21Andreas Lange  LOCALE(141, "If set, the PID will be included in the syslog."), 0,
434bac2000-07-14Andreas Lange  syslog_disabled);
f498ed2000-07-11Martin Nilsson 
23414a2000-07-21Andreas Lange  defvar("LogCO", 0, LOCALE(142, "Logging: Log to system console"),
434bac2000-07-14Andreas Lange  TYPE_FLAG,
23414a2000-07-21Andreas Lange  LOCALE(143, "If set and syslog is used, the error/debug message "
434bac2000-07-14Andreas Lange  "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 
23414a2000-07-21Andreas Lange  defvar("LogST", "Daemon", LOCALE(144, "Logging: Syslog type"),
434bac2000-07-14Andreas Lange  TYPE_STRING_LIST,
23414a2000-07-21Andreas Lange  LOCALE(145, "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);
23414a2000-07-21Andreas Lange  defvar("LogWH", "Errors", LOCALE(146, "Logging: Log what to syslog"),
434bac2000-07-14Andreas Lange  TYPE_STRING_LIST,
23414a2000-07-21Andreas Lange  LOCALE(147, "When syslog is used, how much should be sent to it?<br /><hr />"
434bac2000-07-14Andreas Lange  "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 />"), ({ "Fatal", "Errors", "Warnings", "Debug", "All" }), syslog_disabled);
23414a2000-07-21Andreas Lange  defvar("LogNA", "Roxen", LOCALE(148, "Logging: Log as"),
434bac2000-07-14Andreas Lange  TYPE_STRING,
23414a2000-07-21Andreas Lange  LOCALE(149, "When syslog is used, this will be the identification "
434bac2000-07-14Andreas Lange  "of the Roxen daemon. The entered value will be appended to " "all logs."), 0, syslog_disabled);
ab6f292000-11-18Martin Nilsson #endif // efun(syslog)
690adf1999-08-30Per Hedbor  #ifdef THREADS
23414a2000-07-21Andreas Lange  defvar("numthreads", 5, LOCALE(150, "Number of threads to run"),
434bac2000-07-14Andreas Lange  TYPE_INT,
23414a2000-07-21Andreas Lange  LOCALE(151, "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 "
f498ed2000-07-11Martin Nilsson  "your machine, or if you have a lot of slow NFS accesses.</i></p>"));
ab6f292000-11-18Martin Nilsson #endif // THREADS
690adf1999-08-30Per Hedbor 
5627f12000-04-13Per Hedbor #ifndef __NT__
23414a2000-07-21Andreas Lange  defvar("abs_engage", 0, LOCALE(154, "ABS: Enable Anti-Block-System"),
434bac2000-07-14Andreas Lange  TYPE_FLAG|VAR_MORE,
23414a2000-07-21Andreas Lange  LOCALE(155, "If set, the anti-block-system will be enabled. "
f498ed2000-07-11Martin Nilsson  "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. "));
23414a2000-07-21Andreas Lange  defvar("abs_timeout", 5, LOCALE(156, "ABS: Timeout"),
434bac2000-07-14Andreas Lange  TYPE_INT_LIST|VAR_MORE,
23414a2000-07-21Andreas Lange  LOCALE(157, "If the server is unable to accept connection for this many "
f498ed2000-07-11Martin Nilsson  "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."), ({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 
dac5692000-09-19Andreas Lange  defvar("locale", Variable.Language("Standard", ({ "Standard" }) + Locale.list_languages("roxen_config"), 0, LOCALE(158, "Default language"), LOCALE(159, "Locale, used to localize all " "messages in Roxen. Standard means using " "the default locale, which varies " "according to the value of " "the 'LANG' environment variable."))) ->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);
f218252001-01-14Per Hedbor  defvar("server_salt", secret[..sizeof(secret)-3], LOCALE(8, "Server secret"),
38b81e2001-01-06Martin Nilsson  TYPE_STRING|VAR_MORE,
f218252001-01-14Per Hedbor  LOCALE(9, "The server secret is a string used in some "
38b81e2001-01-06Martin Nilsson  "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") );
387fa62001-03-05Per Hedbor  secret = Crypto.md5()->update(""+time(1)+random(100000)+"x"+gethrtime()) ->digest(); definvisvar("argcache_secret",secret,TYPE_STRING);
f498ed2000-07-11Martin Nilsson  defvar("suicide_engage", 0,
23414a2000-07-21Andreas Lange  LOCALE(160, "Auto Restart: Enable Automatic Restart"),
f498ed2000-07-11Martin Nilsson  TYPE_FLAG|VAR_MORE,
23414a2000-07-21Andreas Lange  LOCALE(161, "If set, Roxen will automatically restart after a "
434bac2000-07-14Andreas Lange  "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 also "
f498ed2000-07-11Martin Nilsson  "because of memory leaks.")
690adf1999-08-30Per Hedbor  );
f498ed2000-07-11Martin Nilsson  defvar("suicide_timeout", 7,
23414a2000-07-21Andreas Lange  LOCALE(162, "Auto Restart: Timeout"),
434bac2000-07-14Andreas Lange  TYPE_INT_LIST|VAR_MORE,
23414a2000-07-21Andreas Lange  LOCALE(163, "Automatically restart the server after this many days."),
434bac2000-07-14Andreas Lange  ({1,2,3,4,5,6,7,14,30}),
8552d92001-01-13Martin Nilsson  lambda(){return !query("suicide_engage");});
690adf1999-08-30Per Hedbor 
95843d2000-12-01Martin Nilsson  defvar("mem_cache_gc", Variable.Int(300, 0, LOCALE(170, "Cache: Memory Cache Garbage Collect Interval"), LOCALE(171, "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 remebering " "what supports flags matches what client."))) ->set_range(1, 60*60*24); // Note that the upper limit is arbitrary.
9d72c41999-08-30Per Hedbor 
a59d252000-07-04Per Hedbor  defvar("config_file_comments", 0,
23414a2000-07-21Andreas Lange  LOCALE(172, "Commented config files"),
f498ed2000-07-11Martin Nilsson  TYPE_FLAG,
23414a2000-07-21Andreas Lange  LOCALE(173, "Save the variable documentation strings as comments "
434bac2000-07-14Andreas Lange  "in the configuration files. Only useful if you read or " "edit the config files directly."));
d37d5a2000-12-08Martin Nilsson  defvar("global_position", Variable.Variable(0, VAR_INVISIBLE));
690adf1999-08-30Per Hedbor }
f4b6251999-09-02Per Hedbor 
3bb11d2000-07-09Per Hedbor void restore_global_variables() { setvars(retrieve("Variables", 0));
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]; }