1
# git-gui about git-gui dialog
2
# Copyright (C) 2006, 2007 Shawn Pearce
6
~/.ssh/id_dsa.pub ~/.ssh/id_ecdsa.pub ~/.ssh/id_ed25519.pub
7
~/.ssh/id_rsa.pub ~/.ssh/identity.pub
9
if {[file exists $name]} {
13
return [list $name $cont]
21
global sshkey_title have_tk85 sshkey_fd use_ttk NS
24
if {[winfo exists $w]} {
32
set finfo [find_ssh_key]
34
set sshkey_title [mc "No keys found."]
37
set sshkey_title [mc "Found a public key in: %s" [lindex $finfo 0]]
38
set gen_state disabled
41
${NS}::frame $w.header
42
${NS}::label $w.header.lbl -textvariable sshkey_title -anchor w
43
${NS}::button $w.header.gen -text [mc "Generate Key"] \
44
-command [list make_ssh_key $w] -state $gen_state
45
pack $w.header.lbl -side left -expand 1 -fill x
46
pack $w.header.gen -side right
47
pack $w.header -fill x -pady 5 -padx 5
49
text $w.contents -width 60 -height 10 -wrap char -relief sunken
50
pack $w.contents -fill both -expand 1
53
if {$use_ttk} { set clr [ttk::style lookup . -selectbackground] }
54
$w.contents configure -inactiveselectbackground $clr
57
${NS}::frame $w.buttons
58
${NS}::button $w.buttons.close -text [mc Close] \
59
-default active -command [list destroy $w]
60
pack $w.buttons.close -side right
61
${NS}::button $w.buttons.copy -text [mc "Copy To Clipboard"] \
62
-command [list tk_textCopy $w.contents]
63
pack $w.buttons.copy -side left
64
pack $w.buttons -side bottom -fill x -pady 5 -padx 5
67
$w.contents insert end [lindex $finfo 1] sel
69
$w.contents configure -state disabled
71
bind $w <Visibility> "grab $w; focus $w.buttons.close"
72
bind $w <Key-Escape> "destroy $w"
73
bind $w <Key-Return> "destroy $w"
74
bind $w <Destroy> kill_sshkey
75
wm title $w [mc "Your OpenSSH Public Key"]
76
tk::PlaceWindow $w widget .
80
proc make_ssh_key {w} {
81
global sshkey_title sshkey_output sshkey_fd
83
set sshkey_title [mc "Generating..."]
84
$w.header.gen configure -state disabled
86
set cmdline [list sh -c {echo | ssh-keygen -q -t rsa -f ~/.ssh/id_rsa 2>&1}]
88
if {[catch { set sshkey_fd [_open_stdout_stderr $cmdline] } err]} {
89
error_popup [mc "Could not start ssh-keygen:\n\n%s" $err]
94
fconfigure $sshkey_fd -blocking 0
95
fileevent $sshkey_fd readable [list read_sshkey_output $sshkey_fd $w]
100
if {![info exists sshkey_fd]} return
101
catch { kill_file_process $sshkey_fd }
102
catch { close $sshkey_fd }
105
proc read_sshkey_output {fd w} {
106
global sshkey_fd sshkey_output sshkey_title
108
set sshkey_output "$sshkey_output[read $fd]"
109
if {![eof $fd]} return
111
fconfigure $fd -blocking 1
114
$w.contents configure -state normal
115
if {[catch {close $fd} err]} {
116
set sshkey_title [mc "Generation failed."]
117
$w.contents insert end $err
118
$w.contents insert end "\n"
119
$w.contents insert end $sshkey_output
121
set finfo [find_ssh_key]
123
set sshkey_title [mc "Generation succeeded, but no keys found."]
124
$w.contents insert end $sshkey_output
126
set sshkey_title [mc "Your key is in: %s" [lindex $finfo 0]]
127
$w.contents insert end [lindex $finfo 1] sel
130
$w.contents configure -state disable