X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=connect.c;h=0ce941ef444277957efdd8a359a568775e2b17a4;hb=08ba24898a1c5c0815450d481d8e5d01bf671642;hp=7636bf976e78a6622281501af2dcc0135781f60a;hpb=a54c4edc511608fdba513cc94812c31fd4b497f6;p=git.git diff --git a/connect.c b/connect.c index 7636bf976..0ce941ef4 100644 --- a/connect.c +++ b/connect.c @@ -177,18 +177,11 @@ static enum protocol get_protocol(const char *name) static const char *ai_name(const struct addrinfo *ai) { - static char addr[INET_ADDRSTRLEN]; - if ( AF_INET == ai->ai_family ) { - struct sockaddr_in *in; - in = (struct sockaddr_in *)ai->ai_addr; - inet_ntop(ai->ai_family, &in->sin_addr, addr, sizeof(addr)); - } else if ( AF_INET6 == ai->ai_family ) { - struct sockaddr_in6 *in; - in = (struct sockaddr_in6 *)ai->ai_addr; - inet_ntop(ai->ai_family, &in->sin6_addr, addr, sizeof(addr)); - } else { + static char addr[NI_MAXHOST]; + if (getnameinfo(ai->ai_addr, ai->ai_addrlen, addr, sizeof(addr), NULL, 0, + NI_NUMERICHOST) != 0) strcpy(addr, "(unknown)"); - } + return addr; } @@ -586,7 +579,10 @@ struct child_process *git_connect(int fd[2], const char *url_orig, git_tcp_connect(fd, host, flags); /* * Separate original protocol components prog and path - * from extended components with a NUL byte. + * from extended host header with a NUL byte. + * + * Note: Do not add any other headers here! Doing so + * will cause older git-daemon servers to crash. */ packet_write(fd[1], "%s %s%chost=%s%c", @@ -609,14 +605,18 @@ struct child_process *git_connect(int fd[2], const char *url_orig, die("command line too long"); conn->in = conn->out = -1; - conn->argv = arg = xcalloc(6, sizeof(*arg)); + conn->argv = arg = xcalloc(7, sizeof(*arg)); if (protocol == PROTO_SSH) { const char *ssh = getenv("GIT_SSH"); + int putty = ssh && strcasestr(ssh, "plink"); if (!ssh) ssh = "ssh"; *arg++ = ssh; + if (putty && !strcasestr(ssh, "tortoiseplink")) + *arg++ = "-batch"; if (port) { - *arg++ = "-p"; + /* P is for PuTTY, p is for OpenSSH */ + *arg++ = putty ? "-P" : "-p"; *arg++ = port; } *arg++ = host;