835c6c2001-06-17Martin Nilsson // This file is part of Roxen WebServer.
b655bf2004-06-30Martin Stjernholm // Copyright © 1996 - 2004, Roxen IS.
687d942007-06-12 Erik Dahl // $Id: global_variables.pike,v 1.100 2007/06/12 12:13:21 erikd Exp $
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 #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 
0778da2006-10-27Martin Stjernholm static void cdt_changed (Variable v);
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()||"")->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,
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 "
edab552002-01-11Henrik Grubbström (Grubba)  "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",
23414a2000-07-21Andreas Lange  LOCALE(60, "Welcome text"), TYPE_TEXT,
edab552002-01-11Henrik Grubbström (Grubba)  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,
9b17bb2003-11-26Henrik Grubbström (Grubba)  LOCALE(65, "If yes, non-anonymous users can connect. " "Note that for password authentication to be performed " "you will need to have the \"Authentication: Password\" " "module in your site.") );
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,
edab552002-01-11Henrik Grubbström (Grubba)  LOCALE(69, "If yes, anonymous users are 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, "
f4420e2002-01-11Henrik Grubbström (Grubba)  "it should specify a file containing a list of valid shells. " "Users with shells that are not in this list will not "
f498ed2000-07-11Martin Nilsson  "be allowed to log in.") );
965a6d2001-04-14Henrik Grubbström (Grubba) 
89d1d82001-05-16Martin Nilsson  defvar( "passive_port_min", 0, LOCALE(257, "Passive port minimum"),
965a6d2001-04-14Henrik Grubbström (Grubba)  TYPE_INT,
89d1d82001-05-16Martin Nilsson  LOCALE(320, "Minimum port number to use in the PASV/EPSV response."));
965a6d2001-04-14Henrik Grubbström (Grubba) 
89d1d82001-05-16Martin Nilsson  defvar( "passive_port_max", 65535, LOCALE(321, "Passive port maximum"),
965a6d2001-04-14Henrik Grubbström (Grubba)  TYPE_INT,
89d1d82001-05-16Martin Nilsson  LOCALE(322, "Maximum port number to use in the PASV/EPSV response."));
e3d2ec2005-04-25Henrik Grubbström (Grubba) 
359cc02005-09-30Anders Johansson  defvar( "rfc2428_support", 1, LOCALE(518, "Support EPRT/EPSV"),
e3d2ec2005-04-25Henrik Grubbström (Grubba)  TYPE_FLAG,
359cc02005-09-30Anders Johansson  LOCALE(528, "Enable support for the EPRT and EPSV commands (RFC2428)."
e3d2ec2005-04-25Henrik Grubbström (Grubba)  "Some firewalls don't handle these commands properly, " "so depending on your network configuration you may need " "to disable them. "));
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; }; };
d21e382001-06-01Jonas Wallden  defvar( "minimum_bitrate", 0, LOCALE(205, "Minimum allowed bitrate" ),
9c19002001-02-27Per Hedbor  TYPE_INT,
b7bf512001-08-20Per Hedbor  LOCALE(215, "The minimum allowed bitrate, in bits/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 "
b7bf512001-08-20Per Hedbor  "14000 is not recommended if you have modem users."));
9c19002001-02-27Per Hedbor 
fff9e52002-04-24Martin Stjernholm  defvar("show_internals", 0, 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 
dddb612001-09-29Martin Nilsson  defvar("set_cookie", 0, LOCALE(74, "Logging: Set unique browser id cookies"),
bc0dec2001-08-05Martin Nilsson  TYPE_FLAG,
4ed0992003-01-15Henrik Grubbström (Grubba)  LOCALE(75, "If set to Yes, all clients that accept cookies will get "
dddb612001-09-29Martin Nilsson  "a unique 'user-id-cookie', which can then be used in the log " "and in scripts to track individual users."));
472b152000-02-08Per Hedbor 
bc0dec2001-08-05Martin Nilsson  defvar("set_cookie_only_once", 1, LOCALE(76, "Logging: Set ID cookies only once"), TYPE_FLAG,
dddb612001-09-29Martin Nilsson  LOCALE(77, "If set to Yes, Roxen will attempt to set unique browser "
bc0dec2001-08-05Martin Nilsson  "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 
85fbbc2004-08-19Henrik Grubbström (Grubba)  defvar( "ssl_cert_file", o->CertificateListVariable ( ({ "demo_certificate.pem" }), 0, LOCALE(86, "SSL certificate file"), LOCALE(87, "The SSL certificate file(s) to use. " "If a path is relative, it will first be " "searched for relative to %s, " "and if not found there relative to %s. "))); defvar( "ssl_key_file", o->KeyFileVariable ( "", 0, LOCALE(88, "SSL key file"), LOCALE(89, "The SSL key file to use. If the path is " "relative, it will first be searched for " "relative to %s, and if not found there " "relative to %s. " "You do not have to specify a key " "file, leave this field empty to use the " "certificate file only.")));
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 "
edab552002-01-11Henrik Grubbström (Grubba)  "statistics in Roxen will still be correct.</p>"));
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 
b5fe392005-12-21Fredrik Noring  defvar("font_dirs", ({ combine_path(getenv("LOCALDIR") || "../local", "fonts/"), "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 
a1fee32002-08-16Mattias Andersson  defvar("font_oversampling", 1, LOCALE(521, "Font oversampling"),
b012c22002-08-16Mattias Andersson  TYPE_FLAG,
a1fee32002-08-16Mattias Andersson  LOCALE(522, "If set to Yes, fonts will be oversampled resulting "
b012c22002-08-16Mattias Andersson  "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."));
b5fe392005-12-21Fredrik Noring  defvar("logdirprefix", getenv("LOGDIR") || "../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 "
edab552002-01-11Henrik Grubbström (Grubba)  "a garbage collect is done? May be left at zero to disable "
434bac2000-07-14Andreas Lange  "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. "
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/",
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 "
edab552002-01-11Henrik Grubbström (Grubba)  "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,
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 "
edab552002-01-11Henrik Grubbström (Grubba)  "of the disk cache into. Changing this value currently "
434bac2000-07-14Andreas Lange  "invalidates the whole cache, since the cache cannot find "
edab552002-01-11Henrik Grubbström (Grubba)  "the old files. In the future, the cache will be "
434bac2000-07-14Andreas Lange  "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..
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);
687d942007-06-12 Erik Dahl  defvar("config_header_string", "", LOCALE(0, "Show this string in header"), TYPE_STRING /* |VAR_MORE */, LOCALE(0, "Enter a identifier that will be displayed in the head of " " config interface. This makes it easier to distinguish " "between different site configurations. "), 0);
23414a2000-07-21Andreas Lange  defvar("User", "", LOCALE(128, "Change uid and gid to"),
434bac2000-07-14Andreas Lange  TYPE_STRING,
b39ccb2001-08-24Martin Stjernholm  LOCALE(129, #"\ 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. The start script attempts to fix this for the standard file locations.</p>"));
434bac2000-07-14Andreas Lange 
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 
b5fe392005-12-21Fredrik Noring  defvar("ModuleDirs", ({ combine_path(getenv("LOCALDIR") || "../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 
0778da2006-10-27Martin Stjernholm  Variable v = Variable.Flag (0, 0, LOCALE(0, "Logging: Dump threads by file polling"), LOCALE(0, #"\ <p>This option can be used to produce dumps of all the threads in the debug log in situations where the Administration Interface doesn't respond.</p> <p>It works by checking for a file called \"<i>&lt;config name&gt;</i>.dump_threads\" in the same directory as the debug log. <i>&lt;config name&gt;</i> is the name of the server configuration, i.e. the same as the base name of the debug log files (typically \"default\"). If this file exists, a thread dump is generated and the file is deleted. If a file on the form \"<i>&lt;config name&gt;</i>.dump_threads.<i>&lt;n&gt;</i>\", where <i>&lt;n&gt;</i> is an integer, exists then <i>n</i> thread dumps are generated in one minute intervals.</p> <p>Note that this method normally isn't necessary in unix-like environments; there you can just send a SIGQUIT signal to the pike process to get a thread dump.</p> <p>Enabling this creates a dedicated thread.</p>")); v->set_changed_callback (cdt_changed); defvar ("dump_threads_by_file", v);
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 "
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__
e082212001-08-28Per Hedbor  defvar("abs_engage", 0, LOCALE(154, "Auto Restart: 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. "));
d873a62001-08-22Per Hedbor 
e082212001-08-28Per Hedbor  defvar("abs_timeout", 5, LOCALE(156, "Auto Restart: 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."),
71e47e2006-12-14Marcus Wellhardh  ({1,2,3,4,5,10,15,30,60}),
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"),
b98c022001-07-31Per Hedbor  TYPE_STRING|VAR_MORE|VAR_NO_DEFAULT,
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 "
edab552002-01-11Henrik Grubbström (Grubba)  "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.
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 "
edab552002-01-11Henrik Grubbström (Grubba)  "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", Variable.Schedule( ({ 2, 1, 1, 0, 4 }), 0,
9fa11d2001-08-24Martin Nilsson  LOCALE(387,"Auto Restart: Schedule"), LOCALE(388, "Automatically restart the "
d873a62001-08-22Per Hedbor  "server according to this schedule.") ) ) ->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", 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 "
7078d32001-07-09Andreas Lange  "memory cache is used for various tasks like remembering "
95843d2000-12-01Martin Nilsson  "what supports flags matches what client."))) ->set_range(1, 60*60*24); // Note that the upper limit is arbitrary.
9d72c41999-08-30Per Hedbor 
e082212001-08-28Per Hedbor  defvar("replicate", 0,
3b3eac2001-09-03Martin Nilsson  LOCALE(163, "Enable replication system" ),
e082212001-08-28Per Hedbor  TYPE_FLAG,
3b3eac2001-09-03Martin Nilsson  LOCALE(337,"If enabled, Roxen will enable various replication systems "
e082212001-08-28Per Hedbor  "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 "
edab552002-01-11Henrik Grubbström (Grubba)  "variable takes effect." ) );
e082212001-08-28Per 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 
6897c92001-06-27Honza Petrous  #ifdef SNMP_AGENT // SNMP stuffs defvar("snmp_agent", 0, LOCALE(999, "SNMP: Enable SNMP agent"), TYPE_FLAG|VAR_MORE,
edab552002-01-11Henrik Grubbström (Grubba)  "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] " "If host isn't set then the IP address of the config interface " "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]; }