TclGPG  Check-in [82ad8f2e80]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Take the name of GnuPG executable from the $GPG_EXECUTABLE environment variable if it's set.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 82ad8f2e80da1505da7e74317a148ed0ad902d64
User & Date: sgolovan 2015-12-26 07:25:12
Context
2015-12-26
10:13
Fixed a harmless but annoying warning with integer to pointer conversion. check-in: 9a3ebdb085 user: sgolovan tags: trunk
07:25
Take the name of GnuPG executable from the $GPG_EXECUTABLE environment variable if it's set. check-in: 82ad8f2e80 user: sgolovan tags: trunk
2015-10-08
10:51
Fixed work with GnuPG 2.1 which doesn't require the GPG_AGENT_INFO environment variable to be defined. Extended copyright period. check-in: b0d82f8bec user: sgolovan tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ChangeLog.






1
2
3
4
5
6
7





2015-10-08  Sergei Golovan  <sgolovan@nes.ru>

	* tclgpg.tcl: Fixed work with GnuPG 2.1 which doesn't require the
	  GPG_AGENT_INFO environment variable to be defined.

	* doc/gpg.man, tclgpg.tcl: Extended copyright period.

>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
2015-12-26  Sergei Golovan  <sgolovan@nes.ru>

	* doc/gpg.man, tclgpg.tcl: Take the name of GnuPG executable from
	  the $GPG_EXECUTABLE environment variable if it's set.

2015-10-08  Sergei Golovan  <sgolovan@nes.ru>

	* tclgpg.tcl: Fixed work with GnuPG 2.1 which doesn't require the
	  GPG_AGENT_INFO environment variable to be defined.

	* doc/gpg.man, tclgpg.tcl: Extended copyright period.

Changes to doc/gpg.man.

139
140
141
142
143
144
145















146
147
148
149
150
151
152
set gpg [::gpg::new]
$gpg set -property armor -value true
$gpg set -property encoding -value utf-8
$gpg set -property passphrase-callback -value pass
puts [$gpg encrypt -input Hello]
$gpg free
}]
















[section "AUTHORS"]
Sergei Golovan

[keywords Tcl GnuPG]
[comment { vim: set ft=tcl ts=8 sw=4 sts=4 et: }]
[manpage_end]







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
set gpg [::gpg::new]
$gpg set -property armor -value true
$gpg set -property encoding -value utf-8
$gpg set -property passphrase-callback -value pass
puts [$gpg encrypt -input Hello]
$gpg free
}]

[section ENVIRONMENT]

[list_begin definitions]

[def [var \$GPG_EXECUTABLE]]

This variable specifies the GnuPG executable if it isn't [cmd gpg] or
can't be found in a directory from the [var \$PATH] environment variable.

[def [var \$GPG_AGENT_INFO]]

This variable is required for the [package gpg] packge to work with GnuPG 2.0.

[list_end]

[section "AUTHORS"]
Sergei Golovan

[keywords Tcl GnuPG]
[comment { vim: set ft=tcl ts=8 sw=4 sts=4 et: }]
[manpage_end]

Changes to tclgpg.tcl.

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
    if {[package vsatisfies $::tcl_version 8.6]} {
        interp alias {} pipe {} chan pipe
    } elseif {[catch {package require pipe}]} {
        package require Tclx
    }
}










if {[llength [auto_execok gpg]] == 0 || \
        ![regexp {^gpg \(GnuPG\) ([\d\.]+)} \
                 [exec [lindex [auto_execok gpg] 0] --version] \
                 -> gpgVersion]} {

    return -code error "GnuPG binary is unusable"
}

if {[package vsatisfies $gpgVersion 2.0] && \

        ![package vsatisfies $gpgVersion 2.1] && \
        ![info exists ::env(GPG_AGENT_INFO)]} {
    unset gpgVersion
    return -code error "GnuPG 2.0 cannot be used without gpg-agent"

}

namespace eval ::gpg {
    variable validities [list unknown undefined never marginal full ultimate]

    variable Version $::gpgVersion
    unset ::gpgVersion

    # Variable to store public keys
    variable keys

    variable debug 0
}

# ::gpg::executable --







>
>
>
>
>
>
>
>
>
|
|
|
|
>
|
|

|
>
|
|
|
|
>
|

<


<
<
<







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
    if {[package vsatisfies $::tcl_version 8.6]} {
        interp alias {} pipe {} chan pipe
    } elseif {[catch {package require pipe}]} {
        package require Tclx
    }
}

namespace eval ::gpg {
    variable gpgExecutable gpg

    if {[info exists ::env(GPG_EXECUTABLE)]} {
        set gpgExecutable $::env(GPG_EXECUTABLE)
    }

    variable Version

    if {[llength [auto_execok $gpgExecutable]] == 0 || \
            ![regexp {^gpg \(GnuPG\) ([\d\.]+)} \
                     [exec [lindex [auto_execok $gpgExecutable] 0] --version] \
                     -> Version]} {
        namespace delete ::gpg
        return -code error "GnuPG binary $gpgExecutable is unusable"
    }

    if {[package vsatisfies $Version 2.0] && \
            ![package vsatisfies $Version 2.0.26] && \
            ![package vsatisfies $Version 2.1] && \
            ![info exists ::env(GPG_AGENT_INFO)]} {
        namespace delete ::gpg
        return -code error "GnuPG 2.0 cannot be used without \$GPG_AGENT_INFO\
                            environment variable"
    }


    variable validities [list unknown undefined never marginal full ultimate]




    # Variable to store public keys
    variable keys

    variable debug 0
}

# ::gpg::executable --
54
55
56
57
58
59
60


61
62
63
64
65
66
67
68
#       Full pathname of the first occurence of the GnuPG executable found
#       or an empty string if the search yielded no results.
#
# Side effects:
#       Updates the global Tcl array auto_execs on success (see library(3tcl)).

proc ::gpg::executable {} {


    lindex [auto_execok gpg] 0
}

# ::gpg::new --
#
#       Create a new GPG context token.
#
# Arguments:







>
>
|







62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#       Full pathname of the first occurence of the GnuPG executable found
#       or an empty string if the search yielded no results.
#
# Side effects:
#       Updates the global Tcl array auto_execs on success (see library(3tcl)).

proc ::gpg::executable {} {
    variable gpgExecutable

    lindex [auto_execok $gpgExecutable] 0
}

# ::gpg::new --
#
#       Create a new GPG context token.
#
# Arguments: