From: Junio C Hamano <gitster@pobox.com>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: Emily Ren <lingyan.ren@gmail.com>, git@vger.kernel.org
Subject: Re: Can I forbid somebody to pull some branch or tag from my repo with git protocol?
Date: Wed, 17 Dec 2008 11:36:26 -0800 [thread overview]
Message-ID: <7vd4fqoapx.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <alpine.DEB.1.00.0812171322330.28560@intel-tinevez-2-302> (Johannes Schindelin's message of "Wed, 17 Dec 2008 13:25:59 +0100 (CET)")
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> On Wed, 17 Dec 2008, Emily Ren wrote:
>
>> I want some group can pull these branches or tags from my repo, while
>> other's can't, Need I maintain two repositories ?
>
> Either that (that would be the easy method, and also the proper one, since
> people would not even know what you hide), but you could patch
> upload-pack so that it runs a hook with the rev-list arguments in
> do_rev_list() in upload-pack.c, and die() if the hook returns non-zero.
I do not think that would work very well as you expect. Two branches can
be pointing at the same commit, and Emily may want to hide one but not the
other. The time you obtain from "want" is too late.
If you were to extend upload-pack, the place to narrow would be the
initial "here are the refs and the objects they point at" announcement
that is done at the very beginning. You would do something like the
pseudo patch attached at the end.
read_set_of_exposed_refs_from_hook() should return, depending on who the
user is (which is obviously not available if this connection is over the
anonymous git-daemon service, but local and usual ssh connection you could
do whoami, and on gitosis there would be some environment variable to
distinguish who you are that you can use), the set of refs that the user
is allowed to see.
diff --git i/upload-pack.c w/upload-pack.c
index e5adbc0..129aa1e 100644
--- i/upload-pack.c
+++ w/upload-pack.c
@@ -10,6 +10,10 @@
#include "revision.h"
#include "list-objects.h"
#include "run-command.h"
+#include "string-list.h"
+
+static int use_ref_limiting;
+static struct string_list exposed_refs;
static const char upload_pack_usage[] = "git-upload-pack [--strict] [--timeout=nn] <dir>";
@@ -574,8 +578,14 @@ static int send_ref(const char *refname, const unsigned char *sha1, int flag, vo
static const char *capabilities = "multi_ack thin-pack side-band"
" side-band-64k ofs-delta shallow no-progress"
" include-tag";
- struct object *o = parse_object(sha1);
+ struct object *o;
+
+ if (use_ref_limiting && !string_list_has_string(&exposed_refs, refname)) {
+ /* The downloader is not allowed to know the presense of this ref */
+ return 0;
+ }
+ o = parse_object(sha1);
if (!o)
die("git upload-pack: cannot find object %s:", sha1_to_hex(sha1));
@@ -600,6 +610,12 @@ static int send_ref(const char *refname, const unsigned char *sha1, int flag, vo
static void upload_pack(void)
{
reset_timeout();
+
+ if ("limit exposed refs" hook is available) {
+ use_ref_limiting = 1;
+ read_set_of_exposed_refs_from_hook(&exposed_refs);
+ }
+
head_ref(send_ref, NULL);
for_each_ref(send_ref, NULL);
packet_flush(1);
next prev parent reply other threads:[~2008-12-17 19:37 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-17 9:03 Can I forbid somebody to pull some branch or tag from my repo with git protocol? Emily Ren
2008-12-17 9:09 ` Junio C Hamano
2008-12-17 9:15 ` Emily Ren
2008-12-17 11:53 ` Sverre Rabbelier
2008-12-17 12:35 ` Emily Ren
2008-12-17 12:47 ` Sverre Rabbelier
2008-12-17 13:37 ` Emily Ren
2008-12-17 12:25 ` Johannes Schindelin
2008-12-17 19:36 ` Junio C Hamano [this message]
2008-12-17 12:12 ` Johannes Schindelin
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=7vd4fqoapx.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=lingyan.ren@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).