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

Re: [PATCH v4 2/3] git-core: Support retrieving passwords with GIT_ASKPASS

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 3, 2010, 19:56 UTC
Message-ID
<7vd3zlqivv.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1267616208-3844-1-git-send-email-lznuaa@gmail.com>
Frank Li <lznuaa@gmail.com> writes:
Show 8 quoted lines
> imap-send and authority http connect reads passwords from an interactive
> terminal. This behavious cause GUIs to hang waiting for git complete.
>
> Fix this problem by allowing a password-retrieving command
> to be specified in GIT_ASKPASS
>
> Signed-off-by: Frank Li <lznuaa@gmail.com>
> ---

It appears that between v3 and v4 you incorporated all the changes J6t suggested. I would have preferred to see you Cc him, so that he can simply respond with "Acked-by:" (or another round of review cycle).

Show 9 quoted lines
> +char *git_getpass(const char *prompt)
> +{
> ...
> +	memset(&pass, 0, sizeof(pass));
> +	pass.argv = args;
> +	pass.out = -1;
> +
> +	if (start_command(&pass))
> +		exit(1);

I understand that you exit silently here because start-command would have given diagnostic messages already.

> +	if (strbuf_read(&buffer, pass.out, 20) < 0)
> +		exit(1);

What about this one? Running out of memory inside strbuf_grow() may have died with message but other error conditions that do give control back to the caller seem pretty quiet to my cursory look...

> +	close(pass.out);
> +
> +	if (finish_command(&pass))
> +		exit(1);

This silent exit is correct, I think; wait_or_whine() called by finish_command() would have reported errors.

> +	strbuf_setlen(&buffer, strcspn(buffer.buf, "\r\n"));
> +
> +	/*it maybe memory leak because getpass return a static buffer*/
> +	return strbuf_detach(&buffer, NULL);

Perhaps keep this value in a "static char *" in the function and free it upon entry on the second call?

Previous: Frank Li
Message 2 of 2 in “git-core: Support retrieving passwords with GIT_ASKPASS”
  1. 2/3 git-core: Support retrieving passwords with GIT_ASKPASSFrank Li, Mar 3, 2010
  2. Junio C HamanoMar 3, 2010

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.