All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Parkins <andyparkins@gmail.com>
To: git@vger.kernel.org
Subject: [PATCH/RFC] Have git-cvsserver call hooks/update before really altering the ref
Date: Tue, 13 Feb 2007 15:12:45 +0000	[thread overview]
Message-ID: <200702131512.45412.andyparkins@gmail.com> (raw)

git-cvsserver is analogous to git-receive-pack; a checking from a cvs
client to a central server is like a git-push from a working repository.
Therefore it's nice to use the same access control (and email sending)
that a receive-pack would perform.

This patch tests for an executable update hook; if it is it is run with
the ref being updated and the old and new hashes as normal.  If the
update hook returns an error code the update is aborted and the ref is
never updated.

Signed-off-by: Andy Parkins <andyparkins@gmail.com>
---
I'm dubious whether this is the correct thing to do.  It suits me for my
circumstances and I'm arguing that git-cvsserver is more like git-receive-pack
than git-commit; but internally it looks a lot more like git-commit.

Without calling the update hook though, git-cvsserver can completely bypass any
extra access checks that git-receive-pack would have to perform.  Assuming
git-cvsserver is a central repository - I think it's correct to call the update
hook rather than the pre-commit hook.

However, it's a judgement call, so I defer to someone with better judgement
than me :-)

 git-cvsserver.perl |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/git-cvsserver.perl b/git-cvsserver.perl
index 9371788..b4ef6bc 100755
--- a/git-cvsserver.perl
+++ b/git-cvsserver.perl
@@ -1171,6 +1171,21 @@ sub req_ci
         exit;
     }
 
+	# Check that this is allowed, just as we would with a receive-pack
+	my @cmd = ( $ENV{GIT_DIR}.'hooks/update', "refs/heads/$state->{module}",
+			$parenthash, $commithash );
+	if( -x $cmd[0] ) {
+		unless( system( @cmd ) == 0 )
+		{
+			$log->warn("Commit failed (update hook declined to update ref)");
+			print "error 2 Commit failed (update hook declined)\n";
+			close LOCKFILE;
+			unlink($lockfile);
+			chdir "/";
+			exit;
+		}
+	}
+
     print LOCKFILE $commithash;
 
     $updater->update();
-- 
1.5.0.rc4.364.g85b1

             reply	other threads:[~2007-02-13 15:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-13 15:12 Andy Parkins [this message]
2007-02-13 17:43 ` [PATCH/RFC] Have git-cvsserver call hooks/update before really altering the ref Junio C Hamano
2007-02-13 17:54   ` Nicolas Pitre
2007-02-13 18:07     ` Junio C Hamano
2007-02-13 18:14   ` Andy Parkins
2007-02-14  5:36 ` Junio C Hamano
2007-02-14  9:13   ` Andy Parkins
2007-02-14  9:33     ` Junio C Hamano
2007-02-19 20:59       ` Martin Langhoff

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200702131512.45412.andyparkins@gmail.com \
    --to=andyparkins@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.