source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* cvsweb: Simplify by providing default paths to commands.
@ 2019-11-29 13:40 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2019-11-29 13:40 UTC (permalink / raw)
  To: source

Log Message:
-----------
Simplify by providing default paths to commands.
If you put the commands somewhere else in your chroot,
simply say so in the configuration file.

Modified Files:
--------------
    cvsweb:
        cvsweb.cgi
        cvsweb.conf

Revision Data
-------------
Index: cvsweb.cgi
===================================================================
RCS file: /home/cvs/mandoc/cvsweb/cvsweb.cgi,v
retrieving revision 4.28
retrieving revision 4.29
diff -Lcvsweb.cgi -Lcvsweb.cgi -u -p -r4.28 -r4.29
--- cvsweb.cgi
+++ cvsweb.cgi
@@ -67,8 +67,7 @@ use vars qw (
   $is_links $is_lynx $is_w3m $is_msie $is_mozilla3 $is_textbased
   %input $query $barequery $sortby $bydate $byrev $byauthor
   $bylog $byfile $defaultDiffType $logsort $cvstree $cvsroot
-  $charset $output_filter
-  @command_path %CMD $allow_compress $backicon $diricon $fileicon
+  $charset $output_filter %CMD $allow_compress $backicon $diricon $fileicon
   $fullname $logo $defaulttitle $address $binfileicon
   $long_intro $short_instruction $shortLogLen $show_author
   $tablepadding $hr_breakable $showfunc $hr_ignwhite $hr_ignkeysubst
@@ -129,6 +128,8 @@ EOM
   $MimeTypes = undef if $@;
 
   $CheckoutMagic = '~checkout~';
+  $CMD{$_} = "/usr/bin/$_" for (qw(cvs gzip rcsdiff rlog));
+  $CMD{tar} = "/bin/tar";
 }
 
 # -----------------------------------------------------------------------------
@@ -644,12 +645,8 @@ if ($input{tarball}) {
           'You cannot download the top level directory.');
   }
 
-  my $istar = $ext eq '.tar.gz' || $ext eq '.tgz';
-  if ($istar) {
-    fatal('500 Internal Error', 'tar command not found.') unless $CMD{tar};
-    fatal('500 Internal Error', 'gzip command not found.') unless $CMD{gzip};
-  } else {
-    fatal('500 Internal Error', 'Unsupported archive type.');
+  unless ($ext eq '.tar.gz' || $ext eq '.tgz') {
+    fatal('404 Not Found', 'Unsupported archive type.');
   }
 
   my $tmpexportdir;
@@ -688,12 +685,10 @@ if ($input{tarball}) {
     local (*TAR_OUT);
 
     my (@cmd, $ctype);
-    if ($istar) {
       my @tar = ($CMD{tar}, @tar_options, '-cf', '-', $basedir);
       my @gzip = ($CMD{gzip}, @gzip_options, '-c');
       push(@cmd, \@tar, '|', \@gzip);
       $ctype = 'application/x-gzip';
-    }
     push(@cmd, '>pipe', \*TAR_OUT);
 
     my ($h, $err) = startproc(@cmd);
@@ -1094,8 +1089,7 @@ EOF
 
   if ($allow_tar && $filesfound) {
     my ($basefile) = ($where =~ m,(?:.*/)?([^/]+),);
-    my $havetar = $CMD{tar} && $CMD{gzip};
-    if (defined($basefile) && $basefile ne '' && $havetar) {
+    if (defined($basefile) && $basefile ne '') {
       my $q = ($query ? "$query;" : '?') . 'tarball=1';
       print "<hr />\n",
         '<div style="text-align: center">Download this directory in ';
@@ -1572,20 +1566,6 @@ sub safeglob($)
 
 
 #
-# Searches @command_path for the given executable file.
-#
-sub search_path($)
-{
-  my ($command) = @_;
-  for my $d (@command_path) {
-    my $cmd = catfile($d, $command);
-    return $cmd if (-x $cmd && !-d _);
-  }
-  return '';
-}
-
-
-#
 # Gets the MIME type for the given file name.
 #
 sub getMimeType($;$)
@@ -2424,10 +2404,9 @@ sub getDirLogs($$@)
 
   if ($linesread == 0) {
     fatal('500 Internal Error',
-          'Failed to spawn rlog on <em>"%s"</em>.<br /><br />Did you set the <b><code>@command_path</code></b> in your configuration file correctly? (Currently: "<code>%s</code>")',
-          htmlquote(join(', ', @files)), join(':', @command_path));
+          'Failed to spawn rlog on <em>"%s"</em>',
+          htmlquote(join(', ', @files)));
   }
-
   return @unreadable;
 }
 
Index: cvsweb.conf
===================================================================
RCS file: /home/cvs/mandoc/cvsweb/cvsweb.conf,v
retrieving revision 4.16
retrieving revision 4.17
diff -Lcvsweb.conf -Lcvsweb.conf -u -p -r4.16 -r4.17
--- cvsweb.conf
+++ cvsweb.conf
@@ -16,21 +16,6 @@
 # when no value for them has been explicitly set.
 #
 
-# Set the path for the following commands:
-#   cvs, rlog, rcsdiff
-#   gzip (if you enable $allow_compress)
-#   (g)tar (if you enable $allow_tar)
-#
-@command_path = qw(/bin /usr/bin /usr/local/bin);
-
-# Search the above directories for each command (prefer gtar over tar).
-#
-for (qw(cvs rlog rcsdiff gzip gtar)) {
-	$CMD{$_} = search_path($_);
-}
-$CMD{tar}   = delete($CMD{gtar}) if $CMD{gtar};
-$CMD{tar} ||= search_path('tar');
-
 # CVS roots
 #
 # CVSweb can handle several CVS repositories at once.  Enter short (internal)
--
 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-29 13:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-29 13:40 cvsweb: Simplify by providing default paths to commands 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).