git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 1/2] git_connect: set ssh shell command in GIT_SSH_CMD

From
Jeff King <peff@peff.net>
Date
Nov 9, 2014, 09:51 UTC
Message-ID
<20141109095155.GB17369@peff.net>
In-Reply-To
<20141108142753.GA28652@melamine.cuivre.fr.eu.org>
On Sat, Nov 08, 2014 at 03:27:53PM +0100, Thomas Quinot wrote:
Show 5 quoted lines
> It may be impractical to install a wrapper script for GIT_SSH
> when additional parameters need to be passed. Provide an alternative
> way of specifying a shell command to be run, including command line
> arguments, by means of the GIT_SSH_CMD environment variable, which
> behaves like GIT_SSH but is passed to the shell.

Thanks, I like this much better. The name GIT_SSH_CMD is not too bad. Personally, of the two (GIT_SSH and GIT_SSH_CMD) I would expect the "_CMD" form to be the one that does not use the shell. But I do not really have a better suggestion for the name, so perhaps it's OK.

Show 8 quoted lines
> Note that with this first patch only, the special processing for PuTTY/plink
> looks at the whole command in that case. I deliberately left it that way,
> even though one might imagine a case where this would cause a false positive,
> e.g. if the user's login name includes the string 'plink':
>    GIT_SSH_CMD="ssh -l fooplink"
> 
> The work-around in this case would be to write:
>    GIT_SSH_CMD="ssh -l foop''link"

I'd be tempted to say that the "plink" magic does not need to kick in at all for GIT_SSH_CMD. There are simply too many corner cases in trying to guess what the shell is going to run. For example:

> A second patch, coming in a followup message, pre-splits $GIT_SSH_CMD
> and ensures that we look for "plink"/"tortoiseplink" only in the argv[0]
> element.

I don't think you can pre-split accurately. Since we promise to pass the result to the shell, the user gets to write whatever they want. Even:

  GIT_SSH_CMD='f() {
    if test "$(hostname)" = "some-machine"; then
      some-special-ssh "$@"
    else
      ssh "$@"
  }
  f'

Parsing complications aside, you cannot even know in git which ssh is going to be run until the shell code is executed. I think either we have to leave the responsibility for munging "-p" into "-P" on the side of the user's shell snippet (and remember that they can still use GIT_SSH as usual, so we are not making anything _worse_ for them here), or we have to provide some unambiguous way for them to signal which calling convention we want ($GIT_SSH_CMD_IS_PLINK or something).

-Peff
Previous: Thomas QuinotNext: Thomas Quinot
Message 5 of 15 in “git_connect: allow passing arguments to ssh in GIT_SSH_ARGS”
  1. git_connect: allow passing arguments to ssh in GIT_SSH_ARGSThomas Quinot, Nov 8, 2014
  2. Jeff KingNov 8, 2014
  3. Thomas QuinotNov 8, 2014
  4. 1/2 git_connect: set ssh shell command in GIT_SSH_CMDThomas Quinot, Nov 8, 2014
  5. Jeff KingNov 9, 2014
  6. Thomas QuinotNov 9, 2014
  7. git_connect: set ssh shell command in GIT_SSH_CMDThomas Quinot, Nov 9, 2014
  8. Junio C HamanoNov 9, 2014
  9. Thomas QuinotNov 9, 2014
  10. Junio C HamanoNov 9, 2014
  11. git_connect: set ssh shell command in GIT_SSH_COMMANDThomas Quinot, Nov 9, 2014
  12. Jeff KingNov 10, 2014
  13. Thomas QuinotNov 10, 2014
  14. Junio C HamanoNov 10, 2014
  15. 2/2 git_connect: when using GIT_SSH_CMD, check for plink in argv[0] onlyThomas Quinot, Nov 8, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.