* git daemon directory munging?
@ 2006-06-04 0:13 Jon Loeliger
2006-06-04 0:42 ` Linus Torvalds
0 siblings, 1 reply; 7+ messages in thread
From: Jon Loeliger @ 2006-06-04 0:13 UTC (permalink / raw)
To: git
Scrapped right off the #git IRC channel...
<jdl> I stumbled across some git-daemon quirk for which I'd like opinions on
possible solutions. [18:56]
<jdl> I run a server that houses multiple virtual hosts on one physical
machine.
<jdl> It has multiple Apache based websites on it, and I want to front
multiple git repositories with gitweb. That all works fine. [18:57]
<jdl> But when I set up my repository stores, ie the /pub/scm/repo.git places,
it falls apart.
<jdl> I want to maintain separate sets of git repos for each virtual site.
[18:58]
<jdl> That is, www.foo.com can't see the repos of www.bar.com and vice versa.
<jdl> So I have an Apache directory set up that maps www.foo.com/pub/scm to
some place like /pub/foo/scm using an alias for /pub/scm. [18:59]
<jdl> Similarly, for www.bar.com I map /pub/scm to /pub/bar/scm
<jdl> Now, when I clone using http: all is well as it correctly maps the URL
using the Apache Alias entry. [19:00]
<jdl> However, when cloning via git: it doesn't do the Alias mapping based on
the given website prefix part of the URL.
<jdl> I would have to clone using git://www.foo.com/pub/foo/scm even though I
would clone using http://www.foo.com/pub/scm/ [19:01]
<jdl> So my proposed solution is to setup a genarlization of the git-daemon
-baser-path=path argument.
<jdl> Instead of a single --base-path, there are potentially multiple
--base-path entries that match multiple a URL prefixes. [19:02]
<jdl> Thus, I'd use something like:
--map-base=www.foo.com/pub/scm:/pub/foo/scm
--map-base=www.bar.com/pub/scm=/pub/bar/scm [19:04]
<dormando> mod_rewrite for git :|
<jdl> Quick prefix hack, yeah. [19:05]
<jdl> Um, stop me before I hack....? :-) [19:06]
<dormando> you're going to end up needing something that supports basic
regexes before long
<dormando> I can't think of many cases where you'd want to directly map like
that, and especially in that specific manner. [19:07]
<jdl> I can't hear you.
<dormando> sorry.
* dormando was going to have similar problems for his hosting service
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: git daemon directory munging?
2006-06-04 0:13 Jon Loeliger
@ 2006-06-04 0:42 ` Linus Torvalds
2006-06-04 6:27 ` Junio C Hamano
2006-06-04 23:08 ` H. Peter Anvin
0 siblings, 2 replies; 7+ messages in thread
From: Linus Torvalds @ 2006-06-04 0:42 UTC (permalink / raw)
To: Jon Loeliger; +Cc: git
On Sat, 3 Jun 2006, Jon Loeliger wrote:
>
> <jdl> Thus, I'd use something like:
> --map-base=www.foo.com/pub/scm:/pub/foo/scm
> --map-base=www.bar.com/pub/scm=/pub/bar/scm
The bigger problem is that nothing actually passes in the hostname to
git-daemon in the first place. By the time the git-daemon is contacted,
the hostname is long gone ;(
Now, you can just extend the git protocol to just pass in the host too.
You can in fact do this in a backwards-compatible manner (old git-daemons
will just ignore it, and new git daemons will automatically notice new
clients) with something evil like the appended.
Not tested (and this actualyl doesn't make the daemon _use_ the data, it
just adds a comment - the rest "is left as an exercise for the reader")
Linus
---
diff --git a/connect.c b/connect.c
index 54f7bf7..36c5d04 100644
--- a/connect.c
+++ b/connect.c
@@ -374,7 +374,7 @@ static int git_tcp_connect(int fd[2], co
fd[0] = sockfd;
fd[1] = sockfd;
- packet_write(sockfd, "%s %s\n", prog, path);
+ packet_write(sockfd, "%s %s%c%s%c%s\n", prog, path, 0, host, 0, port);
return 0;
}
diff --git a/daemon.c b/daemon.c
index 776749e..61e0af9 100644
--- a/daemon.c
+++ b/daemon.c
@@ -267,7 +267,7 @@ static int upload(char *dir)
static int execute(void)
{
static char line[1000];
- int len;
+ int len, n;
alarm(init_timeout ? init_timeout : timeout);
len = packet_read_line(0, line, sizeof(line));
@@ -276,6 +276,14 @@ static int execute(void)
if (len && line[len-1] == '\n')
line[--len] = 0;
+ n = strlen(line);
+ if (n != len) {
+ /* Cool, we have hidden info at the end */
+ /* Parse the hostname and the port, and */
+ /* leave some room for expansion for */
+ /* the future .. */
+ }
+
if (!strncmp("git-upload-pack ", line, 16))
return upload(line+16);
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: git daemon directory munging?
2006-06-04 0:42 ` Linus Torvalds
@ 2006-06-04 6:27 ` Junio C Hamano
2006-06-04 23:10 ` H. Peter Anvin
2006-06-04 23:08 ` H. Peter Anvin
1 sibling, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2006-06-04 6:27 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git
Linus Torvalds <torvalds@osdl.org> writes:
> diff --git a/connect.c b/connect.c
> index 54f7bf7..36c5d04 100644
> --- a/connect.c
> +++ b/connect.c
> @@ -374,7 +374,7 @@ static int git_tcp_connect(int fd[2], co
>
> fd[0] = sockfd;
> fd[1] = sockfd;
> - packet_write(sockfd, "%s %s\n", prog, path);
> + packet_write(sockfd, "%s %s%c%s%c%s\n", prog, path, 0, host, 0, port);
> return 0;
> }
Adding host like HTTP does with Host: header makes sense but I
think the accept side can usually tell what the port it accepted
the connection to is.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: git daemon directory munging?
2006-06-04 0:42 ` Linus Torvalds
2006-06-04 6:27 ` Junio C Hamano
@ 2006-06-04 23:08 ` H. Peter Anvin
1 sibling, 0 replies; 7+ messages in thread
From: H. Peter Anvin @ 2006-06-04 23:08 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Jon Loeliger, git
Linus Torvalds wrote:
>
> On Sat, 3 Jun 2006, Jon Loeliger wrote:
>> <jdl> Thus, I'd use something like:
>> --map-base=www.foo.com/pub/scm:/pub/foo/scm
>> --map-base=www.bar.com/pub/scm=/pub/bar/scm
>
> The bigger problem is that nothing actually passes in the hostname to
> git-daemon in the first place. By the time the git-daemon is contacted,
> the hostname is long gone ;(
Well, you can bind different git daemons to different IP addresses
(IP-based vhosting) or different ports (with SRV records in DNS.)
> Now, you can just extend the git protocol to just pass in the host too.
>
> You can in fact do this in a backwards-compatible manner (old git-daemons
> will just ignore it, and new git daemons will automatically notice new
> clients) with something evil like the appended.
>
That's actually what was done to HTTP.
> Not tested (and this actualyl doesn't make the daemon _use_ the data, it
> just adds a comment - the rest "is left as an exercise for the reader")
-hpa
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: git daemon directory munging?
2006-06-04 6:27 ` Junio C Hamano
@ 2006-06-04 23:10 ` H. Peter Anvin
0 siblings, 0 replies; 7+ messages in thread
From: H. Peter Anvin @ 2006-06-04 23:10 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Linus Torvalds, git
Junio C Hamano wrote:
>
> Adding host like HTTP does with Host: header makes sense but I
> think the accept side can usually tell what the port it accepted
> the connection to is.
>
Yes, but that requires that each hostname has a separate IP address
and/or port number (and SRV records in DNS, which not all platforms pay
attention to.)
Now, if the hostname is passed in like this, it needs to be carefully
canonicalized, and there needs to be provisions for wildcard matches.
-hpa
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: git daemon directory munging?
@ 2006-06-05 2:10 Jon Loeliger
2006-06-05 2:59 ` H. Peter Anvin
0 siblings, 1 reply; 7+ messages in thread
From: Jon Loeliger @ 2006-06-05 2:10 UTC (permalink / raw)
To: git
> Well, you can bind different git daemons to different IP addresses
> (IP-based vhosting) or different ports (with SRV records in DNS.)
Is there existing support for telling the git-daemon what
specific IP to bind to out of an inetd setup and I just
missed it?
I could set that up realatively easily and gain the
functionality I wanted that way too.
I've also hacked in a host interpolation too.
But like you said, canonicalizing it and checking it is likely
a bit of a pain. I've side-stepped one angle of that by
symlinking in my /pub directory for multiple different
hostnames too. :-)
jdl
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: git daemon directory munging?
2006-06-05 2:10 git daemon directory munging? Jon Loeliger
@ 2006-06-05 2:59 ` H. Peter Anvin
0 siblings, 0 replies; 7+ messages in thread
From: H. Peter Anvin @ 2006-06-05 2:59 UTC (permalink / raw)
To: Jon Loeliger; +Cc: git
Jon Loeliger wrote:
>> Well, you can bind different git daemons to different IP addresses
>> (IP-based vhosting) or different ports (with SRV records in DNS.)
>
> Is there existing support for telling the git-daemon what
> specific IP to bind to out of an inetd setup and I just
> missed it?
>
No, but that really should be added. It's a pretty trivial hack.
> I could set that up realatively easily and gain the
> functionality I wanted that way too.
>
> I've also hacked in a host interpolation too.
>
> But like you said, canonicalizing it and checking it is likely
> a bit of a pain. I've side-stepped one angle of that by
> symlinking in my /pub directory for multiple different
> hostnames too. :-)
>
Doesn't work very well. DNS is case-insensitive, and worse, there are
the PunyCode aliases or whatever they're called.
-hpa
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2006-06-05 2:59 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-05 2:10 git daemon directory munging? Jon Loeliger
2006-06-05 2:59 ` H. Peter Anvin
-- strict thread matches above, loose matches on Subject: below --
2006-06-04 0:13 Jon Loeliger
2006-06-04 0:42 ` Linus Torvalds
2006-06-04 6:27 ` Junio C Hamano
2006-06-04 23:10 ` H. Peter Anvin
2006-06-04 23:08 ` H. Peter Anvin
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).