All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Allow using ':' in git:// hostname.
@ 2010-01-26 18:24 Ilari Liusvaara
  2010-01-26 18:24 ` [PATCH 1/2] Support addresses with ':' in git-daemon Ilari Liusvaara
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Ilari Liusvaara @ 2010-01-26 18:24 UTC (permalink / raw)
  To: git

This series fixes two problems with using addresses containing ':'
(e.g. IPv6 numeric addresses) with git://:

1) ':' in hostname makes vhost headers impossible to parse

If there is ':' in address, the vhost headers become impossible
to parse because ':' is also splits host and port and port is
optional. Change git-daemon to be able to perform address unwrapping
so there is uniquely parseable syntax for hostnames containg
':' (this is compatible to how git-remote-gits encodes such vhost
headers and how git-daemon2[1] decodes them).

2) Client double-unwraps addresses

With git://, the addresses are unwrapped twice, which breaks
address parsing for addresses enclosed by [], which in turn is
required for hostnames containing ':'.  This is changed to unwarp
the addresses only once. This also changes wrapped addresses to
be sent as wrapped for vhost headers (the first patch adds ability
to parse this).

[1] The reference implementation of gits:// server daemon.

Ilari Liusvaara (2):
  Support addresses with ':' in git-daemon
  Allow use of []-wrapped addresses in git://

 connect.c |   10 ++++++++--
 daemon.c  |   34 ++++++++++++++++++++++++++++++----
 2 files changed, 38 insertions(+), 6 deletions(-)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] Support addresses with ':' in git-daemon
  2010-01-26 18:24 [PATCH 0/2] Allow using ':' in git:// hostname Ilari Liusvaara
@ 2010-01-26 18:24 ` Ilari Liusvaara
  2010-01-26 22:53   ` Tay Ray Chuan
  2010-01-26 18:24 ` [PATCH 2/2] Allow use of []-wrapped addresses in git:// Ilari Liusvaara
  2010-01-26 19:59 ` [PATCH 0/2] Allow using ':' in git:// hostname Junio C Hamano
  2 siblings, 1 reply; 5+ messages in thread
From: Ilari Liusvaara @ 2010-01-26 18:24 UTC (permalink / raw)
  To: git

If host address could have ':' in it (e.g. numeric IPv6 address), then
host and port could not be uniquely parsed. Fix this by parsing the
"["<host>"]":<port> and "["<host>"]" notations. Currently the built-in
git:// client would send <host>:<port> or <host> for such thing, but
it doesn't matter as due to bugs, resolving address fails if <host>
contains ':'.

Signed-off-by: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
---
 daemon.c |   34 ++++++++++++++++++++++++++++++----
 1 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/daemon.c b/daemon.c
index 360635e..6c2bd97 100644
--- a/daemon.c
+++ b/daemon.c
@@ -399,6 +399,33 @@ static char *xstrdup_tolower(const char *str)
 	return dup;
 }
 
+static void parse_host_and_port(char *hostport, char **host,
+	char **port)
+{
+	if (*hostport == '[') {
+		char *end;
+
+		end = strchr(hostport, ']');
+		if (!end)
+			die("Invalid reqeuest ('[' without ']')");
+		*end = '\0';
+		*host = hostport + 1;
+		if (!end[1])
+			*port = NULL;
+		else if (end[1] == ':')
+			*port = end + 2;
+		else
+			die("Garbage after end of host part");
+	} else {
+		*host = hostport;
+		*port = strrchr(hostport, ':');
+		if (*port) {
+			*port = '\0';
+			++*port;
+		}
+	}
+}
+
 /*
  * Read the host as supplied by the client connection.
  */
@@ -415,11 +442,10 @@ static void parse_host_arg(char *extra_args, int buflen)
 			vallen = strlen(val) + 1;
 			if (*val) {
 				/* Split <host>:<port> at colon. */
-				char *host = val;
-				char *port = strrchr(host, ':');
+				char *host;
+				char *port;
+				parse_host_and_port(val, &host, &port);
 				if (port) {
-					*port = 0;
-					port++;
 					free(tcp_port);
 					tcp_port = xstrdup(port);
 				}
-- 
1.6.6.1.439.gf06b6

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] Allow use of []-wrapped addresses in git://
  2010-01-26 18:24 [PATCH 0/2] Allow using ':' in git:// hostname Ilari Liusvaara
  2010-01-26 18:24 ` [PATCH 1/2] Support addresses with ':' in git-daemon Ilari Liusvaara
@ 2010-01-26 18:24 ` Ilari Liusvaara
  2010-01-26 19:59 ` [PATCH 0/2] Allow using ':' in git:// hostname Junio C Hamano
  2 siblings, 0 replies; 5+ messages in thread
From: Ilari Liusvaara @ 2010-01-26 18:24 UTC (permalink / raw)
  To: git

Allow using "["<host>"]":<port> and "["<host>"]" notations in git://
host addresses. This is needed to be able to connect to addresses
that contain ':' (e.g. numeric IPv6 addresses). Also send the host
header []-wrapped so it can actually be parsed by remote end.

Signed-off-by: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
---
 connect.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/connect.c b/connect.c
index 3a12562..20054e4 100644
--- a/connect.c
+++ b/connect.c
@@ -502,12 +502,18 @@ struct child_process *git_connect(int fd[2], const char *url_orig,
 		c = ':';
 	}
 
+	/*
+	 * Don't do destructive transforms with git:// as that
+	 * protocol code does '[]' dewrapping of its own.
+	 */
 	if (host[0] == '[') {
 		end = strchr(host + 1, ']');
 		if (end) {
-			*end = 0;
+			if (protocol != PROTO_GIT) {
+				*end = 0;
+				host++;
+			}
 			end++;
-			host++;
 		} else
 			end = host;
 	} else
-- 
1.6.6.1.439.gf06b6

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2] Allow using ':' in git:// hostname.
  2010-01-26 18:24 [PATCH 0/2] Allow using ':' in git:// hostname Ilari Liusvaara
  2010-01-26 18:24 ` [PATCH 1/2] Support addresses with ':' in git-daemon Ilari Liusvaara
  2010-01-26 18:24 ` [PATCH 2/2] Allow use of []-wrapped addresses in git:// Ilari Liusvaara
@ 2010-01-26 19:59 ` Junio C Hamano
  2 siblings, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2010-01-26 19:59 UTC (permalink / raw)
  To: Ilari Liusvaara; +Cc: git

Seems like a maint material (together with your xmallocz() one).
Thanks.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] Support addresses with ':' in git-daemon
  2010-01-26 18:24 ` [PATCH 1/2] Support addresses with ':' in git-daemon Ilari Liusvaara
@ 2010-01-26 22:53   ` Tay Ray Chuan
  0 siblings, 0 replies; 5+ messages in thread
From: Tay Ray Chuan @ 2010-01-26 22:53 UTC (permalink / raw)
  To: Ilari Liusvaara; +Cc: git

Hi,

On Wed, Jan 27, 2010 at 2:24 AM, Ilari Liusvaara
<ilari.liusvaara@elisanet.fi> wrote:
> diff --git a/daemon.c b/daemon.c
> index 360635e..6c2bd97 100644
> --- a/daemon.c
> +++ b/daemon.c
> @@ -399,6 +399,33 @@ static char *xstrdup_tolower(const char *str)
>        return dup;
>  }
>
> +static void parse_host_and_port(char *hostport, char **host,
> +       char **port)
> +{
> +       if (*hostport == '[') {
> +               char *end;
> +
> +               end = strchr(hostport, ']');
> +               if (!end)
> +                       die("Invalid reqeuest ('[' without ']')");

s/reqeuest/request/.

-- 
Cheers,
Ray Chuan

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-01-26 22:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-26 18:24 [PATCH 0/2] Allow using ':' in git:// hostname Ilari Liusvaara
2010-01-26 18:24 ` [PATCH 1/2] Support addresses with ':' in git-daemon Ilari Liusvaara
2010-01-26 22:53   ` Tay Ray Chuan
2010-01-26 18:24 ` [PATCH 2/2] Allow use of []-wrapped addresses in git:// Ilari Liusvaara
2010-01-26 19:59 ` [PATCH 0/2] Allow using ':' in git:// hostname Junio C Hamano

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.