From: schwarze@mandoc.bsd.lv
To: source@mandoc.bsd.lv
Subject: cvsweb: better error handling when reading the configuration file
Date: Wed, 13 Nov 2019 04:13:17 -0500 (EST) [thread overview]
Message-ID: <8d077bd3b8f59ad0@mandoc.bsd.lv> (raw)
Log Message:
-----------
better error handling when reading the configuration file
Modified Files:
--------------
cvsweb:
cvsweb.cgi
Revision Data
-------------
Index: cvsweb.cgi
===================================================================
RCS file: /home/cvs/mandoc/cvsweb/cvsweb.cgi,v
retrieving revision 4.21
retrieving revision 4.22
diff -Lcvsweb.cgi -Lcvsweb.cgi -u -p -r4.21 -r4.22
--- cvsweb.cgi
+++ cvsweb.cgi
@@ -144,7 +144,6 @@ sub spacedHtmlText($;$);
sub link($$);
sub revcmp($$);
sub fatal($$@);
-sub config_error($$);
sub redirect($;$);
sub safeglob($);
sub search_path($);
@@ -316,14 +315,18 @@ $maycompress = (
qw(cvsroot hideattic ignorecase sortby logsort f only_with_tag ln
hidecvsroot hidenonreadable);
-#
# Load configuration.
-#
-if (-f $config) {
- do "$config" or config_error($config, $@);
-} else {
- fatal("500 Internal Error",
- 'Configuration not found. Set the parameter <code>$config</code> in cvsweb.cgi to your <b>cvsweb.conf</b> configuration file first.');
+{
+ $config =~ m|^/| or fatal '500 Internal Error',
+ 'Configuration file name "<code>%s</code>" is not an absolute path.',
+ $config;
+ defined do $config and last;
+ $@ and fatal '500 Internal Error',
+ 'Error loading configuration file "<code>%s</code>": <pre>%s</pre>',
+ $config, $@;
+ fatal '500 Internal Error',
+ 'Cannot read configuration file "<code>%s</code>": %s',
+ $config, $! || 'unknown error';
}
# Try to find a readable dir where we can cd into. Some abs_path()
@@ -1542,17 +1545,6 @@ sub fatal($$@)
sprintf($format, map(htmlquote($_), @args)), "</div>\n";
html_footer();
exit(1);
-}
-
-
-#
-# Signal a (fatal) configuration error.
-#
-sub config_error($$)
-{
- fatal('500 Internal Error',
- 'Error loading configuration file "<code>%s</code>":<br /><br />' .
- '%s<br />', @_);
}
--
To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv
reply other threads:[~2019-11-13 9:13 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8d077bd3b8f59ad0@mandoc.bsd.lv \
--to=schwarze@mandoc.bsd.lv \
--cc=source@mandoc.bsd.lv \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).