MxScreen/Config.pm untested

filter: Statementstmt 0.0% 0 / 193 Branchbran 0.0% 0 / 106 Conditioncond 0.0% 0 / 39 MC/DCmcdc 0.0% 0 / 23 Subroutinesub 0.0% 0 / 24 Podpod 0.0% 0 / 7 totaltotal 0.0% 0 / 392 CC 54 SCAR 72.3
CC
54
Cov
0%
configure
2256.0
load_file
20.0
import
12.0
CRAP 1379.4
1 # -*- Mode: perl -*-
2 #
3 # $Id: Config.pm,v 0.1 2001/04/22 17:57:03 ram Exp $
4 #
5 # Copyright (c) 1998-2001, Raphael Manfredi
6 # Copyright (c) 2000-2001, Christophe Dehaudt
7 #
8 # You may redistribute only under the terms of the Artistic License,
9 # as specified in the README file that comes with the distribution.
10 #
11 # HISTORY
12 # $Log: Config.pm,v $
13 # Revision 0.1 2001/04/22 17:57:03 ram
14 # Baseline for first Alpha release.
15 #
16 # $EndLog$
17 #
18  
19 use strict;
20  
21 #
22 # CGI::MxScreen run-time configuration, factorized.
23 #
24  
25 package CGI::MxScreen::Config;
26  
27 use Log::Agent;
28 use Carp::Datum;
29 require CGI;
30  
31 use FindBin qw($Bin);
32 BEGIN {$Bin = $1 if $Bin =~ /^(\S+)$/;} # untaint
33  
34 #
35 # import
36 #
37 # Compile-time processing hook.
38 #
39 # The $config parameter may be either a "filename.pl" (naming scheme which
40 # properly intuits it has to be a syntactically correct perl file which can
41 # be safely required) or a HASH reference.
42 #
43 # It it's a file, it is required in the dynamic CGI::MxScreen::cf namepace.
44 #
45 # If it's a HASH reference, each key sets a configuration variable.
46 # Furthermore, if the special FILE key is set, its value is taken as
47 # a file to be required before setting. This allows one to refine a common
48 # configuration for specific purposes.
49 #
50 # NB: Any '-' in front of the keys is stripped. This enables the use of
51 # Perl's automatic quoting of -words.
52 #
53 # Therefore, the following are strictly equivalent:
54 #
55 # use CGI::MxScreen::Config "./filename.pl";
56 # use CGI::MxScreen::Config ({ -FILE => "./filename.pl" });
57 #
58 sub import {
59 DFEATURE my $f_;
60 my ($module, $config) = @_;
61 $CGI::MxScreen::cf::bindir = $Bin;
62 set_defaults();
63 if (ref $config eq 'HASH') {
64 my $file = $config->{'-FILE'} || $config->{'FILE'};
65 load_file($file) if $file; # File guaranteed to load before
66 load_hash($config); # any hash configuration is made
67 } else {
68 load_file($config);
69 }
70 configure(); # Runtime configuration
71 return DVOID;
72 }
73  
74 #
75 # load_file
76 #
77 # Load specified file
78 #
79 sub load_file {
80 DFEATURE my $f_;
81 my ($file) = @_;
82 $file = "$Bin/$file" unless $file =~ m|^/|;
83 logdie "can't read config file $file: $!" unless -r $file;
84 $CGI::MxScreen::cf::config = $file;
85 eval {
86 local $SIG{__DIE__};
87 local $SIG{__WARN__};
88 package CGI::MxScreen::cf;
89 require $CGI::MxScreen::cf::config; # Keep trace of which one it was
90 };
91 logdie "can't load config file $file: $@" if chop $@;
92 $CGI::MxScreen::cf::_configured = 0; # Signals: don't set defaults
93 return DVOID;
94 }
95  
96 #
97 # load_hash
98 #
99 # Load all keys as CGI::MxScreen::cf scalar variables.
100 # Leading '-' in keys are stripped and FILE is skipped.
101 #
102 sub load_hash {
103 DFEATURE my $f_;
104 my ($h) = @_;
105 while (my ($var, $value) = each %$h) {
106 $var =~ s/^-//;
107 next if $var eq 'FILE';
108 no strict 'refs';
109 ${"CGI::MxScreen::cf::$var"} = $value;
110 }
111 $CGI::MxScreen::cf::_configured = 0; # Signals: don't set defaults
112 return DVOID;
113 }
114  
115 #
116 # set_defaults
117 #
118 # Set configuration defaults.
119 #
120 sub set_defaults {
121 DFEATURE my $f_;
122 {
123 package CGI::MxScreen::cf;
124 no strict 'vars';
125  
126 $fatals_to_browser = 1;
127 $disable_upload = 1;
128 $view_source = 1;
129 $mx_check_vars = 1;
130 $mx_buffer_stdout = 1;
131 }
132 return DVOID;
133 }
134  
135 #
136 # is_configured
137 #
138 # Returns true when configuration was performed.
139 #
140 sub is_configured {
141 DFEATURE my $f_;
142 return DVAL
143 defined $CGI::MxScreen::cf::_configured &&
144 $CGI::MxScreen::cf::_configured;
145 }
146  
147 #
148 # configure
149 #
150 # Perform runtime configuration.
151 # This routine is called by import(), i.e. is ususally run during compilation
152 # of the main script.
153 #
154 sub configure {
155 DFEATURE my $f_;
156  
157 #
158 # If they did not perform any customization already and called us
159 # directly, set some defaults.
160 #
161  
162 if (defined $CGI::MxScreen::cf::_configured) {
163 return DVOID if $CGI::MxScreen::cf::_configured;
164 } else {
165 set_defaults();
166 }
167  
168 #
169 # "chdir" is the first thing we process
170 #
171 if (length $CGI::MxScreen::cf::chdir) {
172 my $dir = $CGI::MxScreen::cf::chdir;
173 logdie "invalid chdir directory $dir: $!" unless -d $dir;
174 $dir = $1 if $dir =~ /^(.*)$/; # untaint
175 chdir($dir) || logdie "cannot chdir to '$dir': $!";
176 }
177  
178 #
179 # "path" -- recall we should be running in taint mode
180 #
181  
182 $ENV{PATH} = $CGI::MxScreen::cf::path if defined $CGI::MxScreen::cf::path;
183  
184 #
185 # "libpath" is handled via a manual "use lib" import.
186 #
187  
188 if (length $CGI::MxScreen::cf::libpath) {
189 my @libs = split(/:/, $CGI::MxScreen::cf::libpath);
190 require lib;
191 lib->import(@libs);
192 }
193  
194 #
195 # Log::Agent -- Application level dispatch
196 #
197  
198 require Log::Agent::Driver::File;
199  
200 #
201 # "logdir" and "logfile" (may use %s for $me)
202 #
203  
204 my $me;
205 ($me = $0) =~ s|.*/(.*)|$1|;
206 $me = $1 if $me =~ /^(.*)$/; # untaint
207  
208 my ($logfile, $logchannels);
209 my $logdir = $CGI::MxScreen::cf::logdir || ".";
210  
211 logdie "invalid logging directory $logdir: $!" unless -d $logdir;
212 $logdir = $1 if $logdir =~ /^(.*)$/; # untaint
213  
214 if (defined $CGI::MxScreen::cf::logfile) {
215 my $fmt = $CGI::MxScreen::cf::logfile;
216 $fmt = $1 if $fmt =~ /^(.*)$/; # untaint
217 $logfile = $fmt eq "" ? "$me.log" : sprintf($fmt, $me);
218 $logfile = "$logdir/$logfile" unless $logfile =~ m|^/|;
219 }
220  
221 #
222 # "logchannels" (may use %s for $me)
223 #
224  
225 if (ref $CGI::MxScreen::cf::logchannels) {
226 my $channels = $CGI::MxScreen::cf::logchannels;
227 $channels = {
228 'error' => "%s.err",
229 'output' => "%s.out",
230 'debug' => "%s.dbg",
231 } unless scalar keys %$channels;
232 foreach my $chan (keys %$channels) {
233 my $file = sprintf($channels->{$chan}, $me);
234 $file = "$logdir/$file" unless $file =~ m|^/|;
235 $channels->{$chan} = $file;
236 }
237 $logchannels = $channels;
238 }
239  
240 #
241 # "log_maxsize" and "log_maxtime"
242 #
243  
244 my $rotate;
245  
246 if (
247 defined $CGI::MxScreen::cf::log_maxsize ||
248 defined $CGI::MxScreen::cf::log_maxtime
249 ) {
250 require Log::Agent::Rotate;
251 my $keep = 7;
252 $keep = $CGI::MxScreen::cf::log_backlog
253 if defined $CGI::MxScreen::cf::log_backlog &&
254 $CGI::MxScreen::cf::log_backlog >= 0;
255  
256 $rotate = Log::Agent::Rotate->make(
257 -backlog => $keep,
258 -unzipped => $keep, # don't gzip, could cause some delay
259 -is_alone => 0,
260 -max_size => $CGI::MxScreen::cf::log_maxsize,
261 -max_time => $CGI::MxScreen::cf::log_maxtime,
262 -single_host => $CGI::MxScreen::cf::log_single_host,
263 );
264 }
265  
266 #
267 # Create driver
268 #
269  
270 my $driver;
271  
272 if (defined $logfile || defined $logchannels) {
273 my @dest = defined $logchannels ?
274 (-channels => $logchannels) :
275 (-file => $logfile);
276 $driver = Log::Agent::Driver::File->make(
277 -prefix => $me,
278 -stampfmt => $CGI::MxScreen::cf::logstamp || "own",
279 -showpid => 1,
280 -duperr => 1,
281 -rotate => $rotate,
282 @dest,
283 );
284 } else {
285 # Logs will go to the server, force the "date" format
286 $driver = Log::Agent::Driver::File->make(
287 -prefix => $me,
288 -stampfmt => "date",
289 -showpid => 1,
290 -file => '>&STDERR',
291 -magic_open => 1,
292 );
293 }
294  
295 #
296 # "loglevel" and "logdebug"
297 #
298 logconfig(-prefix => $me, -driver => $driver,
299 -trace => $CGI::MxScreen::cf::loglevel || 0,
300 -debug => $CGI::MxScreen::cf::logdebug || 0,
301 );
302  
303 #
304 # CGI::MxScreen logging
305 #
306  
307 if (defined $CGI::MxScreen::cf::mx_logfile) {
308 require Log::Agent::Logger;
309 require Log::Agent::Channel::File;
310  
311 my $fmt = $CGI::MxScreen::cf::mx_logfile;
312 $fmt = $1 if $fmt =~ /^(.*)$/; # untaint
313 my $file = $fmt eq "" ? "$me.log" : sprintf($fmt, $me);
314 $file = "$logdir/$file" unless $file =~ m|^/|;
315  
316 my $channel = Log::Agent::Channel::File->make(
317 -prefix => $me,
318 -stampfmt => "own",
319 -filename => $file,
320 -rotate => $rotate,
321 );
322  
323 $CGI::MxScreen::Config::LOG = Log::Agent::Logger->make(
324 -channel => $channel,
325 -max_prio => $CGI::MxScreen::cf::mx_loglevel || "debug",
326 );
327 }
328  
329 #
330 # CGI::MxScreen session handling
331 #
332  
333 if (defined $CGI::MxScreen::cf::mx_serializer) {
334 my $ary = $CGI::MxScreen::cf::mx_serializer;
335 if (ref $ary eq 'ARRAY') {
336 my ($type, @args) = @$ary;
337 $type =~ s/^\+/CGI::MxScreen::Serializer::/;
338 eval "require $type";
339 if (chop $@) {
340 logerr "can't load $type: $@";
341 } else {
342 my $s = $CGI::MxScreen::Config::SERIALIZER = $type->make(@args);
343 logwarn "mx_serializer defined an unexpected type $s"
344 unless $s->isa("CGI::MxScreen::Serializer");
345 }
346 } else {
347 logerr "ignoring mx_serializer: not an arrray ref!";
348 }
349 }
350  
351 unless (ref $CGI::MxScreen::Config::SERIALIZER) {
352 require CGI::MxScreen::Serializer::Storable;
353 $CGI::MxScreen::Config::SERIALIZER =
354 CGI::MxScreen::Serializer::Storable->make();
355 }
356  
357 if (defined $CGI::MxScreen::cf::mx_medium) {
358 my $ary = $CGI::MxScreen::cf::mx_medium;
359 if (ref $ary eq 'ARRAY') {
360 my ($type, @args) = @$ary;
361 $type =~ s/^\+/CGI::MxScreen::Session::Medium::/;
362 eval "require $type";
363 if (chop $@) {
364 logerr "can't load $type: $@";
365 } else {
366 my $s = $CGI::MxScreen::Config::MEDIUM = $type->make(@args);
367 logwarn "mx_medium defined an unexpected type $s"
368 unless $s->isa("CGI::MxScreen::Session::Medium");
369 }
370 } else {
371 logerr "ignoring mx_medium: not an arrray ref!";
372 }
373 }
374  
375 unless (ref $CGI::MxScreen::Config::MEDIUM) {
376 require CGI::MxScreen::Session::Medium::Browser;
377 $CGI::MxScreen::Config::MEDIUM =
378 CGI::MxScreen::Session::Medium::Browser->make(
379 -key => "that's my unsecure _key_"
380 );
381 }
382  
383 #
384 # Carp::Datum configuration
385 #
386  
387 Carp::Datum->import($CGI::MxScreen::cf::datum_on ? "on" : "off");
388 if (defined $CGI::MxScreen::cf::datum_config) {
389 my $datum_config = $CGI::MxScreen::cf::datum_config;
390 $datum_config = "$Bin/$datum_config" unless $datum_config =~ m|^/|;
391 DLOAD_CONFIG(-file => $datum_config) if -f $datum_config;
392 }
393  
394 #
395 # "disable_upload" and "post_max"
396 #
397  
398 $CGI::DISABLE_UPLOADS = 1
399 if $CGI::MxScreen::cf::disable_upload;
400 $CGI::POST_MAX = $CGI::MxScreen::cf::post_max || 1024 * 1024;
401  
402 #
403 # "fatals_to_browser" and "fatal_message"
404 #
405  
406 if ($CGI::MxScreen::cf::fatals_to_browser) {
407 require CGI::Carp;
408 CGI::Carp->import('fatalsToBrowser');
409 CGI::Carp::set_message($CGI::MxScreen::cf::fatal_message)
410 if $CGI::MxScreen::cf::fatal_message;
411 }
412  
413 #
414 # "cgi_carpout"
415 #
416  
417 if (-t STDIN && -t STDOUT) { # Debug mode anyway!
418 require CGI::Carp;
419 CGI::Carp::carpout(\*STDOUT);
420 } elsif ($CGI::MxScreen::cf::cgi_carpout && defined $logfile) {
421 local *FH;
422 if (open(FH, ">> $logfile")) {
423 select((select(FH), $| = 1)[0]);
424 CGI::Carp::carpout(\*FH);
425 } else {
426 CGI::Carp::carp("can't append to $logfile: $!");
427 }
428 }
429  
430 #
431 # "view_source" -- produce <VIEW SOURCE>-able HTML
432 #
433  
434 $\ = "\n" unless
435 defined($CGI::MxScreen::cf::view_source) &&
436 !$CGI::MxScreen::cf::view_source;
437  
438 $CGI::MxScreen::cf::_configured = 1; # Mark as "configured"
439  
440 return DVOID;
441 }
442  
443 1; # for require
444  
445 =head1 NAME
446  
447 CGI::MxScreen::Config - configuration for CGI::MxScreen
448  
449 =head1 SYNOPSIS
450  
451 use CGI::MxScreen::Config "./filename.pl";
452 use CGI::MxScreen::Config ({ -FILE => "./filename.pl" });
453  
454 use CGI::MxScreen::Config ({
455 -FILE => "./filename.pl", # Common init
456 -disable_upload => 0, # Supersede common init
457 -fatals_to_browser => 0,
458 -loglevel => "debug",
459 });
460  
461 =head1 DESCRIPTION
462  
463 The CGI::MxScreen::Config module is meant to provide compile-time
464 configuration for the CGI::MxScreen framework.
465  
466 Configuration parameters may be set in a Perl file (which is loaded via
467 C<require>, so it must end-up being syntactically correct and return a
468 true value). Inclusion happens in the C<CGI::MxScreen::cf> namespace, and
469 therefore you must not use any C<package> declaration in that file.
470  
471 Configuration parameters may also be specified as keys within a hash ref
472 object, and may be prefixed by a C<-> character to benefit from Perl's
473 auto-quoting. That character is not part of the variable however, and
474 case matters.
475  
476 Note that you cannot say:
477  
478 use CGI::MxScreen::Config { -loglevel => "notice" }; # WRONG
479  
480 because it is synctactically incorrect. You must enclose the hash ref
481 within parenthesis, as in:
482  
483 use CGI::MxScreen::Config ({ -loglevel => "notice" }); # RIGHT
484  
485 The reason we take a hash ref as first argument and not a list of values
486 is to leave room for further extensions.
487  
488 The special C<-FILE> key points to a filename which is loaded B<before>
489 processing the remaining keys. Therefore, it is possible to override
490 some variables on a per-script basis, yet share customized settings.
491  
492 The CGI::MxScreen module uses C<Log::Agent> for logging, with the File driver.
493 Some options like C<logfile> and C<loglevel> may be used to customize its
494 behaviour. By default, logging will be redirected to STDERR.
495  
496 There's currently no option to choose another logging driver like Syslog,
497 but this can be added easily if there's some demand.
498  
499 =head1 INTERFACE
500  
501 The following configuration variables are available, in alphabetical
502 order:
503  
504 =over
505  
506 =item bindir
507  
508 A preset variable, indicating the location of the CGI script.
509  
510 =item cgi_carpout
511  
512 When set to true and C<logfile> is also defined, arrange for C<CGI::Carp>
513 to redirect errors to that logfile.
514  
515 =item chdir
516  
517 If set, attempt to chdir() to the specified directory very early during
518 C<CGI::MxScreen::Config> processing.
519  
520 =item config
521  
522 A read-only variable, set to the filename that was used to load configuration
523 from, if any.
524  
525 =item datum_config
526  
527 When set to a non-null string, refers to the configuration file to
528 load for C<Carp::Datum> dynamic configuration. See L<Carp::Datum::Cfg> for
529 details.
530  
531 =item datum_on
532  
533 When true, activates C<Carp::Datum>. Note that the C<datum_config> variable
534 is used to load the configuration even when this variable is set to false.
535  
536 =item disable_upload
537  
538 Sets C<$CGI::DISABLE_UPLOADS> to true if set.
539  
540 =item fatal_message
541  
542 The fatal message to be used by C<CGI::Carp> when C<fatals_to_browser> is set.
543 See L<CGI::Carp> for details.
544  
545 =item fatals_to_browser
546  
547 When set to true, tells C<CGI::Carp> to redirect fatal errors to the browser.
548 This is useful during the debugging phase. It is true by default.
549  
550 =item libdir
551  
552 A set of directories to be added to @INC via C<"use lib">, in the order given.
553 The format is the same as the one used by the PERL5LIB variable.
554  
555 =item logchannels
556  
557 The hash ref to give to C<Log::Agent::Driver::File> via C<-channels>.
558 Values are printf patterns where "%s" stands for the script's basename.
559 This variable supersedes any setting in C<logfile>.
560  
561 When an empty logchannels hash ref is given, it is interpreted as if the
562 following was given instead:
563  
564 {
565 'error' => "%s.err",
566 'output' => "%s.out",
567 'debug' => "%s.dbg",
568 }
569  
570 where "%s" stands for "$me", the basename of the script.
571  
572 See L<Log::Agent::Driver::File> for more information.
573  
574 =item logdebug
575  
576 Sets the value of the C<-debug> flag for logconfig(). See L<Log::Agent>
577 for allowed values.
578  
579 =item logdir
580  
581 This variable is used to anchor logfiles to some directory when C<logfile>
582 does not specify a full path. If unset, it defaults to ".". Note that
583 when C<chdir> is used, "." is the directory where we chdir-ed to.
584  
585 =item logfile
586  
587 The path of the file where logging should go. Leaving all C<logdir>,
588 C<logfile> and C<logchannels> empty will cause logging to go to STDERR,
589 which should end-up in the server's error log.
590  
591 If left empty but C<logdir> was set, the value of "$me.log" is assummed,
592 where "$me" stands for the script's basename. You may use "%s" in the
593 name to stand for "$me" (an sprintf() is called, so any % you wish to
594 be part of the logfile name should be written as %%).
595  
596 =item loglevel
597  
598 Specify the loglevel for tracing (DTRACE) when the debug mode of
599 C<Carp::Datum> is turned off.
600 Possible values are:
601 emergency, alert, critical, error, warning, notice, info, debug
602  
603 See L<Log::Agent> for further details.
604  
605 =item logstamp
606  
607 The C<Log::Agent> timestamping format to use. Defaults to "own" when a
608 logfile is used, and is forced to "date" when logs are redirected to the server
609 logs.
610  
611 =item log_backlog
612  
613 The amount of backlog you wish to keep after logfile rotation. Backlog
614 is never compressed, because it is currently performed synchronously
615 by C<Log::Agent::Rotate> and that could cause huge delays when C<log_maxsize>
616 is big, impacting your script response time.
617  
618 Defaults to 7.
619  
620 =item log_maxsize
621  
622 The maximum size in bytes for the logfile. See L<Log::Agent::Rotate>.
623  
624 =item log_maxtime
625  
626 The maximum time a logfile can be kept open before being rotated.
627 See L<Log::Agent::Rotate> for the allowed syntax.
628  
629 =item log_single_host
630  
631 By default, C<CGI::MxScreen> assumes nothing upon how logfiles can be accessed.
632 When you know they are only accessed from ONE machine, you can set this
633 variable to I<true>, and it will speed up locking done via C<LockFile::Simple>
634 during log rotations.
635  
636 =item mx_buffer_stdout
637  
638 When true, all regular output to STDOUT is saved away, and the context will
639 be emitted before any other form output (when saved within the form). This
640 has a slight overhead cost since we have to copy things, but has two nice
641 advantages: in case of fatal errors, the regular output is not mixed with
642 the CGI::Carp output; and the widgets appear on their browser when the
643 context is already emitted, meaning that even if they press a submit button
644 before they have got the whole form, we'll be able to process it sanely.
645  
646 Default is I<true>.
647  
648 =item mx_check_vars
649  
650 Boolean flag, telling whether C<CGI::MxScreen> should trap any access
651 to unknown keys within the screen global context (accessed through
652 C<$screen-E<gt>vars>) and make them fatal errors.
653  
654 Default is I<true>.
655  
656 =item mx_logfile
657  
658 The C<CGI::MxScreen> application logfile, where the module logs what is
659 happening.
660  
661 =item mx_loglevel
662  
663 The C<CGI::MxScreen> application loglevel. Syslog priorities are used,
664 and the specified level is the maximum priority logged.
665  
666 Here is the list of the various things logged, and their level:
667  
668 Level What
669 ------ -------------------------------------------
670 emerg
671 alert Internal errors
672 crit Display errors
673 err Callback failures
674 warn Current state, session info
675 notice Button pressed, state changes
676 info User-agent (1st time), global time spent
677 debug Detailed statistics
678  
679 =item mx_medium
680  
681 Defines the medium used to save the application context. It takes an
682 ARRAY ref defining the medium type (must inherit from
683 C<CGI::MxScreen::Session::Medium>) followed by the creation routine arguments.
684  
685 The first array item (the medium type) is a string which can be shortened:
686 the "CGI::MxScreen::Session::Medium::" leading part may be replaced by '+',
687 which will be automatically replaced.
688  
689 If not specified, it defaults to:
690  
691 [
692 "+Browser",
693 -key => "an unsecure key -- not this one",
694 ]
695  
696 meaning the session contexts will be saved within the browser. This
697 is for convenience only, but when releasing for production, you should never
698 rely on this default and specify a sensible encryption key, to prevent
699 eavesdropping and tampering on the context.
700  
701 See L<CGI::MxScreen::Session::Medium> for the list of available media.
702  
703 =item mx_serializer
704  
705 Defines the serializer to use to create a frozen context image.
706 It takes an ARRAY ref defining the medium type (must inherit from
707 C<CGI::MxScreen::Serializer>) followed by the creation routine arguments.
708  
709 The first array item (the serializer type) is a string which can be shortened:
710 the "CGI::MxScreen::Serializer::" leading part may be replaced by '+',
711 which will be automatically replaced.
712  
713 If not specified, this defaults to:
714  
715 ["+Storable"]
716  
717 An alternative when using the browser to store sessions (see C<mx_medium>)
718 is to use:
719  
720 [
721 "+Storable",
722 -shared => 0,
723 -compress => 1,
724 ]
725  
726 to create a more compact representation, and reduce network traffic at the
727 cost of more CPU time spent on the server.
728  
729 See L<CGI::MxScreen::Serializer> for the list of supported serializers.
730  
731 =item path
732  
733 If set, its value is used to set the PATH environment variable. Remember
734 that CGI scripts should always be run with taint checks enabled, and that
735 explicitely setting the PATH is necessary to be able to run commands
736 via system().
737  
738 =item post_max
739  
740 The value of this variable is used to set C<$CGI::POST_MAX>. It defaults
741 to 1 Mbyte when not set.
742  
743 =item view_source
744  
745 By default, the $\ variable is set to "\n" so that all print statements
746 end-up being on their own line. This tends to produce view-able source code.
747 Setting this to 0 avoids touching $\. You may of course add your own "\n"
748 to each print statement, but this is not recommended.
749  
750 =head1 EXAMPLE
751  
752 Here is a configuration file example:
753  
754 $disable_upload = 1;
755 $post_max = 10 * 1024;
756
757 $fatals_to_browser = 1;
758
759 $datum_config = "debug.cf";
760 $datum_on = 1;
761
762 $logdir = "/home/ram/public_html/log";
763 $logfile = "%s.log";
764 $logstamp = "own";
765 $loglevel = "warn";
766 $logdebug = 0;
767 $logchannels = {} if $datum_on; # take defaults, supersedes $logfile
768
769 $cgi_carpout = 1;
770 $view_source = 1;
771
772 $path = "/bin:/usr/bin:/home/ram/bin/scripts:/home/ram/bin/i386";
773 $chdir = "/home/ram/public_html/scripts";
774 $libpath = "$bindir/lib:/usr/local/cgilib";
775  
776 $mx_logfile = "mx.log";
777 $mx_loglevel = "info";
778 $mx_medium = ["+Browser", -key => "shush! it's a secret" ];
779 $mx_serializer = ["+Storable", -compress => 1];
780
781 1;
782  
783 =head1 AUTHOR
784  
785 Raphael Manfredi F<E<lt>Raphael_Manfredi@pobox.comE<gt>>
786  
787 =head1 SEE ALSO
788  
789 CGI::Carp(3), CGI::MxScreen(3),
790 CGI::MxScreen::Serializer(3), CGI::MxScreen::Session::Medium(3),
791 Log::Agent(3).
792  
793 =cut
794