| version 1.2, 2002/08/13 12:10:57 |
version 1.3, 2002/08/14 16:52:23 |
|
|
| $allow_tar @tar_options @gzip_options @zip_options @cvs_options |
$allow_tar @tar_options @gzip_options @zip_options @cvs_options |
| $LOG_FILESEPARATOR $LOG_REVSEPARATOR |
$LOG_FILESEPARATOR $LOG_REVSEPARATOR |
| $tmpdir $HTML_DOCTYPE $HTML_META |
$tmpdir $HTML_DOCTYPE $HTML_META |
| |
|
| |
@errorMessages %errorMessages |
| ); |
); |
| # }}} |
# }}} |
| |
|
| Line 241 $LOG_REVSEPARATOR = q/^-{28}$/; |
|
| Line 243 $LOG_REVSEPARATOR = q/^-{28}$/; |
|
| }, |
}, |
| ); |
); |
| |
|
| $HTML_DOCTYPE = |
|
| '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'; |
|
| |
|
| $HTML_META = <<EOM; |
|
| <meta name="robots" content="nofollow"> |
|
| <meta name="generator" content="FreeBSD-CVSweb $cvsweb_revision"> |
|
| <meta http-equiv="Content-Script-Type" content="text/javascript"> |
|
| <meta http-equiv="Content-Style-Type" content="text/css"> |
|
| EOM |
|
| |
|
| ##### End of configuration variables ##### }}} |
##### End of configuration variables ##### }}} |
| |
|
| use Time::Local (); |
use Time::Local (); |
| Line 354 $input{only_with_tag} = $input{only_on_b |
|
| Line 346 $input{only_with_tag} = $input{only_on_b |
|
| foreach (@unsafevars) { |
foreach (@unsafevars) { |
| # Colons are needed in diffs between tags. |
# Colons are needed in diffs between tags. |
| if (defined($input{$_}) && $input{$_} =~ /[^\w\-.:]/) { |
if (defined($input{$_}) && $input{$_} =~ /[^\w\-.:]/) { |
| fatal("500 Internal Error", |
fatal("500 Internal Error", $errorMessages{'malformed query2'}, |
| 'Malformed query (%s=%s)', |
|
| $_, $input{$_}); |
$_, $input{$_}); |
| } |
} |
| } |
} |
|
|
| undef $rewrite; |
undef $rewrite; |
| |
|
| if (!-d $cvsroot) { |
if (!-d $cvsroot) { |
| fatal("500 Internal Error", |
fatal("500 Internal Error", $errorMessages{'server down'}); |
| '$CVSROOT not found!<p>The server on which the CVS tree lives is probably down. Please try again in a few minutes.'); |
|
| } |
} |
| |
|
| # |
# |
| Line 545 if (!-d $cvsroot) { |
|
| Line 535 if (!-d $cvsroot) { |
|
| $where =~ m:([^/]*):; |
$where =~ m:([^/]*):; |
| $module = $1; |
$module = $1; |
| if ($module && &forbidden_module($module)) { |
if ($module && &forbidden_module($module)) { |
| fatal("403 Forbidden", |
fatal("403 Forbidden", $errorMessages{'forbidden modules'}, $where); |
| 'Access to %s forbidden.', |
|
| $where); |
|
| } |
} |
| |
|
| # |
# |
| # Handle tarball downloads before any headers are output. |
# Handle tarball downloads before any headers are output. |
| # {{{ |
# {{{ |
| if ($input{tarball}) { |
if ($input{tarball}) { |
| fatal("403 Forbidden", |
fatal("403 Forbidden", $errorMessages{'tarball prohibited'}) |
| 'Downloading tarballs is prohibited.') |
|
| unless $allow_tar; |
unless $allow_tar; |
| my ($module) = ($where =~ m,^/?(.*),); # untaint |
my ($module) = ($where =~ m,^/?(.*),); # untaint |
| $module =~ s,/([^/]*)$,,; |
$module =~ s,/([^/]*)$,,; |
| Line 563 if ($input{tarball}) { |
|
| Line 550 if ($input{tarball}) { |
|
| my ($basedir) = ($module =~ m,([^/]+)$,); |
my ($basedir) = ($module =~ m,([^/]+)$,); |
| |
|
| if ($basedir eq '' || $module eq '') { |
if ($basedir eq '' || $module eq '') { |
| fatal("500 Internal Error", |
fatal("500 Internal Error", $errorMessages{'download topdir'}); |
| 'You cannot download the top level directory.'); |
|
| } |
} |
| |
|
| my $tmpexportdir = "$tmpdir/.cvsweb.$$." . int(time); |
my $tmpexportdir = "$tmpdir/.cvsweb.$$." . int(time); |
| |
|
| mkdir($tmpexportdir, 0700) |
mkdir($tmpexportdir, 0700) |
| or fatal("500 Internal Error", |
or fatal("500 Internal Error", $errorMessages{'make temp'}, $!); |
| 'Unable to make temporary directory: %s', |
|
| $!); |
|
| |
|
| my @fatal; |
my @fatal; |
| |
|
| Line 587 if ($input{tarball}) { |
|
| Line 571 if ($input{tarball}) { |
|
| if (system $CMD{cvs}, @cvs_options, '-Qd', $cvsroot, 'export', '-r', |
if (system $CMD{cvs}, @cvs_options, '-Qd', $cvsroot, 'export', '-r', |
| $tag, '-d', "$tmpexportdir/$basedir", $module) |
$tag, '-d', "$tmpexportdir/$basedir", $module) |
| { |
{ |
| @fatal = ("500 Internal Error", |
@fatal = ("500 Internal Error", $errorMessages{'cvs co failure'}, |
| 'cvs co failure: %s: %s', |
|
| $!, $module); |
$!, $module); |
| } else { |
} else { |
| $| = 1; # Essential to get the buffering right. |
$| = 1; # Essential to get the buffering right. |
| Line 599 if ($input{tarball}) { |
|
| Line 582 if ($input{tarball}) { |
|
| system |
system |
| "$CMD{tar} @tar_options -cf - -C $tmpexportdir $basedir | $CMD{gzip} @gzip_options -c" |
"$CMD{tar} @tar_options -cf - -C $tmpexportdir $basedir | $CMD{gzip} @gzip_options -c" |
| and @fatal = |
and @fatal = |
| ("500 Internal Error", |
("500 Internal Error", $errorMessages{'tar zc failure'}, $!, $basedir); |
| 'tar zc failure: %s: %s', |
|
| $!, $basedir); |
|
| } elsif ($ext eq '.zip' && $CMD{zip}) { |
} elsif ($ext eq '.zip' && $CMD{zip}) { |
| print "Content-Type: application/zip\r\n\r\n"; |
print "Content-Type: application/zip\r\n\r\n"; |
| |
|
| system |
system |
| "cd $tmpexportdir && $CMD{zip} @zip_options -r - $basedir" |
"cd $tmpexportdir && $CMD{zip} @zip_options -r - $basedir" |
| and @fatal = |
and @fatal = |
| ("500 Internal Error", |
("500 Internal Error", $errorMessages{'zip failure'}, |
| 'zip failure: %s: %s', |
|
| $!, $basedir); |
$!, $basedir); |
| } else { |
} else { |
| @fatal = |
@fatal = ("500 Internal Error", $errorMessages{'unsupported file type'}); |
| ("500 Internal Error", |
|
| 'unsupported file type'); |
|
| } |
} |
| } |
} |
| |
|
| Line 1124 if (-d $fullname) { |
|
| Line 1102 if (-d $fullname) { |
|
| elsif (-f $fullname . ',v') { |
elsif (-f $fullname . ',v') { |
| |
|
| if (forbidden_file($fullname)) { |
if (forbidden_file($fullname)) { |
| fatal('403 Forbidden', |
fatal('403 Forbidden', $errorMessages{'forbidden files'}); |
| 'Access forbidden. This file is mentioned in @ForbiddenFiles'); |
|
| return; |
return; |
| } |
} |
| |
|
| Line 1211 elsif (-f $fullname . ',v') { |
|
| Line 1188 elsif (-f $fullname . ',v') { |
|
| } |
} |
| } |
} |
| } |
} |
| fatal("404 Not Found", |
fatal("404 Not Found", $errorMessages{'no such file'}, $where); |
| '%s: no such file or directory', |
|
| $where); |
|
| } |
} |
| # }}} |
# }}} |
| gzipclose(); |
gzipclose(); |
| Line 1629 sub doAnnotate($$) { |
|
| Line 1604 sub doAnnotate($$) { |
|
| # make sure the revisions are wellformed, for security |
# make sure the revisions are wellformed, for security |
| # reasons .. |
# reasons .. |
| if ($rev =~ /[^\w.]/) { |
if ($rev =~ /[^\w.]/) { |
| fatal("404 Not Found", |
fatal("404 Not Found", $errorMessages{'malformed query'}, |
| 'Malformed query "%s"', |
|
| $ENV{QUERY_STRING}); |
$ENV{QUERY_STRING}); |
| } |
} |
| |
|
| Line 1783 sub doAnnotate($$) { |
|
| Line 1757 sub doAnnotate($$) { |
|
| # We could complain about any text received after this, like the |
# We could complain about any text received after this, like the |
| # CVS command line client. But for simplicity, we don't. |
# CVS command line client. But for simplicity, we don't. |
| } elsif ($words[0] eq "error") { |
} elsif ($words[0] eq "error") { |
| fatal("500 Internal Error", |
fatal("500 Internal Error", $errorMessages{'annotate'}, $_); |
| 'Error occured during annotate: <b>%s</b>', |
|
| $_); |
|
| } |
} |
| } |
} |
| |
|
| Line 1814 sub doCheckout($$) { |
|
| Line 1786 sub doCheckout($$) { |
|
| # make sure the revisions a wellformed, for security |
# make sure the revisions a wellformed, for security |
| # reasons .. |
# reasons .. |
| if (defined($rev) && $rev =~ /[^\w.]/) { |
if (defined($rev) && $rev =~ /[^\w.]/) { |
| fatal("404 Not Found", |
fatal("404 Not Found", $errorMessages{'malformed query'}, |
| 'Malformed query "%s"', |
|
| $ENV{QUERY_STRING}); |
$ENV{QUERY_STRING}); |
| } |
} |
| |
|
| Line 1863 sub doCheckout($$) { |
|
| Line 1834 sub doCheckout($$) { |
|
| } |
} |
| |
|
| if (eof($fh)) { |
if (eof($fh)) { |
| fatal("404 Not Found", |
fatal("404 Not Found", $errorMessages{'pertinent'}, $where); |
| '%s is not (any longer) pertinent', |
|
| $where); |
|
| } |
} |
| |
|
| #=================================================================== |
#=================================================================== |
| Line 1889 sub doCheckout($$) { |
|
| Line 1858 sub doCheckout($$) { |
|
| } |
} |
| |
|
| if ($filename ne $where) { |
if ($filename ne $where) { |
| fatal("500 Internal Error", |
fatal("500 Internal Error", $errorMessages{'unexpected output'}, $cvsheader); |
| 'Unexpected output from cvs co: %s', |
|
| $cvsheader); |
|
| } |
} |
| $| = 1; |
$| = 1; |
| |
|
| Line 1988 sub doDiff($$$$$$) { |
|
| Line 1955 sub doDiff($$$$$$) { |
|
| my ($rev1, $rev2, $sym1, $sym2, $f1, $f2); |
my ($rev1, $rev2, $sym1, $sym2, $f1, $f2); |
| |
|
| if (&forbidden_file($fullname)) { |
if (&forbidden_file($fullname)) { |
| fatal("403 Forbidden", |
fatal("403 Forbidden", $errorMessages{'forbidden files'} ); |
| 'Access forbidden. This file is mentioned in @ForbiddenFiles'); |
|
| return; |
return; |
| } |
} |
| |
|
| Line 2014 sub doDiff($$$$$$) { |
|
| Line 1980 sub doDiff($$$$$$) { |
|
| # make sure the revisions a wellformed, for security |
# make sure the revisions a wellformed, for security |
| # reasons .. |
# reasons .. |
| if ($rev1 =~ /[^\w.]/ || $rev2 =~ /[^\w.]/) { |
if ($rev1 =~ /[^\w.]/ || $rev2 =~ /[^\w.]/) { |
| fatal("404 Not Found", |
fatal("404 Not Found", $errorMessages{'malformed query'}, |
| 'Malformed query "%s"', |
|
| $ENV{QUERY_STRING}); |
$ENV{QUERY_STRING}); |
| } |
} |
| |
|
| Line 2031 sub doDiff($$$$$$) { |
|
| Line 1996 sub doDiff($$$$$$) { |
|
| my $difftype = $DIFFTYPES{$f}; |
my $difftype = $DIFFTYPES{$f}; |
| |
|
| if (!$difftype) { |
if (!$difftype) { |
| fatal("400 Bad arguments", |
fatal("400 Bad arguments", $errorMessages{'bad diff'}, $f); |
| 'Diff format %s not understood', |
|
| $f); |
|
| } |
} |
| |
|
| my @difftype = @{$difftype->{'opts'}}; |
my @difftype = @{$difftype->{'opts'}}; |
| Line 2328 sub getDirLogs($$@) { |
|
| Line 2291 sub getDirLogs($$@) { |
|
| } |
} |
| |
|
| if ($. == 0) { |
if ($. == 0) { |
| fatal("500 Internal Error", |
fatal("500 Internal Error", $errorMessages{'failed spawn'}, |
| 'Failed to spawn GNU rlog on <em>"%s"</em>. <p>Did you set the <b>$command_path</b> in your configuration file correctly ? (Currently "%s"', |
|
| join (", ", @files), $command_path); |
join (", ", @files), $command_path); |
| } |
} |
| close($fh); |
close($fh); |
| Line 2438 sub readLog($;$) { |
|
| Line 2400 sub readLog($;$) { |
|
| $state{$rev} = $8; |
$state{$rev} = $8; |
| $difflines{$rev} = $10; |
$difflines{$rev} = $10; |
| } else { |
} else { |
| fatal("500 Internal Error", |
fatal("500 Internal Error", $errorMessages{'RCS output'}, $_); |
| 'Error parsing RCS output: %s', |
|
| $_); |
|
| } |
} |
| line: |
line: |
| |
|
| Line 2546 sub readLog($;$) { |
|
| Line 2506 sub readLog($;$) { |
|
| } |
} |
| |
|
| if (!defined($onlyonbranch) || $onlybranchpoint eq "") { |
if (!defined($onlyonbranch) || $onlybranchpoint eq "") { |
| fatal("404 Tag not found", |
fatal("404 Tag not found", $errorMessages{'tag not found'}, |
| 'Tag %s not defined', |
|
| $input{'only_with_tag'}); |
$input{'only_with_tag'}); |
| } |
} |
| } |
} |