From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from localhost (mandoc.bsd.lv [local]) by mandoc.bsd.lv (OpenSMTPD) with ESMTPA id 8c3b180a for ; Fri, 29 Nov 2019 08:40:20 -0500 (EST) Date: Fri, 29 Nov 2019 08:40:20 -0500 (EST) X-Mailinglist: mandoc-source Reply-To: source@mandoc.bsd.lv MIME-Version: 1.0 From: schwarze@mandoc.bsd.lv To: source@mandoc.bsd.lv Subject: cvsweb: Simplify by providing default paths to commands. X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Message-ID: <8d0799fe4824dbcf@mandoc.bsd.lv> 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 "
\n", '
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 "%s".

Did you set the @command_path in your configuration file correctly? (Currently: "%s")', - htmlquote(join(', ', @files)), join(':', @command_path)); + 'Failed to spawn rlog on "%s"', + 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