TclGPG  Check-in [5ca7d8906d]

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

Overview
Comment:Fixed parsing the gpg status output during keys import if there are expired keys in the keyring. Also, added a few code comments.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:5ca7d8906d448481730b7e9d43f7d737a1c858f4
User & Date: sgolovan 2016-01-01 09:48:25
Context
2016-01-01
09:54
Extended copyright years. check-in: 6b7eef336b user: sgolovan tags: trunk
09:48
Fixed parsing the gpg status output during keys import if there are expired keys in the keyring. Also, added a few code comments. check-in: 5ca7d8906d user: sgolovan tags: trunk
2015-12-31
20:12
Explicitly unset the GPG_AGENT_INFO environment variable because it interferes with tests. check-in: 6361d617e5 user: sergei tags: trunk
Changes

Changes to ChangeLog.







1
2
3
4
5
6
7






2015-12-31  Sergei Golovan  <sgolovan@nes.ru>

	* tclgpg.test: Explicitly unset the GPG_AGENT_INFO environment
	  variable because it interferes with tests.

2015-12-30  Sergei Golovan  <sgolovan@nes.ru>

>
>
>
>
>
>







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

	* tclgpg.tcl: Fixed parsing the gpg status output during keys import
	  if there are expired keys in the keyring. Also, added a few code
	  comments.

2015-12-31  Sergei Golovan  <sgolovan@nes.ru>

	* tclgpg.test: Explicitly unset the GPG_AGENT_INFO environment
	  variable because it interferes with tests.

2015-12-30  Sergei Golovan  <sgolovan@nes.ru>

Changes to tclgpg.tcl.

646
647
648
649
650
651
652

653
654
655















656
657
658
659
660
661
662
....
1863
1864
1865
1866
1867
1868
1869



1870
1871
1872
1873
1874

1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887


1888
1889
1890
1891
1892
1893
1894
        return [UseGPG $token decrypt $commands $gpgChannels]
    }
}

# ::gpg::Import --
#
#       Import a GPG key from a keyserver, or from an URI, or from a string.

#
# Arguments:
#       token               A GPG context token created in ::gpg::context.
















proc ::gpg::Import {token args} {
    variable $token
    upvar 0 $token state

    set commands {}
    set opts {}
................................................................................
                default {
                    FinishWithError $channels $commands "Key is unusable"
                    return
                }
            }
        }




        if {[info exists state(import_error)]} {
            FinishWithError $channels $commands $state(import_error)
            return
        }


        if {[info exists state(badpassphrase)] && $state(badpassphrase)} {
            FinishWithError $channels $commands "Bad passphrase"
            return
        }

        if {[info exists state(keyexpired)] && $state(keyexpired)} {
            FinishWithError $channels $commands "Key expired"
            return
        }

        if {[info exists state(keyrevoked)] && $state(keyrevoked)} {
            FinishWithError $channels $commands "Key revoked"
            return


        }

        set data [FinishGPG $token $operation $channels $commands $input]

        CleanupGPG $channels

        if {[llength $commands] == 0} {







>



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







 







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

|
|
|
|

|
|
|
>
>







646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
....
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
        return [UseGPG $token decrypt $commands $gpgChannels]
    }
}

# ::gpg::Import --
#
#       Import a GPG key from a keyserver, or from an URI, or from a string.
#       One of the (-key, -keys), (-uri), or (-data) option must be specified.
#
# Arguments:
#       token               A GPG context token created in ::gpg::context.
#       -keyserver server   (optional, defaults to a server from the config)
#                           A keyserver to get the key(s) from.
#       -key keyspec        A key (fingerprint, keyid) to import from a
#                           keyserver.
#       -keys keyspeclist   A list of keys to import from a keyserver.
#       -uri uri            An URI to fetch a key to import from.
#       -data keydata       A key data to import.
#       -command command    (optional, defaults to none) Callback for the
#                           case of asynchronous operation.
#
# Result:
#       A list of import statuses for all affected keys (TODO: elaborate).
#
# Side effects:
#       GPG keyring is updated.

proc ::gpg::Import {token args} {
    variable $token
    upvar 0 $token state

    set commands {}
    set opts {}
................................................................................
                default {
                    FinishWithError $channels $commands "Key is unusable"
                    return
                }
            }
        }

        switch -- $operation {
            import -
            fetch {
                if {[info exists state(import_error)]} {
                    FinishWithError $channels $commands $state(import_error)
                    return
                }
            }
            default {
                if {[info exists state(badpassphrase)] && $state(badpassphrase)} {
                    FinishWithError $channels $commands "Bad passphrase"
                    return
                }

                if {[info exists state(keyexpired)] && $state(keyexpired)} {
                    FinishWithError $channels $commands "Key expired"
                    return
                }

                if {[info exists state(keyrevoked)] && $state(keyrevoked)} {
                    FinishWithError $channels $commands "Key revoked"
                    return
                }
            }
        }

        set data [FinishGPG $token $operation $channels $commands $input]

        CleanupGPG $channels

        if {[llength $commands] == 0} {