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

GIT_ASKPASS absolute path detection bug on Windows

From
AKAndrás Kucsma <andras.kucsma@gmail.com>
Date
Mar 21, 2020, 11:42 UTC
Message-ID
<CANPdQv+tCnfy_csM8EwuqAYBtgkJ3RhRvo+ALbzO=BcZA7qJtg@mail.gmail.com>
Hi All,

I believe to have found an issue regarding properly executing the GIT_ASKPASS binary. I'm using Windows Server 2019, with git 2.21.0 installed using cygwin.

## To reproduce:

Assume you have the askpass binary at C:\askpass.bat. In CMD the following commands reproduce the issue:

C:\> set GIT_ASKPASS=C:\askpass.bat C:\> git clone https://<private_repository>.git Cloning into '<private_repository>'... error: cannot run C:\askpass.bat: No such file or directory [... proceeds to interactively ask for username and password ...]

On the other hand, if we change the GIT_ASKPASS environment variable slightly, so that there is a forward slash (/) instead of a backslash (\), things work as expected:

C:\> set GIT_ASKPASS=C:/askpass.bat C:\> git clone https://<private_repository>.git Cloning into '<private_repository>'... [... success ...]

## Some context:

The source of the problem, is that if git doesn't find a forward slash anywhere in the path, it assumes it is not a real path and has to look for the binary using the PATH environment variable. See in prepare_cmd(): https://github.com/git/git/blob/98cedd0233e/run-command.c#L429-L439

You can see that the "cannot run" error message is printed here, just after prepare_cmd() returned -1: https://github.com/git/git/blob/98cedd0233e/run-command.c#L749-L753

I believe this was introduced in late 2018 around git v2.19.2, although I did not actually bisect the issue: https://github.com/git/git/commit/321fd823897#diff-7577a5178f8cdc0f719e580577889f04R401-R415

I hope I'm sharing this bug at the right forum. Please direct me to the proper place if not.

Thank you, Andras

Next: Torsten Bögershausen
Message 1 of 9 in “GIT_ASKPASS absolute path detection bug on Windows”
  1. András KucsmaMar 21, 2020
  2. Torsten BögershausenMar 22, 2020
  3. András KucsmaMar 22, 2020
  4. brian m. carlsonMar 22, 2020
  5. Torsten BögershausenMar 22, 2020
  6. András KucsmaMar 22, 2020
  7. Achim GratzMar 22, 2020
  8. Torsten BögershausenMar 23, 2020
  9. András KucsmaMar 23, 2020

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.