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

Re: [BUG] GIT_SSH_COMMAND is not being decomposed

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 16, 2019, 04:24 UTC
Message-ID
<xmqqsguipofi.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<008101d4f3db$56c20410$04460c30$@nexbridge.com>
"Randall S. Becker" <rsbecker@nexbridge.com> writes:
> As a suggestion, with people who know how to escape stuff properly
> (or not), perhaps we can select the alternate behaviour explicitly
> using a core.sshIgnoreEscape=true/false option. Thoughts on that?

The semantics of prepare_shell_cmd() is, regardless of any "funny characters" on the command line, the spawned command MUST behave AS IF it was run via the shell. The strcspn() trick is there merely as a low-level optimization so that we do not have to say

	sh -c a-single-token
which would be exactly the same as running
	a-single-token
The most typical use of that strcspn() trick is to ensure that
	GIT_SSH_COMMAND="the-command and its arguments"

would not attempt to run a command with a long and funny name "the-command and its arguments" somewhere on the $PATH without any parameter, and instead run

	sh -c "the-command and its arguments"

i.e. run the "the-command" with three parameters (and perhaps more built-in parameters prepared by the caller in the ssh connection codepath).

Previous: Randall S. BeckerNext: Johannes Sixt
Message 9 of 10 in “[BUG] GIT_SSH_COMMAND is not being decomposed”
  1. Randall S. BeckerApr 13, 2019
  2. Ævar Arnfjörð BjarmasonApr 13, 2019
  3. Randall S. BeckerApr 13, 2019
  4. SZEDER GáborApr 13, 2019
  5. Randall S. BeckerApr 14, 2019
  6. Randall S. BeckerApr 15, 2019
  7. Andreas SchwabApr 15, 2019
  8. Randall S. BeckerApr 15, 2019
  9. Junio C HamanoApr 16, 2019
  10. Johannes SixtApr 15, 2019

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.