[packages/gitolite3] raw from http://gitolite.com/gitolite/gitweb.conf.html

glen glen at pld-linux.org
Thu Jun 11 23:12:41 CEST 2015


commit 06d60fdfcd6ea1ac724404f0914085bcc788bc86
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Fri Jan 31 23:18:07 2014 +0200

    raw from http://gitolite.com/gitolite/gitweb.conf.html

 gitolite.pl | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
---
diff --git a/gitolite.pl b/gitolite.pl
new file mode 100644
index 0000000..76e0e25
--- /dev/null
+++ b/gitolite.pl
@@ -0,0 +1,41 @@
+# ----------------------------------------------------------------------
+
+# Per-repo authorization for gitweb using gitolite v3 access rules
+# Read comments, modify code as needed, and include in gitweb.conf
+
+# ----------------------------------------------------------------------
+
+# First, run 'gitolite query-rc -a' (as the gitolite hosting user) to find the
+# values for GL_BINDIR and GL_LIBDIR in your installation.  Then use those
+# values in the code below:
+
+BEGIN {
+	$ENV{HOME} = '/home/git';   # or whatever is the hosting user's $HOME
+	$ENV{GL_BINDIR} = '/full/path/to/gitolite/src';
+	$ENV{GL_LIBDIR} = '/full/path/to/gitolite/src/lib';
+}
+
+# Pull in gitolite's perl API module.  Among other things, this also sets the
+# GL_REPO_BASE environment variable.
+use lib $ENV{GL_LIBDIR};
+use Gitolite::Easy;
+
+# Set projectroot for gitweb.  If you already set it earlier in gitweb.conf
+# you don't need this but please make sure the path you used is the same as
+# the value of GL_REPO_BASE in the 'gitolite query-rc -a' output above.
+$projectroot = $ENV{GL_REPO_BASE};
+
+# Now get the user name.  Unauthenticated clients will be deemed to be the
+# 'gitweb' user so make sure gitolite's conf file does not allow that user to
+# see anything sensitive.
+$ENV{GL_USER} = $cgi->remote_user || 'gitweb';
+
+$export_auth_hook = sub {
+	my $repo = shift;
+	# gitweb passes us the full repo path; we need to 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/;
+
+	# call Easy.pm's 'can_read' function
+	return can_read($repo);
+};
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/gitolite3.git/commitdiff/5428611b5c1b863482d14a4cb1651d972311db81



More information about the pld-cvs-commit mailing list