From: Alexander Gavrilov <angavrilov@gmail.com>
To: git@vger.kernel.org
Cc: msysgit@googlegroups.com,
Johannes Sixt <johannes.sixt@telecom.at>,
"Shawn O. Pearce" <spearce@spearce.org>,
Junio C Hamano <gitster@pobox.com>
Subject: [PATCH (GIT-GUI,MINGW) 2/3] git-gui: Add a simple implementation of SSH_ASKPASS.
Date: Mon, 20 Oct 2008 20:02:19 +0400 [thread overview]
Message-ID: <1224518540-23782-3-git-send-email-angavrilov@gmail.com> (raw)
In-Reply-To: <1224518540-23782-2-git-send-email-angavrilov@gmail.com>
OpenSSH allows specifying an external program to use
for direct user interaction. While most Linux systems
already have such programs, some environments, for
instance, msysgit, lack it. This patch adds a simple
fallback Tcl implementation of the tool.
In msysgit it is also necessary to set a fake value of
the DISPLAY variable, because otherwise ssh won't even
try to use SSH_ASKPASS handlers.
Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
---
Makefile | 2 ++
git-gui.sh | 12 ++++++++++++
git-gui--askpass | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 73 insertions(+), 0 deletions(-)
create mode 100755 git-gui--askpass
diff --git a/Makefile b/Makefile
index 55765c8..0ee47bf 100644
--- a/Makefile
+++ b/Makefile
@@ -285,6 +285,7 @@ all:: $(GITGUI_MAIN) lib/tclIndex $(ALL_MSGFILES)
install: all
$(QUIET)$(INSTALL_D0)'$(DESTDIR_SQ)$(gitexecdir_SQ)' $(INSTALL_D1)
$(QUIET)$(INSTALL_X0)git-gui $(INSTALL_X1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
+ $(QUIET)$(INSTALL_X0)git-gui--askpass $(INSTALL_X1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
$(QUIET)$(foreach p,$(GITGUI_BUILT_INS), $(INSTALL_L0)'$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' $(INSTALL_L1)'$(DESTDIR_SQ)$(gitexecdir_SQ)/git-gui' $(INSTALL_L2)'$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' $(INSTALL_L3) &&) true
ifdef GITGUI_WINDOWS_WRAPPER
$(QUIET)$(INSTALL_R0)git-gui.tcl $(INSTALL_R1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
@@ -302,6 +303,7 @@ endif
uninstall:
$(QUIET)$(CLEAN_DST) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui $(REMOVE_F1)
+ $(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui--askpass $(REMOVE_F1)
$(QUIET)$(foreach p,$(GITGUI_BUILT_INS), $(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/$p $(REMOVE_F1) &&) true
ifdef GITGUI_WINDOWS_WRAPPER
$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui.tcl $(REMOVE_F1)
diff --git a/git-gui.sh b/git-gui.sh
index e4d1f70..5e04a7c 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -592,6 +592,11 @@ bind . <Visibility> {
if {[is_Windows]} {
wm iconbitmap . -default $oguilib/git-gui.ico
set ::tk::AlwaysShowSelection 1
+
+ # Spoof an X11 display for SSH
+ if {![info exists env(DISPLAY)]} {
+ set env(DISPLAY) :native
+ }
}
######################################################################
@@ -1071,6 +1076,13 @@ set nullid2 "0000000000000000000000000000000000000001"
set have_tk85 [expr {[package vcompare $tk_version "8.5"] >= 0}]
######################################################################
+
+# Suggest our implementation of askpass, if not already set
+if {![info exists env(SSH_ASKPASS)]} {
+ set env(SSH_ASKPASS) [gitexec git-gui--askpass]
+}
+
+######################################################################
##
## task management
diff --git a/git-gui--askpass b/git-gui--askpass
new file mode 100755
index 0000000..12e117e
--- /dev/null
+++ b/git-gui--askpass
@@ -0,0 +1,59 @@
+#!/bin/sh
+# Tcl ignores the next line -*- tcl -*- \
+exec wish "$0" -- "$@"
+
+# This is a trivial implementation of an SSH_ASKPASS handler.
+# Git-gui uses this script if none are already configured.
+
+set answer {}
+set yesno 0
+set rc 255
+
+if {$argc < 1} {
+ set prompt "Enter your OpenSSH passphrase:"
+} else {
+ set prompt [join $argv " "]
+ if {[regexp -nocase {\(yes\/no\)\?\s*$} $prompt]} {
+ set yesno 1
+ }
+}
+
+message .m -text $prompt -justify center -aspect 4000
+pack .m -side top -fill x -padx 20 -pady 20 -expand 1
+
+entry .e -textvariable answer -width 50
+pack .e -side top -fill x -padx 10 -pady 10
+
+if {!$yesno} {
+ .e configure -show "*"
+}
+
+frame .b
+button .b.ok -text OK -command finish
+button .b.cancel -text Cancel -command {destroy .}
+
+pack .b.ok -side left -expand 1
+pack .b.cancel -side right -expand 1
+pack .b -side bottom -fill x -padx 10 -pady 10
+
+bind . <Visibility> {focus -force .e}
+bind . <Key-Return> finish
+bind . <Key-Escape> {destroy .}
+bind . <Destroy> {exit $rc}
+
+proc finish {} {
+ if {$::yesno} {
+ if {$::answer ne "yes" && $::answer ne "no"} {
+ tk_messageBox -icon error -title "Error" -type ok \
+ -message "Only 'yes' or 'no' input allowed."
+ return
+ }
+ }
+
+ set ::rc 0
+ puts $::answer
+ destroy .
+}
+
+wm title . "OpenSSH"
+tk::PlaceWindow .
--
1.6.0.20.g6148bc
next prev parent reply other threads:[~2008-10-20 16:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-20 16:02 [PATCH (GIT-GUI,MINGW) 0/3] Fix OpenSSH & Git-Gui integration in msysgit Alexander Gavrilov
2008-10-20 16:02 ` [PATCH (GIT-GUI,MINGW) 1/3] git-gui: Add a dialog that shows the OpenSSH public key Alexander Gavrilov
2008-10-20 16:02 ` Alexander Gavrilov [this message]
2008-10-20 16:02 ` [PATCH (GIT-GUI,MINGW) 3/3] Windows: Make OpenSSH properly detect tty detachment Alexander Gavrilov
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1224518540-23782-3-git-send-email-angavrilov@gmail.com \
--to=angavrilov@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=johannes.sixt@telecom.at \
--cc=msysgit@googlegroups.com \
--cc=spearce@spearce.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.
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 NNTP newsgroup(s).