︙ | | |
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
-
-
+
+
|
} else {
return false
}
}
#
# NOTE: This procedure returns non-zero if the specified string value
# looks like a PGP signature. The value argument is the string
# to check.
# looks like an OpenPGP signature. The value argument is the
# string to check.
#
# <public>
proc isPgpSignature { value } {
if {[string length $value] == 0 || [string first [string trim {
-----BEGIN PGP SIGNATURE-----
}] $value] == 0} then {
return true
|
︙ | | |
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
-
-
-
-
-
+
+
+
+
+
+
|
incr counter
}
}
}
#
# NOTE: This procedure attempts to verify the PGP signature contained in
# the specified (named) file. Non-zero is only returned if the PGP
# signature is verified successfully. A script error should not be
# raised by this procedure. The fileName argument must be the fully
# qualified path and file name of the PGP signature file to verify.
# NOTE: This procedure attempts to verify the OpenPGP signature contained
# in the specified (named) file. Non-zero is only returned if the
# OpenPGP signature is verified successfully. A script error should
# not be raised by this procedure. The fileName argument must be
# the fully qualified path and file name of the OpenPGP signature
# file to verify.
#
# <public>
proc verifyPgpSignature { fileName } {
variable pgpCommand
if {[isEagle]} then {
set fileName [appendArgs \" $fileName \"]
|
︙ | | |
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
|
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
|
-
-
+
+
|
return false
}
#
# NOTE: This procedure uses the package lookup metadata. If the package
# script is properly signed, an attempt will be made to evaluate it
# in the target language. If the script was signed using PGP, then
# a conforming implementation of the OpenPGP specification (e.g.
# in the target language. If the script was signed using OpenPGP,
# then a conforming implementation of the OpenPGP specification (e.g.
# gpg2) must be installed locally. If the script was signed using
# Harpy then Garuda, Eagle, and Harpy must be installed locally.
# This procedure is designed to work for both native Tcl and Eagle
# packages. Additionally, it is designed to work when evaluated
# using either native Tcl or Eagle; however, it is up to the package
# script itself to either add the package or provide the package to
# the language(s) supported by that package. The varName argument
|
︙ | | |
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
|
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
|
-
+
-
+
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
|
#
# NOTE: If there is no package script, there is nothing we
# can do here.
#
if {[string length $metadata(script)] > 0} then {
#
# NOTE: Figure out temporary file name for the downloaded script
# and its associated PGP signature.
# and its associated OpenPGP signature.
#
set fileName(1) [getFileTempName]
set fileName(2) [appendArgs $fileName(1) .asc]
#
# NOTE: Write downloaded script to a temporary file.
#
writeFile $fileName(1) $metadata(script)
#
# NOTE: Write downloaded script PGP signature a temporary file.
# NOTE: Write downloaded script OpenPGP signature a temporary file.
#
if {[string length $metadata(certificate)] > 0} then {
writeFile $fileName(2) $metadata(certificate)
}
#
# NOTE: Attempt to verify the PGP signature for the package script.
# NOTE: Attempt to verify the OpenPGP signature for the package
# script.
#
if {[verifyPgpSignature $fileName(2)]} then {
#
# NOTE: Delete the temporary files that we created for the PGP
# signature verification.
# NOTE: Delete the temporary files that we created for the
# OpenPGP signature verification.
#
eval $script(cleanup)
} else {
#
# NOTE: Delete the temporary files that we created for the PGP
# signature verification.
# NOTE: Delete the temporary files that we created for the
# OpenPGP signature verification.
#
eval $script(cleanup)
#
# NOTE: PGP signature verification failed. Raise an error and
# do not proceed with evaluating the package script.
# NOTE: OpenPGP signature verification failed. Raise an error
# and do not proceed with evaluating the package script.
#
error "bad PGP signature"
}
#
# NOTE: The PGP signature was verified; use the downloaded package
# script verbatim.
# NOTE: The OpenPGP signature was verified; use the downloaded
# package script verbatim.
#
set script(inner) $metadata(script)
#
# NOTE: Determine the target language for the package script, which
# may or may not be the language that is currently evaluating
# this script (Eagle). The default language, when one was not
|
︙ | | |