5
use lib $ENV{GL_LIBDIR};
8
use Gitolite::Conf::Load;
11
Usage: gitolite access [-q] <repo> <user> <perm> <ref>
13
Print access rights for arguments given. The string printed has the word
14
DENIED in it if access was denied. With '-q', returns only an exit code
15
(shell truth, not perl truth -- 0 is success).
19
- perm: defauts to '+'. Valid values: R, W, +, C, D, M
20
- ref: defauts to 'any'. See notes below
23
- ref: Any fully qualified ref ('refs/heads/master', not 'master') is fine.
24
The 'any' ref is special -- it ignores deny rules (see docs for what this
25
means and exceptions).
27
Batch mode: see src/triggers/post-compile/update-git-daemon-access-list for a
28
good example that shows how to test several repos in one invocation. This is
29
orders of magnitude faster than running the command multiple times; you'll
30
notice if you have more than a hundred or so repos.
33
usage() if not @ARGV or $ARGV[0] eq '-h';
35
if ( $ARGV[0] eq '-q' ) { $quiet = 1; shift @ARGV; }
37
my ( $repo, $user, $aa, $ref ) = @ARGV;
40
_die "invalid perm" if not( $aa and $aa =~ /^(R|W|\+|C|D|M|\^C)$/ );
41
_die "invalid ref name" if not( $ref and $ref =~ $REPONAME_PATT );
45
if ( $repo ne '%' and $user ne '%' ) {
46
# single repo, single user; no STDIN
47
$ret = access( $repo, $user, $aa, $ref );
49
if ( $ret =~ /DENIED/ ) {
50
print "$ret\n" unless $quiet;
54
print "$ret\n" unless $quiet;
58
$repo = '' if $repo eq '%';
59
$user = '' if $user eq '%';
61
_die "'-q' doesn't go with using a pipe" if $quiet;
65
my $r = $repo || shift @in;
66
my $u = $user || shift @in;
67
$ret = access( $r, $u, $aa, $ref );
68
print "$r\t$u\t$ret\n";