source@mandoc.bsd.lv
 help / color / 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, back to index

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

source@mandoc.bsd.lv

Archives are clonable: git clone --mirror http://inbox.vuxu.org/mandoc-source

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.mandoc.source


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git