1
  
2
  
3
  
4
  
5
  
6
  
7
  
8
  
9
  
10
  
11
  
12
  
13
  
14
  
15
  
16
  
17
  
18
  
19
  
20
  
21
  
22
  
23
  
24
  
25
  
26
  
27
  
28
  
29
  
30
  
31
  
32
  
33
  
34
  
35
  
36
  
37
  
38
  
39
  
40
  
41
  
42
  
43
  
44
  
45
  
46
  
47
  
48
  
49
  
50
  
51
  
52
  
53
  
54
  
55
  
56
  
57
  
58
  
59
  
60
  
61
  
62
  
63
  
64
  
65
  
66
  
67
  
68
  
69
  
70
  
71
  
72
  
73
  
74
  
75
  
76
  
77
  
78
  
79
  
80
  
81
  
82
  
83
  
84
  
85
  
86
  
87
  
88
  
89
  
90
  
91
  
92
  
93
  
94
  
95
  
96
  
97
  
98
  
99
  
100
  
101
  
102
  
103
  
104
  
105
  
106
  
107
  
108
  
109
  
110
  
111
  
112
  
113
  
114
  
115
  
116
  
117
  
118
  
119
  
120
  
121
  
122
  
123
  
124
  
125
  
126
  
127
  
128
  
129
  
130
  
131
  
132
  
133
  
134
  
135
  
136
  
137
  
138
  
139
  
140
  
141
  
142
  
143
  
144
  
145
  
146
  
147
  
148
  
149
  
150
  
151
  
152
  
153
  
154
  
155
  
156
  
157
  
158
  
159
  
160
  
161
  
162
  
163
  
164
  
165
  
166
  
167
  
168
  
169
  
170
  
171
  
172
  
173
  
174
  
175
  
176
  
177
  
178
  
179
  
180
  
181
  
182
  
183
  
184
  
185
  
186
  
187
  
188
  
189
  
190
  
191
  
192
  
193
  
194
  
195
  
196
  
197
  
198
  
199
  
200
  
201
  
202
  
203
  
204
  
205
  
206
  
207
  
208
  
209
  
210
  
211
  
212
  
213
  
214
  
215
  
216
  
217
  
218
  
219
  
220
  
221
  
222
  
223
  
224
  
225
  
226
  
227
  
228
  
229
  
230
  
231
  
232
  
233
  
234
  
235
  
236
  
237
  
238
  
239
  
240
  
241
  
242
  
243
  
244
  
245
  
246
  
247
  
248
  
249
  
250
  
251
  
252
  
253
  
254
  
255
  
256
  
257
  
258
  
259
  
260
  
261
  
262
  
263
  
264
  
265
  
266
  
267
  
268
  
269
  
270
  
271
  
272
  
273
  
274
  
275
  
276
  
277
  
278
  
279
  
280
  
281
  
282
  
283
  
284
  
285
  
286
  
287
  
288
  
289
  
290
  
291
  
292
  
293
  
294
  
295
  
296
  
297
  
298
  
299
  
300
  
301
  
302
  
303
  
304
  
305
  
306
  
307
  
308
  
309
  
310
  
311
  
312
  
313
  
314
  
315
  
316
  
317
  
318
  
319
  
320
  
321
  
322
  
323
  
324
  
325
  
326
  
327
  
328
  
329
  
330
  
331
  
332
  
333
  
334
  
335
  
336
  
337
  
338
  
339
  
340
  
341
  
342
  
343
  
344
  
345
  
346
  
347
  
348
  
349
  
350
  
351
  
352
  
353
  
354
  
355
  
356
  
357
  
358
  
359
  
360
  
361
  
362
  
363
  
364
  
365
  
366
  
367
  
368
  
369
  
370
  
371
  
372
  
373
  
374
  
375
  
376
  
377
  
378
  
379
  
380
  
381
  
382
  
383
  
384
  
385
  
386
  
387
  
388
  
389
  
390
  
391
  
392
  
393
  
394
  
395
  
396
  
397
  
398
  
399
  
400
  
401
  
402
  
403
  
404
  
405
  
406
  
407
  
408
  
409
  
410
  
411
  
412
  
413
  
414
  
415
  
416
  
417
  
418
  
419
  
420
  
421
  
422
  
423
  
424
  
425
  
426
  
427
  
428
  
429
  
430
  
431
  
432
  
433
  
434
  
435
  
436
  
437
  
438
  
439
  
440
  
441
  
442
  
443
  
444
  
445
  
446
  
447
  
448
  
449
  
450
  
451
  
452
  
453
  
454
  
455
  
456
  
457
  
458
  
459
  
460
  
461
  
462
  
463
  
464
  
465
  
466
  
467
  
468
  
469
  
470
  
471
  
472
  
473
  
474
  
475
  
476
  
477
  
478
  
479
  
480
  
481
  
482
  
483
  
484
  
485
  
486
  
487
  
488
  
489
  
490
  
491
  
492
  
493
  
494
  
495
  
496
  
497
  
498
  
499
  
500
  
501
  
502
  
503
  
504
  
505
  
506
  
507
  
508
  
509
  
510
  
511
  
512
  
513
  
514
  
515
  
516
  
517
  
518
  
519
  
520
  
521
  
522
  
523
  
524
  
525
  
526
  
527
  
528
  
529
  
530
  
531
  
532
  
533
  
534
  
535
  
536
  
537
  
538
  
539
  
540
  
541
  
542
  
543
  
544
  
545
  
546
  
547
  
548
  
549
  
550
  
551
  
552
  
553
  
554
  
555
  
556
  
557
  
558
  
559
  
560
  
561
  
562
  
563
  
564
  
565
  
566
  
567
  
568
  
569
  
570
  
571
  
572
  
573
  
574
  
575
  
576
  
577
  
578
  
579
  
580
  
581
  
582
  
583
  
584
  
585
  
586
  
587
  
588
  
589
  
590
  
591
  
592
  
593
  
594
  
595
  
596
  
597
  
598
  
599
  
600
  
601
  
602
  
603
  
604
  
605
  
606
  
607
  
608
  
609
  
610
  
611
  
612
  
613
  
614
  
615
  
616
  
617
  
618
  
619
  
620
  
621
  
622
  
623
  
624
  
625
  
626
  
627
  
628
  
629
  
630
  
631
  
632
  
633
  
634
  
635
  
636
  
637
  
638
  
639
  
640
  
641
  
642
  
643
  
644
  
645
  
646
  
647
  
648
  
649
  
650
  
651
  
652
  
653
  
654
  
655
  
656
  
657
  
658
  
659
  
660
  
661
  
662
  
663
  
664
  
665
  
666
  
667
  
668
  
669
  
670
  
671
  
672
  
673
  
674
  
675
  
676
  
677
  
678
  
679
  
680
  
681
  
682
  
683
  
684
  
685
  
686
  
687
  
688
  
689
  
690
  
// This file is part of Roxen WebServer. 
// Copyright © 1996 - 2001, Roxen IS. 
// $Id: global_variables.pike,v 1.72 2001/06/26 23:18:13 hop Exp $ 
 
// #pragma strict_types 
#define DEFVAR mixed...:object 
#define BDEFVAR mixed...:object 
 
#define IN_ROXEN 
#include <module.h> 
inherit "read_config"; 
inherit "basic_defvar"; 
#include <version.h> 
 
//<locale-token project="roxen_config">LOCALE</locale-token> 
#define LOCALE(X,Y)  _DEF_LOCALE("roxen_config",X,Y) 
 
mixed save() 
{ 
  store( "Variables", variables, 0, 0 ); 
} 
 
// 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. 
 
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"); } 
 
#ifdef SNMP_AGENT 
private int(0..1) snmp_disabled() { return !query("snmp_agent"); } 
#endif 
 
// And why put these functions here, you might righfully ask. 
 
// 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. 
void set_up_hilfe_variables( Protocol o ) 
{ 
  function(DEFVAR) defvar = o->defvar; 
 
  defvar( "require_auth", 1, 
          LOCALE(309,"Require user with the 'hilfe' permission"), TYPE_FLAG, 
          LOCALE(310,"If yes, require a user with the hilfe permission " 
                 "set, otherwise, any configuration interface user will " 
                 "work,  even one with only the view settings permission" ) ); 
} 
 
 
void set_up_ftp_variables( Protocol o ) 
{ 
  function(DEFVAR) defvar = o->defvar; 
 
 
  defvar( "FTPWelcome", 
          "              +------------------------------------------------\n" 
          "              +--      Welcome to the Roxen FTP server      ---\n" 
          "              +------------------------------------------------\n", 
          LOCALE(60, "Welcome text"), TYPE_TEXT, 
          LOCALE(61, "The text shown to the user on connect") ); 
 
  defvar( "ftp_user_session_limit", 0, LOCALE(62, "User session limit"),  
          TYPE_INT, 
          LOCALE(63, "The maximum number of times a user can connect at once." 
          " 0 means unlimited.") ); 
 
  defvar( "named_ftp", 1,  LOCALE(64, "Allow named ftp"), TYPE_FLAG, 
          LOCALE(65, "If yes, non-anonymous users can connect") ); 
 
  defvar( "guest_ftp", 1,  
          LOCALE(66, "Allow login with incorrect password/user"),  
          TYPE_FLAG, 
          LOCALE(67, "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.")); 
 
  defvar( "anonymous_ftp", 1, LOCALE(68, "Allow anonymous ftp"),  
          TYPE_FLAG, 
          LOCALE(69, "If yes, anonymous users is allowed to connect.") ); 
 
  defvar( "shells", "",  LOCALE(70, "Shell database"),  
          TYPE_FILE, 
          LOCALE(71, "If this string is set to anything but the empty string, " 
          "it should point to a file containing a list of valid shells. " 
          "Users with shells that does not figure in this list will not " 
          "be allowed to log in.") ); 
 
  defvar( "passive_port_min", 0, LOCALE(257, "Passive port minimum"), 
          TYPE_INT, 
          LOCALE(320, "Minimum port number to use in the PASV/EPSV response.")); 
 
  defvar( "passive_port_max", 65535, LOCALE(321, "Passive port maximum"), 
          TYPE_INT, 
          LOCALE(322, "Maximum port number to use in the PASV/EPSV response.")); 
} 
 
 
void set_up_http_variables( Protocol o, int|void fhttp ) 
{ 
  function(DEFVAR) defvar = o->defvar; 
 
  function do_set_cookie(Protocol o) 
  { 
    return lambda() { 
             return o->query("set_cookie") == 0; 
           }; 
  }; 
 
  defvar( "minimum_bitrate", 0, LOCALE(205, "Minimum allowed bitrate" ), 
          TYPE_INT, 
          LOCALE(215, "The minimum allowed bitrate, in Kbits/second. If the  " 
                 "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.")); 
 
  defvar("show_internals", 1, LOCALE(72, "Show internal errors"),  
         TYPE_FLAG, 
         LOCALE(73, "Show 'Internal server error' messages to the user. " 
                "This is very useful if you are debugging your own modules " 
                "or writing Pike scripts.")); 
 
  if(!fhttp) 
  { 
    defvar("set_cookie", 0, LOCALE(74, "Logging: Set unique user id cookies"), 
           TYPE_FLAG, 
           LOCALE(75, "If set to Yes, all users of your server whose clients " 
                  "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,  
           LOCALE(76, "Logging: Set ID cookies only once"), 
           TYPE_FLAG, 
           LOCALE(77, "If set to Yes, Roxen will attempt to set unique user " 
                  "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 )); 
  } 
} 
 
void set_up_fhttp_variables( Protocol o ) 
{ 
  function(BDEFVAR) defvar = o->defvar; 
 
  defvar( "log", "None", LOCALE(78, "Logging method"), 
          TYPE_STRING_LIST, 
          LOCALE(79, "None - No log<br />" 
                 "CommonLog - A common log in a file<br />" 
                 "Compat - Log through Roxen's normal logging format.<br />" 
                 "<p>Please note that compat limits Roxen to less than 1k " 
                 "requests/second.</p>"), 
          ({ "None", "CommonLog", "Compat" })); 
 
  defvar( "log_file", "$LOGDIR/clog-"+o->ip+":"+o->port, 
          LOCALE(80, "Log file"), 
          TYPE_FILE, 
          LOCALE(81, "This file is used if logging is done using the " 
                 "CommonLog method.")); 
 
  defvar( "ram_cache", 20, LOCALE(82, "Ram cache"), 
          TYPE_INT, 
          LOCALE(83, "The size of the ram cache, in MegaBytes")); 
 
  defvar( "read_timeout", 120, LOCALE(84, "Client timeout"), 
          TYPE_INT, 
          LOCALE(85, "The maximum time Roxen will wait for a client " 
                 "before giving up, and close the connection, in seconds")); 
 
  set_up_http_variables( o,1 ); 
 
} 
 
void set_up_ssl_variables( Protocol o ) 
{ 
  function(DEFVAR) defvar = o->defvar; 
 
  defvar( "ssl_cert_file", "demo_certificate.pem", 
          LOCALE(86, "SSL certificate file"), 
          TYPE_STRING, 
          sprintf(LOCALE(87, "The SSL certificate file to use. The path " 
                         "is relative to %s")+"\n", getcwd() )); 
 
 
  defvar( "ssl_key_file", "", LOCALE(88, "SSL key file"), 
          TYPE_STRING, 
          sprintf(LOCALE(89, "The SSL key file to use. The path is " 
                         "relative to %s, you do not have to specify a key " 
                         "file, leave this field empty to use the certificate " 
                         "file only")+"\n", getcwd() )); 
} 
 
 
// Get the current domain. This is not as easy as one could think. 
string get_domain(int|void l) 
{ 
  array f; 
  string t, s; 
 
  // FIXME: NT support. 
 
  t = Stdio.read_bytes("/etc/resolv.conf"); 
  if(t) 
  { 
    if(!sscanf(t, "domain %s\n", s)) 
      if(!sscanf(t, "search %s%*[ \t\n]", s)) 
        s="nowhere"; 
  } else { 
    s="nowhere"; 
  } 
  s = "host."+s; 
  sscanf(s, "%*s.%s", s); 
  if(s && strlen(s)) 
  { 
    if(s[-1] == '.') s=s[..strlen(s)-2]; 
    if(s[0] == '.') s=s[1..]; 
  } else { 
    s="unknown"; 
  } 
  return s; 
} 
 
 
class PortOptions 
{ 
  inherit Variable.Variable; 
  constant type = "PortOptions"; 
 
  int check_visibility(RequestID id, int a, int b, int c, int d) { return 0;  } 
  void set_from_form(RequestID id ) { return; } 
  void create() 
  { 
    ::create( ([]), 0, 0, 0 ); 
  } 
}; 
 
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(); 
  } 
} 
 
void define_global_variables(  ) 
{ 
  int p; 
 
  defvar("port_options", PortOptions()); 
 
  defvar("RestoreConnLogFull", 0, 
          LOCALE(90, "Logging: Log entire file length in restored connections"), 
          TYPE_FLAG, 
          LOCALE(91, "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.")); 
 
  defvar("default_font", "roxen builtin", LOCALE(92, "Default font"),  
         TYPE_FONT, 
         LOCALE(93, "The default font to use when modules request a font.")); 
 
  defvar("font_dirs", ({"../local/nfonts/", "nfonts/" })+ 
#ifdef __NT__ 
         ({combine_path(replace(getenv("SystemRoot"),"\\","/"),"fonts/")}) 
#else 
         ((getenv("RX_FONTPATH")||"")/","-({""})) 
#endif 
         , LOCALE(94, "Font directories"),  
         TYPE_DIR_LIST, 
         LOCALE(95, "This is where the fonts are located.")); 
 
  defvar("logdirprefix", "../logs/",  
         LOCALE(96, "Logging: Log directory prefix"), 
         TYPE_STRING|VAR_MORE, 
         LOCALE(97, "This is the default file path that will be prepended " 
                "to the log file path in all the default modules and the " 
                "site.")); 
 
  defvar("cache", 0, LOCALE(98, "Cache: Proxy Disk Cache Enabled"),  
         TYPE_FLAG, 
         LOCALE(99, "If set to Yes, caching will be enabled.")); 
 
  defvar("garb_min_garb", 1,  
         LOCALE(100, "Cache: Proxy Disk Cache Clean size"), 
         TYPE_INT, 
         LOCALE(101, "Minimum number of Megabytes removed when a garbage collect is done."), 
          0, cache_disabled_p); 
 
  defvar("cache_minimum_left", 5, 
         LOCALE(102, "Cache: Proxy Disk Cache Minimum available free space and inodes (in %)"),  
         TYPE_INT, 
         LOCALE(103, "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."), 
         0, 
#if constant(filesystem_stat) 
       cache_disabled_p 
#else 
       1 
#endif /* filesystem_stat */ 
       ); 
 
  defvar("cache_size", 25, LOCALE(104, "Cache: Proxy Disk Cache Size"),  
         TYPE_INT, 
         LOCALE(105, "How many MB may the cache grow to before a garbage " 
                "collect is done?"), 
         0, cache_disabled_p); 
 
  defvar("cache_max_num_files", 0, 
         LOCALE(106, "Cache: Proxy Disk Cache Maximum number of files"),  
         TYPE_INT,  
         LOCALE(107, "How many cache files (inodes) may be on disk before " 
                "a garbage collect is done ? May be left zero to disable " 
                "this check."), 
         0, cache_disabled_p); 
 
  defvar("bytes_per_second", 50, 
         LOCALE(108, "Cache: Proxy Disk Cache bytes per second"), 
         TYPE_INT, 
         LOCALE(109, "How file size should be treated during garbage collect. " 
          "Each X bytes counts as a second, so that larger files will " 
          "be removed first."), 
          0, cache_disabled_p); 
 
  defvar("cachedir", "/tmp/roxen_cache/", 
          LOCALE(110, "Cache: Proxy Disk Cache Base Cache Dir"), 
          TYPE_DIR, 
          LOCALE(111, "This is the base directory where cached files will " 
                 "reside. To avoid mishaps, 'roxen_cache/' is always " 
                 "prepended to this variable."), 
         0, cache_disabled_p); 
 
  defvar("hash_num_dirs", 500, 
         LOCALE(112, "Cache: Proxy Disk Cache Number of hash directories"), 
         TYPE_INT|VAR_MORE, 
         LOCALE(113, "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."), 
         0, cache_disabled_p); 
 
  defvar("cache_keep_without_content_length", 1, 
         LOCALE(114, "Cache: Proxy Disk Cache Keep without Content-Length"), 
         TYPE_FLAG,  
         LOCALE(115, "Keep files without Content-Length header information " 
                "in the cache?"), 
         0, cache_disabled_p); 
 
  defvar("cache_check_last_modified", 0, 
         LOCALE(116, "Cache: Proxy Disk Cache Refreshes on Last-Modified"),  
         TYPE_FLAG, 
         LOCALE(117, "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."), 
         0, cache_disabled_p); 
 
  defvar("cache_last_resort", 0, 
         LOCALE(118, "Cache: Proxy Disk Cache Last resort (in days)"),  
         TYPE_INT, 
         LOCALE(119, "How many days shall files without Expires and without " 
                "Last-Modified header information be kept?"), 
         0, cache_disabled_p); 
 
  defvar("cache_gc_logfile",  "", 
         LOCALE(120, "Cache: Proxy Disk Cache Garbage collector logfile"),  
         TYPE_FILE, 
         LOCALE(121, "Information about garbage collector runs, removed and " 
                "refreshed files, cache and disk status goes here."), 
         0, cache_disabled_p); 
 
  /// End of cache variables.. 
 
  // FIXME: Should mention real_version. 
  defvar("default_ident", 1,  
         LOCALE(124, "Identify, Use default identification string"), 
         TYPE_FLAG|VAR_MORE, 
         LOCALE(125, "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>")); 
   
  defvar("ident", replace(real_version," ","·"),  
         LOCALE(126, "Identify, Identify as"), 
         TYPE_STRING /* |VAR_MORE */, 
         LOCALE(127, "Enter the name that Roxen should use when talking to clients. "), 
         0, ident_disabled_p); 
   
  defvar("User", "", LOCALE(128, "Change uid and gid to"),  
         TYPE_STRING, 
         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].")); 
 
  defvar("permanent_uid", 0, LOCALE(130, "Change uid and gid permanently"), 
         TYPE_FLAG, 
         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 " 
          "it gives better security.")); 
 
  // FIXME: Should mention getcwd() 
  defvar("ModuleDirs", ({ "../local/modules/", "modules/" }), 
         LOCALE(132, "Module directories"),  
         TYPE_DIR_LIST, 
         LOCALE(133, "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.")); 
 
  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"); 
                             } ); 
 
  defvar("audit", 0, LOCALE(136, "Logging: Audit trail"),  
         TYPE_FLAG, 
         LOCALE(137, "If Audit trail is set to Yes, all changes of uid will be " 
                "logged in the Event log.")); 
 
#if efun(syslog) 
  defvar("LogA", "file", LOCALE(138, "Logging: Debug log method"),  
         TYPE_STRING_LIST|VAR_MORE, 
         LOCALE(139, "What method to use for the debug log, default is file, " 
          "but " 
          "syslog is also available. When using file, the output is really" 
          " sent to stdout and stderr, but this is handled by the " 
          "start script."), 
         ({ "file", "syslog" })); 
 
  defvar("LogSP", 1, LOCALE(140, "Logging: Log PID"),  
         TYPE_FLAG, 
         LOCALE(141, "If set, the PID will be included in the syslog."), 0, 
         syslog_disabled); 
 
  defvar("LogCO", 0, LOCALE(142, "Logging: Log to system console"),  
         TYPE_FLAG, 
         LOCALE(143, "If set and syslog is used, the error/debug message " 
                "will be printed to the system console as well as to the " 
                "system log."), 
          0, syslog_disabled); 
 
  defvar("LogST", "Daemon", LOCALE(144, "Logging: Syslog type"),  
         TYPE_STRING_LIST, 
         LOCALE(145, "When using SYSLOG, which log type should be used."), 
         ({ "Daemon", "Local 0", "Local 1", "Local 2", "Local 3", 
            "Local 4", "Local 5", "Local 6", "Local 7", "User" }), 
         syslog_disabled); 
 
  defvar("LogWH", "Errors", LOCALE(146, "Logging: Log what to syslog"),  
         TYPE_STRING_LIST, 
         LOCALE(147, "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 />"), 
         ({ "Fatal", "Errors",  "Warnings", "Debug", "All" }), 
         syslog_disabled); 
 
  defvar("LogNA", "Roxen", LOCALE(148, "Logging: Log as"),  
         TYPE_STRING, 
         LOCALE(149, "When syslog is used, this will be the identification " 
                "of the Roxen daemon. The entered value will be appended to " 
                "all logs."), 
         0, syslog_disabled); 
#endif // efun(syslog) 
 
#ifdef THREADS 
  defvar("numthreads", 5, LOCALE(150, "Number of threads to run"),  
         TYPE_INT, 
         LOCALE(151, "The number of simultaneous threads Roxen will use.\n" 
          "<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 " 
          "your machine, or if you have a lot of slow NFS accesses.</i></p>")); 
#endif // THREADS 
 
#ifndef __NT__ 
  defvar("abs_engage", 0, LOCALE(154, "ABS: Enable Anti-Block-System"),  
         TYPE_FLAG|VAR_MORE, 
         LOCALE(155, "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, LOCALE(156, "ABS: Timeout"), 
         TYPE_INT_LIST|VAR_MORE, 
         LOCALE(157, "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."), 
         ({1,2,3,4,5,10,15}), 
         lambda() {return !query("abs_engage");}); 
#endif // __NT__ 
 
  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) { 
                              roxenp()->set_default_locale(query("locale")); 
                              roxenp()->set_locale(); 
                            } ); 
 
  string secret=Crypto.md5()->update(""+time(1)+random(100000))->digest(); 
  secret = MIME.encode_base64(secret,1); 
  defvar("server_salt", secret[..sizeof(secret)-3], LOCALE(8, "Server secret"), 
         TYPE_STRING|VAR_MORE, 
         LOCALE(9, "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") ); 
 
  secret = Crypto.md5()->update(""+time(1)+random(100000)+"x"+gethrtime()) 
    ->digest(); 
 
  definvisvar("argcache_secret","",TYPE_STRING); 
  set( "argcache_secret", secret ); 
  // force save. 
 
   
  defvar("suicide_engage", 0, 
         LOCALE(160, "Auto Restart: Enable Automatic Restart"), 
         TYPE_FLAG|VAR_MORE, 
         LOCALE(161, "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 also " 
                "because of memory leaks.") 
          ); 
 
  defvar("suicide_timeout", 7, 
         LOCALE(162, "Auto Restart: Timeout"), 
         TYPE_INT_LIST|VAR_MORE, 
         LOCALE(163, "Automatically restart the server after this many days."), 
         ({1,2,3,4,5,6,7,14,30}), 
         lambda(){return !query("suicide_engage");}); 
 
  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. 
 
  defvar("config_file_comments", 0, 
         LOCALE(172, "Commented config files"), 
         TYPE_FLAG, 
         LOCALE(173, "Save the variable documentation strings as comments " 
                "in the configuration files. Only useful if you read or " 
                "edit the config files directly.")); 
 
  defvar("global_position", 
         Variable.Variable(0, VAR_INVISIBLE)); 
 
 
 
#ifdef SNMP_AGENT 
  // SNMP stuffs 
  defvar("snmp_agent", 0, LOCALE(999, "SNMP: Enable SNMP agent"), 
         TYPE_FLAG|VAR_MORE, 
         "If set, the Roxen SNMP agent will be anabled. " 
         ); 
  defvar("snmp_community", ({"public:ro"}), "SNMP: Community string", 
         TYPE_STRING_LIST, 
         "One community name per line. Default permissions are 'read-only'. " 
         "'Read-write' permissions can be specified by append :rw to the community " 
         "name (for example mypub:rw).", 
         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" })); 
*/ 
  defvar("snmp_hostport", "", "SNMP: IP address and port", 
         TYPE_STRING, 
         "Agent listenning IP adress and port. Format: [[host]:port] " 
         "If host isn't set then will be use IP address of config interface", 
         0, snmp_disabled); 
/* 
  defvar("snmp_traphost","","SNMP traps destinations", 
         TYPE_STRING, 
         "...", 
         0, snmp_disabled); 
*/ 
  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 
 
} 
 
 
void restore_global_variables() 
{ 
  mapping m = retrieve("Variables", 0); 
  setvars(retrieve("Variables", 0)); 
  if( !m->argcache_secret ) save(); 
  old_module_dirs = query( "ModuleDirs" ); 
  getvar( "ModuleDirs" )->add_changed_callback( zap_all_module_caches ); 
} 
 
static mapping(string:mixed) __vars = ([ ]); 
 
// These two should be documented somewhere. They are to be used to 
// set global, but non-persistent, variables in Roxen. 
mixed set_var(string var, mixed to) 
{ 
  return __vars[var] = to; 
} 
 
mixed query_var(string var) 
{ 
  return __vars[var]; 
}