- From: Terje Bless <link@dev.w3.org>
- Date: Sat, 04 Sep 2004 21:06:19 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/validator/httpd/cgi-bin
In directory hutz:/tmp/cvs-serv22292/httpd/cgi-bin
Modified Files:
check
Log Message:
More config cleanup. Provide SetEnv for base path, and check all paths for
existance and readability (-d and -r). This closes Bug #863.
Index: check
===================================================================
RCS file: /sources/public/validator/httpd/cgi-bin/check,v
retrieving revision 1.333
retrieving revision 1.334
diff -u -d -r1.333 -r1.334
--- check 3 Sep 2004 01:26:33 -0000 1.333
+++ check 4 Sep 2004 21:06:17 -0000 1.334
@@ -98,12 +98,17 @@
# Things inside BEGIN don't happen on every request in persistent
# environments, such as mod_perl. So let's do globals, eg. read config here.
BEGIN {
+ # Launder data for -T; -AutoLaunder doesn't catch this one.
+ if (exists $ENV{W3C_VALIDATOR_HOME}) {
+ $ENV{W3C_VALIDATOR_HOME} =~ /^(.*)$/;
+ $ENV{W3C_VALIDATOR_HOME} = $1;
+ }
#
# Read Config Files.
eval {
- my %config_opts =
- (-ConfigFile => $ENV{W3C_VALIDATOR_CFG} || '/etc/w3c/validator.conf',
+ my %config_opts = (
+ -ConfigFile => ($ENV{W3C_VALIDATOR_CFG} || '/etc/w3c/validator.conf'),
-MergeDuplicateOptions => TRUE,
-MergeDuplicateBlocks => TRUE,
-SplitPolicy => 'equalsign',
@@ -113,10 +118,12 @@
-AutoLaunder => TRUE,
-AutoTrue => TRUE,
-DefaultConfig => {
- Protocols => {Allow => 'http,https'},
- 'SGML Parser' => '/usr/bin/onsgmls',
- 'Template Path' => '/usr/local/validator/share/templates/en_US',
- },
+ Protocols => {Allow => 'http,https'},
+ Paths => {
+ Base => ($ENV{W3C_VALIDATOR_HOME} || '/usr/local/validator'),
+ SGML => {Parser => '/usr/bin/onsgmls'},
+ },
+ },
);
my %cfg = Config::General->new(%config_opts)->getall();
$CFG = \%cfg;
@@ -124,13 +131,37 @@
if ($@) {
die <<".EOF.";
Could not read configuration. Set the W3C_VALIDATOR_CFG environment variable
-or copy conf/* to /etc/w3c/, and make sure that the configuration file, as well
-as all included files are readable by the web server user. The error was:
-'$@'
+or copy conf/* to /etc/w3c/. Make sure that the configuration file and all
+included files are readable by the web server user. The error was:\n'$@'
.EOF.
}
#
+ # Check a filesystem path for existance and "readability".
+ sub pathcheck (@) {
+ my %paths = map {$_ => [-d $_, -r _]} @_;
+ my @_d = grep {not $paths{$_}->[0]} keys %paths;
+ my @_r = grep {not $paths{$_}->[1]} keys %paths;
+ return TRUE if (scalar(@_d) + scalar(@_r) == 0);
+ die <<".EOF." if scalar @_d;
+Does not exist or is not a directory: @_d
+.EOF.
+ die <<".EOF." if scalar @_r;
+Directory not readable (permission denied): @_r
+.EOF.
+ }
+
+ #
+ # Check paths in config...
+ {
+ my @dirs = ();
+ push @dirs, $CFG->{Paths}->{Base};
+ push @dirs, $CFG->{Paths}->{Templates};
+ push @dirs, $CFG->{Paths}->{SGML}->{Library};
+ &pathcheck(@dirs);
+ }
+
+ #
# Split allowed protocols into a list.
if (my $allowed = delete($CFG->{Protocols}->{Allow})) {
$CFG->{Protocols}->{Allow} = [ split(/\s*,\s*/, $allowed) ];
@@ -138,8 +169,8 @@
#
# Make sure onsgmls exists and is executable.
- unless (-x $CFG->{'SGML Parser'}) {
- die qq(Configured SGML Parser "$CFG->{'SGML Parser'}" not executable!\n);
+ unless (-x $CFG->{Paths}->{SGML}->{Parser}) {
+ die qq(Configured SGML Parser "$CFG->{Paths}->{SGML}->{Parser}" not executable!\n);
}
{ # Make types config indexed by FPI.
@@ -270,11 +301,11 @@
###############################################################################
my $T = HTML::Template->new(
- filename => File::Spec->catfile($CFG->{'Template Path'}, 'result.tmpl'),
+ filename => File::Spec->catfile($CFG->{Paths}->{Templates}, 'result.tmpl'),
die_on_bad_params => FALSE,
);
my $E = HTML::Template->new(
- filename => File::Spec->catfile($CFG->{'Template Path'}, 'fatal-error.tmpl'),
+ filename => File::Spec->catfile($CFG->{Paths}->{Templates}, 'fatal-error.tmpl'),
die_on_bad_params => FALSE,
);
@@ -599,7 +630,7 @@
#
# By default, use SGML catalog file and SGML Declaration.
- my $catalog = File::Spec->catfile($CFG->{'SGML Library'}, 'sgml.soc');
+ my $catalog = File::Spec->catfile($CFG->{Paths}->{SGML}->{Library}, 'sgml.soc');
my @spopt = qw(
-R
-wvalid
@@ -610,7 +641,7 @@
#
# Switch to XML semantics if file is XML.
if (&is_xml($File)) {
- $catalog = File::Spec->catfile($CFG->{'SGML Library'}, 'xml.soc');
+ $catalog = File::Spec->catfile($CFG->{Paths}->{SGML}->{Library}, 'xml.soc');
push(@spopt, '-wxml');
&add_warning($File, 'note', 'Note:', <<".EOF.");
The Validator XML support has
@@ -644,11 +675,13 @@
#
# Tell onsgmls about the SGML Library.
- $ENV{SGML_SEARCH_PATH} = $CFG->{'SGML Library'};
+ $ENV{SGML_SEARCH_PATH} = $CFG->{Paths}->{SGML}->{Library};
#
# Set the command to execute.
- my @cmd = ($CFG->{'SGML Parser'}, '-n', '-c', $catalog, @spopt);
+ my @cmd = ($CFG->{Paths}->{SGML}->{Parser}, '-n', '-c', $catalog, @spopt);
+
+
#
# Set debug info for HTML report.
Received on Saturday, 4 September 2004 21:06:19 UTC