2010-05-14 18:00:40 +02:00
|
|
|
# --------------------------------------------
|
|
|
|
# Per-repo authorization based on gitolite ACL
|
|
|
|
# Include this in gitweb.conf
|
|
|
|
# See doc/3-faq-tips-etc.mkd for more info
|
|
|
|
|
|
|
|
# HOME of the gitolite user
|
|
|
|
my $gl_home = "/home/git";
|
|
|
|
|
|
|
|
# environment variables needed by gitolite.pm
|
|
|
|
$ENV{GL_RC} = "$gl_home/.gitolite.rc";
|
2010-05-27 19:47:06 +02:00
|
|
|
$ENV{GL_USER} = $cgi->remote_user || "gitweb";
|
2010-05-14 18:00:40 +02:00
|
|
|
|
|
|
|
# variables from the RC file
|
|
|
|
our ($REPO_BASE, $GL_ADMINDIR);
|
|
|
|
|
|
|
|
# set HOME temporarily for RC parsing
|
|
|
|
my $orig_home = $ENV{HOME};
|
|
|
|
$ENV{HOME} = $gl_home;
|
|
|
|
do $ENV{GL_RC}
|
|
|
|
or die_error(500, "Failed to parse $ENV{GL_RC}: " . ($! or $@));
|
|
|
|
$ENV{HOME} = $orig_home;
|
|
|
|
|
|
|
|
# set project root etc. absolute paths
|
|
|
|
$ENV{GL_REPO_BASE_ABS} = ( $REPO_BASE =~ m(^/) ? $REPO_BASE : "$gl_home/$REPO_BASE" );
|
|
|
|
$projects_list = $projectroot = $ENV{GL_REPO_BASE_ABS};
|
|
|
|
|
|
|
|
# load gitolite helper routines
|
2010-10-23 13:13:47 +02:00
|
|
|
unshift @INC, "$GL_ADMINDIR/src";
|
|
|
|
require gitolite
|
2010-05-14 18:00:40 +02:00
|
|
|
or die_error(500, "Failed to parse gitolite.pm: " . ($! or $@));
|
|
|
|
|
|
|
|
$export_auth_hook = sub {
|
|
|
|
my $repo = shift;
|
|
|
|
# gitweb passes us the full repo path; so we strip the beginning
|
|
|
|
# and the end, to get the repo name as it is specified in gitolite conf
|
|
|
|
return unless $repo =~ s/^\Q$projectroot\E\/?(.+)\.git$/$1/;
|
|
|
|
|
|
|
|
# check for (at least) "R" permission
|
|
|
|
my ($perm, $creator) = &repo_rights($repo);
|
|
|
|
return ($perm =~ /R/);
|
|
|
|
};
|