This file is indexed.

/usr/share/tkrat2.2/pgp.tcl is in tkrat 1:2.2cvs20100105-true-dfsg-6ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
# pgp.tcl --
#
# This file contains code which handles pgp interaction
#
#
#  TkRat software and its included text is Copyright 1996-2004 by
#  Martin Forssén
#
#  The full text of the legal notices is contained in the file called
#  COPYRIGHT, included with this distribution.


# RatGetPGPPassPhrase --
#
# Get the pgp pass phrase from the user
#
# Arguments:

proc RatGetPGPPassPhrase {} {
    global idCnt t

    # Create identifier
    set id pgpPass[incr idCnt]
    set w .$id
    upvar \#0 $id hd

    # Create toplevel
    toplevel $w -class TkRat
    wm title $w $t(pgp_pass_phrase) 

    # Populate window
    label $w.label -text "$t(pgp_pass_phrase):"
    entry $w.entry -textvariable ${id}(phrase) -width 32 -show -
    button $w.button_ok -text $t(ok) -command "set ${id}(done) ok"
    button $w.button_cancel -text $t(abort) -command "set ${id}(done) abort"
    grid $w.label $w.entry -pady 5 -padx 5
    grid $w.button_ok $w.button_cancel
    bind $w.entry <Return> "set ${id}(done) ok"
    wm protocol $w WM_DELETE_WINDOW "set ${id}(done) abort"

    ::tkrat::winctl::SetGeometry pgpPhrase $w
    ::tkrat::winctl::ModalGrab $w $w.entry
    bind $w <Escape> "$w.button_cancel invoke"

    tkwait variable ${id}(done)

    ::tkrat::winctl::RecordGeometry pgpPhrase $w
    destroy $w
    set ret [list $hd(done) $hd(phrase)]
    unset hd
    return $ret
}

# RatPGPError --
#
# Report an PGP error to the user. It should return either "ABORT" or
# "RETRY".
#
# Arguments:
# error	-	An error message

proc RatPGPError {error} {
    global idCnt t

    # Create identifier
    set id pgpProblem[incr idCnt]
    set w .$id
    upvar \#0 $id hd

    # Create toplevel
    toplevel $w -class TkRat
    wm title $w $t(pgp_problem) 

    # Populate window
    frame $w.f
    pack $w.f -padx 5 -pady 5 -fill both -expand 1

    label $w.f.label -text "$t(pgp_problem):"
    pack $w.f.label -side top -anchor w

    frame $w.f.t -relief sunken -bd 1
    scrollbar $w.f.t.scroll \
	-relief sunken \
	-command "$w.f.t.text yview" \
	-highlightthickness 0
    text $w.f.t.text \
	-yscroll "$w.f.t.scroll set" \
	-setgrid 1 \
	-relief raised \
	-bd 0 \
	-highlightthickness 0
    pack $w.f.t.scroll -side right -fill y
    pack $w.f.t.text -side left -expand yes -fill both
    set errmsg [string map [list "\a" ""] $error]
    $w.f.t.text insert 1.0 $errmsg
    $w.f.t.text configure -state disabled
    pack $w.f.t -expand 1 -fill both

    frame $w.f.b
    button $w.f.b.retry -text $t(retry) -command "set ${id}(done) RETRY"
    button $w.f.b.abort -text $t(abort) -command "set ${id}(done) ABORT"
    pack $w.f.b.retry $w.f.b.abort -side left -expand 1 -pady 5
    pack $w.f.b -side bottom -fill x
    wm protocol $w WM_DELETE_WINDOW "set ${id}(done) ABORT"

    ::tkrat::winctl::SetGeometry pgpError $w $w.f.t.text
    ::tkrat::winctl::ModalGrab $w
    bind $w <Escape> "$w.f.b.abort invoke"

    tkwait variable ${id}(done)

    ::tkrat::winctl::RecordGeometry pgpError $w $w.f.t.text
    destroy $w
    set action $hd(done)
    unset hd
    return $action
}

# RatPGPGetIds --
#
# Let the user select keys from her keyrings
#
# Arguments:
# proc	- procedure to call when done
# arg	- argument to procedure (before list of ids)

proc RatPGPGetIds {proc arg} {
    global idCnt t option

    # List keys
    if {[catch {RatPGP listkeys} keylist]} {
	Popup $keylist
	return
    }

    # Create identifier
    set id pgpGet[incr idCnt]
    set w .$id
    upvar \#0 $id hd

    # Create toplevel
    toplevel $w -class TkRat
    wm title $w $t(select_keys) 

    # Add text
    set hd(list) $w.l
    rat_textlist::create $hd(list) [lindex $keylist 0]
    pack $w.l -side top -fill both -expand 1

    # Buttons
    frame $w.buttons
    button $w.buttons.ok -text $t(ok) \
	    -command "RatPGPGetIdsDone $w $id 1 [list $proc $arg]"
    button $w.buttons.sel -text $t(select_all) \
	    -command "rat_textlist::selection $hd(list) set 0 end"
    button $w.buttons.unsel -text $t(deselect_all) \
	    -command "rat_textlist::selection $hd(list) clear"
    button $w.buttons.cancel -text $t(cancel) \
	    -command "RatPGPGetIdsDone $w $id 0 [list $proc $arg]"
    pack $w.buttons.ok \
	 $w.buttons.sel \
	 $w.buttons.unsel \
	 $w.buttons.cancel -side left -expand 1
    pack $w.buttons -side bottom -pady 5 -fill x

    # Populate text widget
    set hd(keys) {}
    foreach e [lindex $keylist 1] {
	lappend hd(keys) [lrange $e 0 1]
	set desc [lindex $e 2]
	foreach s [lindex $e 3] {
	    set desc "$desc\n  $s"
	}
	rat_textlist::insert $hd(list) end $desc
    }

    wm protocol $w WM_DELETE_WINDOW \
	    "RatPGPGetIdsDone $w $id 0 [list $proc $arg]"

    ::tkrat::winctl::SetGeometry pgpGet \
        $w [rat_textlist::textwidget $hd(list)]

    bind $w <Escape> "$w.buttons.cancel invoke"
}

# RatPGPGetIdsDone --
#
# Calls when the selection is done
#
# Arguments:
# w	  -	The id selection window
# handler -	The handler which identifies the session window
# done    -	The users selection (1=ok, 0=cancel)
# proc	  -	procedure to call when done
# arg	  -	argument to procedure (before list of ids)

proc RatPGPGetIdsDone {w handler done proc arg} {
    upvar \#0 $handler hd
    global option

    if {$done} {
	set ids {}
	foreach s [rat_textlist::selection $hd(list) get] {
	    lappend ids [lrange [lindex $hd(keys) $s] 0 1]
	}
	$proc $arg $ids
    }
    ::tkrat::winctl::RecordGeometry pgpGet \
        $w [rat_textlist::textwidget $hd(list)]
    catch {focus $hd(oldfocus)}
    destroy $w
    unset hd
}

# RatPGPAddKeys --
#
# Add keys to keyring
#
# Arguments:
# keys	  - Keys to add
# keyring - Keyring to add them to

proc RatPGPAddKeys {keys {keyring ""}} {
    global idCnt option t rat_tmp

    # Create identifier
    set id pgpInt[incr idCnt]
    upvar \#0 $id hd

    # Setup file
    set hd(fileName) $rat_tmp/rat.[RatGenId]
    set f [open $hd(fileName) w]
    puts $f $keys
    close $f

    # Create command and run it
    if {"" != $option(pgp_path)} {
	set dir $option(pgp_path)/
    } else {
	set dir ""
    }
    if {$option(pgp_version) == 2} {
        set cmd "${dir}pgp -ka $hd(fileName) $keyring"
    } elseif {$option(pgp_version) == 5} {
        set cmd "${dir}pgpk -ka $hd(fileName) $keyring"
    } elseif {$option(pgp_version) == "gpg-1"} {
        set cmd "${dir}gpg --no-secmem-warning -q --import $hd(fileName)"
    } elseif {$option(pgp_version) == 6} {
        set cmd "${dir}pgp -ka $hd(fileName) $keyring"
    }
    set cmd "$cmd; echo '$t(press_return_to_dismiss)'; read FOO"

    RatBgExec ${id}(existStatus) "$option(terminal) \"$cmd\""

    trace variable hd(existStatus) w RatPGPAddKeysDone
}

# RatPGPAddKeysDone --
#
# This gets called when the add command has run and should clean
# things up.
#
# Arguments:
# name1, name2 -        Variable specifiers
# op           -        Operation

proc RatPGPAddKeysDone {name1 name2 op} {
    upvar \#0 $name1 hd

    file delete -force -- $hd(fileName) &
    unset hd
}


# SetupSignAsWidget --
#
# Create a widget to select signing key
#
# w      - Window to build
# var    - Name of global variable which holds the value

proc SetupSignAsWidget {w var} {
    global t b
    upvar \#0 $var v
	
    set sa [lindex $v 1]
    if {"" == $sa} {
	set sa "-- $t(auto) --"
    }
    menubutton $w -text $sa -indicatoron 1 \
	-menu $w.m -bd 2 -relief raised -anchor w -justify left
    set b($w) pref_sign_as

    menu $w.m -postcommand "PostSignAs $w $var"
}

# PostSignAs --
#
# Post the SignAs menu
#
# Arguments
# w      - Widget
# var    - Name of global variable which holds the value

proc PostSignAs {w var} {
    global t

    $w.m delete 0 end
    set al "-- $t(auto) --"
    $w.m add command -label $al -command \
	"$w configure -text [list $al]; \
         set $var {}"
    foreach k [lindex [RatPGP listkeys SecRing] 1] {
	if {[lindex $k 4]} {
	    set label "[lindex $k 2] [join [lindex $k 3]]"
	    set ln "[lindex $k 2]\n  [join [lindex $k 3] {  }]"
	    $w.m add command -label $label -command \
		"$w configure -text [list $ln] ; \
                 set $var [list [list [lindex $k 0] $ln]]"
	}
    }
    FixMenu $w.m
}

# PGPDetails --
#
# Show detailed pgp settings when composing
#
# Arguments:
# handler - message handler

proc PGPDetails {handler} {
    global t fixedBoldFont
    upvar \#0 $handler mh

    # Create toplevel
    set w .pgp_details
    toplevel $w -class TkRat
    wm title $w $t(pgp_details) 

    # Populate window
    labelframe $w.my -text $t(my_key)
    SetupSignAsWidget $w.my.k ${handler}(pgp_signer)
    pack $w.my.k -padx 2 -pady 2 -fill x

    labelframe $w.recipients -text $t(recipients)
    text $w.recipients.t -wrap none
    pack $w.recipients.t -padx 2 -pady 2

    $w.recipients.t tag configure bold -font $fixedBoldFont -lmargin1 2
    $w.recipients.t tag configure last -spacing3 5 -lmargin1 2
    set na 0
    foreach f {to cc} {
        foreach a [RatSplitAdr $mh($f)] {
            set key_info [lindex [RatAlias expand pgp $a $mh(role)] 0]
            if {1 < [llength $key_info]} {
                set key [lindex $key_info 1]
            } else {
                set key $key_info
            }
            $w.recipients.t insert end "$t($f): " bold
            $w.recipients.t insert end "$a\n"
            $w.recipients.t insert end "$t(key): $key\n" last
            incr na
        }
    }
    if {$na < 4} {
        set na 4
    }
    $w.recipients.t configure -height [expr int($na*2.2+0.9)]

    button $w.close -text $t(close) -command "destroy $w"

    pack $w.my $w.recipients -side top -padx 2 -pady 2 -fill x
    pack $w.close -padx 2 -pady 2

    bind $w <Escape> "$w.close invoke"
    bind $w.close <Destroy> "::tkrat::winctl::RecordGeometry pgpDetails $w"
    ::tkrat::winctl::SetGeometry pgpDetails $w
    ::tkrat::winctl::ModalGrab $w
}