diff options
author | Junio C Hamano <gitster@pobox.com> | 2015-10-05 12:30:14 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-10-05 12:30:14 -0700 |
commit | e6f11c19abab516b81a722ea56dccd20fb9c0987 (patch) | |
tree | aa43363976b4365530fcfcf8475880d4c6a1bfc5 /connect.c | |
parent | Merge branch 'jk/date-local' (diff) | |
parent | git_connect: clarify conn->use_shell flag (diff) | |
download | tgif-e6f11c19abab516b81a722ea56dccd20fb9c0987.tar.xz |
Merge branch 'jk/connect-clear-env'
The ssh transport, just like any other transport over the network,
did not clear GIT_* environment variables, but it is possible to
use SendEnv and AcceptEnv to leak them to the remote invocation of
Git, which is not a good idea at all. Explicitly clear them just
like we do for the local transport.
* jk/connect-clear-env:
git_connect: clarify conn->use_shell flag
git_connect: clear GIT_* environment for ssh
Diffstat (limited to 'connect.c')
-rw-r--r-- | connect.c | 26 |
1 files changed, 15 insertions, 11 deletions
@@ -721,10 +721,13 @@ struct child_process *git_connect(int fd[2], const char *url, strbuf_addch(&cmd, ' '); sq_quote_buf(&cmd, path); + /* remove repo-local variables from the environment */ + conn->env = local_repo_env; + conn->use_shell = 1; conn->in = conn->out = -1; if (protocol == PROTO_SSH) { const char *ssh; - int putty, tortoiseplink = 0; + int putty = 0, tortoiseplink = 0; char *ssh_host = hostandport; const char *port = NULL; get_host_and_port(&ssh_host, &port); @@ -746,13 +749,17 @@ struct child_process *git_connect(int fd[2], const char *url, } ssh = getenv("GIT_SSH_COMMAND"); - if (ssh) { - conn->use_shell = 1; - putty = 0; - } else { + if (!ssh) { const char *base; char *ssh_dup; + /* + * GIT_SSH is the no-shell version of + * GIT_SSH_COMMAND (and must remain so for + * historical compatibility). + */ + conn->use_shell = 0; + ssh = getenv("GIT_SSH"); if (!ssh) ssh = "ssh"; @@ -762,8 +769,9 @@ struct child_process *git_connect(int fd[2], const char *url, tortoiseplink = !strcasecmp(base, "tortoiseplink") || !strcasecmp(base, "tortoiseplink.exe"); - putty = !strcasecmp(base, "plink") || - !strcasecmp(base, "plink.exe") || tortoiseplink; + putty = tortoiseplink || + !strcasecmp(base, "plink") || + !strcasecmp(base, "plink.exe"); free(ssh_dup); } @@ -777,10 +785,6 @@ struct child_process *git_connect(int fd[2], const char *url, argv_array_push(&conn->args, port); } argv_array_push(&conn->args, ssh_host); - } else { - /* remove repo-local variables from the environment */ - conn->env = local_repo_env; - conn->use_shell = 1; } argv_array_push(&conn->args, cmd.buf); |