git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Alexander Sulfrian <alexander@sulfrian.net>
To: git@vger.kernel.org
Cc: Alexander Sulfrian <alexander@sulfrian.net>
Subject: [PATCH] git_getpass: fix ssh-askpass behaviour
Date: Sun, 12 Dec 2010 13:32:54 +0100	[thread overview]
Message-ID: <1292157174-4033-2-git-send-email-alexander@sulfrian.net> (raw)
In-Reply-To: <AANLkTinES5dqt+JAMOrp7gAYJ4UgK9ipfEN9ag5qSCLp@mail.gmail.com>

call ssh-askpass only if the display environment variable is also set
---
 connect.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/connect.c b/connect.c
index 57dc20c..2810e3b 100644
--- a/connect.c
+++ b/connect.c
@@ -621,7 +621,7 @@ int finish_connect(struct child_process *conn)
 
 char *git_getpass(const char *prompt)
 {
-	const char *askpass;
+	const char *askpass, *display;
 	struct child_process pass;
 	const char *args[3];
 	static struct strbuf buffer = STRBUF_INIT;
@@ -631,7 +631,10 @@ char *git_getpass(const char *prompt)
 		askpass = askpass_program;
 	if (!askpass)
 		askpass = getenv("SSH_ASKPASS");
-	if (!askpass || !(*askpass)) {
+
+	/* only call askpass if display is set */
+	display = getenv("DISPLAY");
+	if (!display || !(*display) || !askpass || !(*askpass))
 		char *result = getpass(prompt);
 		if (!result)
 			die_errno("Could not read password");
-- 
1.7.2.2

  parent reply	other threads:[~2010-12-12 12:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-11  3:24 git calls SSH_ASKPASS even if DISPLAY is not set Xin Wang
2010-12-12 12:32 ` [RFC/PATCH] " Alexander Sulfrian
2010-12-12 12:32 ` Alexander Sulfrian [this message]
2010-12-12 13:07   ` [PATCH] git_getpass: fix ssh-askpass behaviour Alexander Sulfrian
2010-12-13  0:41   ` Junio C Hamano
2010-12-13 22:00     ` hvoigt
2010-12-13  9:48   ` Johannes Sixt
2012-05-07 21:42 ` git calls SSH_ASKPASS even if DISPLAY is not set LarryMartell
  -- strict thread matches above, loose matches on Subject: below --
2010-12-13  4:09 [PATCH] git_getpass: fix ssh-askpass behaviour Xin Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1292157174-4033-2-git-send-email-alexander@sulfrian.net \
    --to=alexander@sulfrian.net \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).