source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* cvsweb: better error handling when reading the configuration file
@ 2019-11-13  9:13 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2019-11-13  9:13 UTC (permalink / raw)
  To: source

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-11-13  9:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-13  9:13 cvsweb: better error handling when reading the configuration file schwarze

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).