auth: do not anchor the pattern given for expand
Currently the pattern of expand command is line anchored. This is different than in e.g. grep, and causes extra work to add '.*' prefix and/or suffix in many use cases. The new semantics now mean you might get more matches than you would have gotten earlier. However, the expand command is still totally undocumented, so I think it is acceptable to change the functionality. ;) This patch removes the anchoring. So for earlier behavior the specified pattern needs be in form of '^<pattern>$'. The default pattern is also changed from '.*' to '^', so there might be even a small speed improvement. =) Signed-off-by: Teemu Matilainen <teemu.matilainen@reaktor.fi>
This commit is contained in:
parent
de74e8d343
commit
deda3da182
|
@ -320,7 +320,7 @@ sub expand_wild
|
|||
$actual_repo =~ s/^\.\///;
|
||||
$actual_repo =~ s/\.git$//;
|
||||
# actual_repo has to match the pattern being expanded
|
||||
next unless $actual_repo =~ /^$repo$/;
|
||||
next unless $actual_repo =~ /$repo/;
|
||||
# if actual_repo is present "as is" in the config, those
|
||||
# permissions will override anything inherited from a
|
||||
# wildcard that also happens to match
|
||||
|
|
|
@ -115,7 +115,7 @@ if ($ENV{SSH_ORIGINAL_COMMAND} =~ $CUSTOM_COMMANDS) {
|
|||
my $cmd = $ENV{SSH_ORIGINAL_COMMAND};
|
||||
my ($verb, $repo) = ($cmd =~ /^\s*(\S+)(?:\s+\/?(.*?)(?:.git)?)?$/);
|
||||
# deal with "no argument" cases
|
||||
$verb eq 'expand' ? $repo = '.*' : die "$verb needs an argument\n" unless $repo;
|
||||
$verb eq 'expand' ? $repo = '^' : die "$verb needs an argument\n" unless $repo;
|
||||
if ($repo =~ $REPONAME_PATT and $verb =~ /getperms|setperms/) {
|
||||
# with an actual reponame, you can "getperms" or "setperms"
|
||||
get_set_perms($repo_base_abs, $repo, $verb, $user);
|
||||
|
|
Loading…
Reference in a new issue