Skip to content

Instantly share code, notes, and snippets.

@lkraav
Created January 23, 2010 08:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lkraav/284504 to your computer and use it in GitHub Desktop.
Save lkraav/284504 to your computer and use it in GitHub Desktop.
gitweb.conf
$projectroot = '/path/to/gitosis/repositories';
$gitosis_conf = '/path/to/gitosis/repositories/gitosis-admin.git/gitosis.conf';
$username = $cgi->remote_user;
$export_auth_hook = sub {
my $projectdir = shift;
if($projectdir =~ (/(.*?)\.git/)) {
my $projectname = basename($1);
open FILE, $gitosis_conf or die 'Could not open gitosis config file. Please make sure that $gitosis_conf is set properly';
my $project_match = 0;
my $user_match = 0;
while() {
if($_ =~ /^\s*members\s*\=\s*(?:.*?\s)*$username(?:\s+|$)/) {$user_match = 1;}
if($_ =~ /^\s*writable\s*\=\s*(?:.*?\s)*$projectname(?:\s+|$)/) {$project_match = 1;}
if($project_match && $user_match) {
return 1;
}
if($_ =~ /\[group/) {
$project_match = $user_match = 0;
}
}
}
return 0;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment