]> Lady’s Gitweb - Gitweb/blobdiff - gitweb.perl
gitweb: fix 'ctags' feature check and others
[Gitweb] / gitweb.perl
index fefa8f94e09ca5f387a5ae766d0ccc5512338b647a2e7b67e100c1d9809d0f92..d1c345f8c5f463f84b9c43204a16d7d6b85e036ca60e148f6b1a02a32d242bca 100755 (executable)
@@ -30,7 +30,7 @@ our $my_uri = $cgi->url(-absolute => 1);
 # if we're called with PATH_INFO, we have to strip that
 # from the URL to find our real URL
 # we make $path_info global because it's also used later on
 # if we're called with PATH_INFO, we have to strip that
 # from the URL to find our real URL
 # we make $path_info global because it's also used later on
-my $path_info = $ENV{"PATH_INFO"};
+our $path_info = $ENV{"PATH_INFO"};
 if ($path_info) {
        $my_url =~ s,\Q$path_info\E$,,;
        $my_uri =~ s,\Q$path_info\E$,,;
 if ($path_info) {
        $my_url =~ s,\Q$path_info\E$,,;
        $my_uri =~ s,\Q$path_info\E$,,;
@@ -96,6 +96,11 @@ our $default_projects_order = "project";
 # (only effective if this variable evaluates to true)
 our $export_ok = "++GITWEB_EXPORT_OK++";
 
 # (only effective if this variable evaluates to true)
 our $export_ok = "++GITWEB_EXPORT_OK++";
 
+# show repository only if this subroutine returns true
+# when given the path to the project, for example:
+#    sub { return -e "$_[0]/git-daemon-export-ok"; }
+our $export_auth_hook = undef;
+
 # only allow viewing of repositories also shown on the overview page
 our $strict_export = "++GITWEB_STRICT_EXPORT++";
 
 # only allow viewing of repositories also shown on the overview page
 our $strict_export = "++GITWEB_STRICT_EXPORT++";
 
@@ -401,7 +406,8 @@ sub check_head_link {
 sub check_export_ok {
        my ($dir) = @_;
        return (check_head_link($dir) &&
 sub check_export_ok {
        my ($dir) = @_;
        return (check_head_link($dir) &&
-               (!$export_ok || -e "$dir/$export_ok"));
+               (!$export_ok || -e "$dir/$export_ok") &&
+               (!$export_auth_hook || $export_auth_hook->($dir)));
 }
 
 # process alternate names for backward compatibility
 }
 
 # process alternate names for backward compatibility
@@ -437,7 +443,7 @@ $projects_list ||= $projectroot;
 # together during validation: this allows subsequent uses (e.g. href()) to be
 # agnostic of the parameter origin
 
 # together during validation: this allows subsequent uses (e.g. href()) to be
 # agnostic of the parameter origin
 
-my %input_params = ();
+our %input_params = ();
 
 # input parameters are stored with the long parameter name as key. This will
 # also be used in the href subroutine to convert parameters to their CGI
 
 # input parameters are stored with the long parameter name as key. This will
 # also be used in the href subroutine to convert parameters to their CGI
@@ -447,7 +453,7 @@ my %input_params = ();
 # XXX: Warning: If you touch this, check the search form for updating,
 # too.
 
 # XXX: Warning: If you touch this, check the search form for updating,
 # too.
 
-my @cgi_param_mapping = (
+our @cgi_param_mapping = (
        project => "p",
        action => "a",
        file_name => "f",
        project => "p",
        action => "a",
        file_name => "f",
@@ -464,10 +470,10 @@ my @cgi_param_mapping = (
        extra_options => "opt",
        search_use_regexp => "sr",
 );
        extra_options => "opt",
        search_use_regexp => "sr",
 );
-my %cgi_param_mapping = @cgi_param_mapping;
+our %cgi_param_mapping = @cgi_param_mapping;
 
 # we will also need to know the possible actions, for validation
 
 # we will also need to know the possible actions, for validation
-my %actions = (
+our %actions = (
        "blame" => \&git_blame,
        "blobdiff" => \&git_blobdiff,
        "blobdiff_plain" => \&git_blobdiff_plain,
        "blame" => \&git_blame,
        "blobdiff" => \&git_blobdiff,
        "blobdiff_plain" => \&git_blobdiff_plain,
@@ -499,7 +505,7 @@ my %actions = (
 
 # finally, we have the hash of allowed extra_options for the commands that
 # allow them
 
 # finally, we have the hash of allowed extra_options for the commands that
 # allow them
-my %allowed_options = (
+our %allowed_options = (
        "--no-merges" => [ qw(rss atom log shortlog history) ],
 );
 
        "--no-merges" => [ qw(rss atom log shortlog history) ],
 );
 
@@ -3909,7 +3915,7 @@ sub fill_project_list_info {
        my ($projlist, $check_forks) = @_;
        my @projects;
 
        my ($projlist, $check_forks) = @_;
        my @projects;
 
-       my $show_ctags = gitweb_check_feature('ctags');
+       my ($show_ctags) = gitweb_check_feature('ctags');
  PROJECT:
        foreach my $pr (@$projlist) {
                my (@activity) = git_get_last_activity($pr->{'path'});
  PROJECT:
        foreach my $pr (@$projlist) {
                my (@activity) = git_get_last_activity($pr->{'path'});
@@ -3983,7 +3989,7 @@ sub git_project_list_body {
                @projects = sort {$a->{$oi->{'key'}} <=> $b->{$oi->{'key'}}} @projects;
        }
 
                @projects = sort {$a->{$oi->{'key'}} <=> $b->{$oi->{'key'}}} @projects;
        }
 
-       my $show_ctags = gitweb_check_feature('ctags');
+       my ($show_ctags) = gitweb_check_feature('ctags');
        if ($show_ctags) {
                my %ctags;
                foreach my $p (@projects) {
        if ($show_ctags) {
                my %ctags;
                foreach my $p (@projects) {
@@ -4452,7 +4458,7 @@ sub git_summary {
        }
 
        # Tag cloud
        }
 
        # Tag cloud
-       my $show_ctags = (gitweb_check_feature('ctags'))[0];
+       my ($show_ctags) = gitweb_check_feature('ctags');
        if ($show_ctags) {
                my $ctags = git_get_project_ctags($project);
                my $cloud = git_populate_project_tagcloud($ctags);
        if ($show_ctags) {
                my $ctags = git_get_project_ctags($project);
                my $cloud = git_populate_project_tagcloud($ctags);
@@ -4554,7 +4560,7 @@ sub git_blame {
        my $fd;
        my $ftype;
 
        my $fd;
        my $ftype;
 
-       gitweb_check_feature('blame')
+       gitweb_check_feature('blame')[0]
            or die_error(403, "Blame view not allowed");
 
        die_error(400, "No file name given") unless $file_name;
            or die_error(403, "Blame view not allowed");
 
        die_error(400, "No file name given") unless $file_name;
@@ -5605,7 +5611,7 @@ sub git_history {
 }
 
 sub git_search {
 }
 
 sub git_search {
-       gitweb_check_feature('search') or die_error(403, "Search is disabled");
+       gitweb_check_feature('search')[0] or die_error(403, "Search is disabled");
        if (!defined $searchtext) {
                die_error(400, "Text field is empty");
        }
        if (!defined $searchtext) {
                die_error(400, "Text field is empty");
        }
@@ -5624,11 +5630,11 @@ sub git_search {
        if ($searchtype eq 'pickaxe') {
                # pickaxe may take all resources of your box and run for several minutes
                # with every query - so decide by yourself how public you make this feature
        if ($searchtype eq 'pickaxe') {
                # pickaxe may take all resources of your box and run for several minutes
                # with every query - so decide by yourself how public you make this feature
-               gitweb_check_feature('pickaxe')
+               gitweb_check_feature('pickaxe')[0]
                    or die_error(403, "Pickaxe is disabled");
        }
        if ($searchtype eq 'grep') {
                    or die_error(403, "Pickaxe is disabled");
        }
        if ($searchtype eq 'grep') {
-               gitweb_check_feature('grep')
+               gitweb_check_feature('grep')[0]
                    or die_error(403, "Grep is disabled");
        }
 
                    or die_error(403, "Grep is disabled");
        }
 
This page took 0.198481 seconds and 4 git commands to generate.