auth: minor fix to reporting on wildcard repos

Mpenz asked what would happen if the config looked like

    repo foo/abc
        R   sitaram

    repo foo/.*
        RW  sitaram

If you asked for an expand of '.*', it would pick up permissions from
the second set (i.e., "RW") and print them against "foo/abc".

This is misleading, since those are not the permissions that will
actually be *used*.  Gitolite always uses the more specific form if it
is given, which means your actual permissions are just "R".

This patch is to prevent that misleading reporting in this corner case.
This commit is contained in:
Sitaram Chamarty 2010-01-30 04:48:51 +05:30
parent 4142be4e59
commit bc0a478e64

View file

@ -230,6 +230,7 @@ sub expand_wild
# get the list of repo patterns
&parse_acl($GL_CONF_COMPILED, "", "NOBODY", "NOBODY", "NOBODY");
my @repopatts = grep { $_ !~ $REPONAME_PATT } sort keys %repos;
my %reponames = map { $_ => 1 } grep { $_ =~ $REPONAME_PATT } sort keys %repos;
# display matching repos (from *all* the repos in the system) that $user
# has at least "R" access to
@ -239,6 +240,11 @@ sub expand_wild
chomp ($actual_repo);
$actual_repo =~ s/^\.\///;
$actual_repo =~ s/\.git$//;
# actual_repo should not be present "as is" in the config, because if
# it does, those permissions will override anything inherited from a
# wildcard that also happens to match, and it would be misleading to
# show that here
next if $reponames{$actual_repo};
# it has to match the pattern being expanded
next unless $actual_repo =~ /^$repo$/;
# it also has to match one of the repo patterns in %repos (which we