From b78a720ceeecf7db985dd8d013c08829ea8cfc81 Mon Sep 17 00:00:00 2001 From: Sitaram Chamarty Date: Fri, 27 Nov 2009 23:00:58 +0530 Subject: [PATCH] auth/compile: auto-vivify is default now, so: the "create a new repo" code moves from compile to auth. Only someone who has W access can create it, but he can do so even on a "R" operation (like clone or ls-remote). This is a pre-requisite for rebel's wildcard repos, where autovivification is the only way you can create arbitrary repos matching a pattern. The only reason it's getting into master is because it looks cool! ---- OK that's a lie; the real reason is to keep the two branches as similar as possible, though they;ve diverged quite a bit since the "only one-line difference" days where "rebel" just meant "deny/exclude" rules!) --- src/gl-auth-command | 9 +++++++++ src/gl-compile-conf | 21 +++++---------------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/gl-auth-command b/src/gl-auth-command index 31d1fa8..a135be6 100755 --- a/src/gl-auth-command +++ b/src/gl-auth-command @@ -100,6 +100,15 @@ die "$perm access for $repo DENIED to $user\n" unless $repos{$repo}{$perm}{$user} or $repos{$repo}{$perm}{'@all'}; +# create the repo if it doesn't already exist and the user has "W" access +my $repo_base_abs = ( $REPO_BASE =~ m(^/) ? $REPO_BASE : "$ENV{HOME}/$REPO_BASE" ); +if ( ( $repos{$repo}{W}{$user} + or $repos{$repo}{W}{'@all'} ) and not -d "$repo_base_abs/$repo.git" ) { + wrap_chdir("$repo_base_abs"); + new_repo($repo, "$GL_ADMINDIR/src/hooks"); + wrap_chdir($ENV{HOME}); +} + # ---------------------------------------------------------------------------- # logging, timestamp. also setup env vars for later # ---------------------------------------------------------------------------- diff --git a/src/gl-compile-conf b/src/gl-compile-conf index d939e5f..583a3f0 100755 --- a/src/gl-compile-conf +++ b/src/gl-compile-conf @@ -312,27 +312,12 @@ my $git_version = `git --version`; my ($gv_maj, $gv_min, $gv_patchrel) = ($git_version =~ m/git version (\d+)\.(\d+)\.(\d+)/); die "$ABRT I can't understand $git_version\n" unless ($gv_maj >= 1); $git_version = $gv_maj*10000 + $gv_min*100 + $gv_patchrel; # now it's "normalised" -my $git_too_old = 0; -# repo-base needs to be an absolute path for this loop to work right -# so if it was not already absolute, prefix $HOME. -my $repo_base_abs = ( $REPO_BASE =~ m(^/) ? $REPO_BASE : "$ENV{HOME}/$REPO_BASE" ); -wrap_chdir("$repo_base_abs"); -for my $repo (keys %repos) -{ - unless (-d "$repo.git") - { - new_repo($repo, "$GL_ADMINDIR/src/hooks"); - $git_too_old++ if $git_version < 10602; # that's 1.6.2 to you - # new_repo would have chdir'd us away; come back - wrap_chdir("$repo_base_abs"); - } -} warn "\n\t\t***** WARNING *****\n" . "\tyour git version is older than 1.6.2\n" . "\tgitolite will work but you MUST read the section on\n" . "\t\"git version dependency\" in doc/3-faq-tips-etc.mkd\n" - if $git_too_old; + if $git_version < 10602; # that's 1.6.2 to you # ---------------------------------------------------------------------------- # handle gitweb and daemon @@ -343,6 +328,10 @@ warn "\n\t\t***** WARNING *****\n" . # :-) These are now "pseduo users" -- giving them "R" access to a repo is all # you have to do +# repo-base needs to be an absolute path for this loop to work right +# so if it was not already absolute, prefix $HOME. +my $repo_base_abs = ( $REPO_BASE =~ m(^/) ? $REPO_BASE : "$ENV{HOME}/$REPO_BASE" ); + wrap_chdir("$repo_base_abs"); # daemons first...