Overview
Comment: | Make the temporary file cleanup code shared by all the appropriate code paths. Coding style cleanup. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
3b8436d84c212d9eb62c60255d073c65 |
User & Date: | mistachkin on 2016-08-16 23:42:54 |
Other Links: | manifest | tags |
Context
2016-08-16
| ||
23:51 | Remove unused procedure argument. check-in: 6a93f22dad user: mistachkin tags: trunk | |
23:42 | Make the temporary file cleanup code shared by all the appropriate code paths. Coding style cleanup. check-in: 3b8436d84c user: mistachkin tags: trunk | |
23:16 | Add preliminary support for package scripts that are signed using OpenPGP. check-in: d81d61b270 user: mistachkin tags: trunk | |
Changes
Modified client/pkgr.eagle from [9791c3779a] to [8b2eee5e8c].
︙ | ︙ | |||
99 100 101 102 103 104 105 | proc verifyPgpSignature { fileName } { variable pgpCommand if {[isEagle]} then { set fileName [appendArgs \" $fileName \"] return [expr {[catch { | | | | 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | proc verifyPgpSignature { fileName } { variable pgpCommand if {[isEagle]} then { set fileName [appendArgs \" $fileName \"] return [expr {[catch { eval exec -success Success [subst $pgpCommand] }] == 0}] } else { return [expr {[catch { eval exec [subst $pgpCommand] 2>@1 }] == 0}] } } |
︙ | ︙ | |||
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 | # # NOTE: If the package script certificate is mising, fail. # if {![info exists metadata(certificate)]} then { error "missing script certificate" } # # NOTE: Figure out the "type" of script certificate we are now dealing # with. # if {[isHarpyCertificate $metadata(certificate)]} then { # # NOTE: Attempt to create a completely unique array variable name to # hold the package metadata in this scripting language as well # as possibly in the other necessary scripting language(s). # | > > > > > > > > > > > > > > > > > > | > > > | | > | | | 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 | # # NOTE: If the package script certificate is mising, fail. # if {![info exists metadata(certificate)]} then { error "missing script certificate" } # # NOTE: Create common cleanup script block that deletes any temporary # files created for the script verification process. # set script(cleanup) { if {[string length $fileName(2)] > 0 && \ [file exists $fileName(2)]} then { catch {file delete $fileName(2)} unset -nocomplain fileName(2) } if {[string length $fileName(1)] > 0 && \ [file exists $fileName(1)]} then { catch {file delete $fileName(1)} unset -nocomplain fileName(1) } } # # NOTE: Figure out the "type" of script certificate we are now dealing # with. # if {[isHarpyCertificate $metadata(certificate)]} then { # # NOTE: Attempt to create a completely unique array variable name to # hold the package metadata in this scripting language as well # as possibly in the other necessary scripting language(s). # set newVarName(1) [appendArgs \ [getLookupVarNamePrefix] metadata_ [getLookupVarNameSuffix]] set newVarName(2) [appendArgs \ [getLookupVarNamePrefix] cleanup_ [getLookupVarNameSuffix]] set newProcName(1) [appendArgs \ [getLookupVarNamePrefix] eagleHasSecurity_ [getLookupVarNameSuffix]] set newProcName(2) [appendArgs \ [getLookupVarNamePrefix] getFileTempName_ [getLookupVarNameSuffix]] set newProcName(3) [appendArgs \ [getLookupVarNamePrefix] tclMustBeReady_ [getLookupVarNameSuffix]] # # NOTE: Create the Eagle script block that will be used to securely # evaluate a signed package script. This must be evaluated in # Eagle because it uses several plugins only available there. # set script(outer) [string map [list \ %metadata% $newVarName(1) %cleanup% $newVarName(2) \ %eagleHasSecurity% $newProcName(1) %getFileTempName% \ $newProcName(2) %tclMustBeReady% $newProcName(3)] { try { # # NOTE: If there is no package ifneeded script, there is nothing we # can do here. # if {[string length ${%metadata%(ifNeeded)}] > 0} then { # |
︙ | ︙ | |||
472 473 474 475 476 477 478 | } default { error "unsupported language" } } } finally { # | | < < < < < < | < < < < < < > > | > | | | > | | | 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 | } default { error "unsupported language" } } } finally { # # NOTE: Perform any necessary cleanup steps. # eval ${%cleanup%} } } finally { # # NOTE: Restore the saved security state for the interpreter. # if {!$savedSecurity} then {source disableSecurity} unset -nocomplain savedSecurity } } } finally { rename {%tclMustBeReady%} "" rename {%getFileTempName%} "" rename {%eagleHasSecurity%} "" unset -nocomplain {%cleanup%} unset -nocomplain {%metadata%} } }] # # NOTE: Copy the package metadata into the fresh array variable, # if necessary, marshalling it from native Tcl to Eagle. # if {[isEagle]} then { array set $newVarName(1) [array get metadata] set $newVarName(2) $script(cleanup) proc $newProcName(1) {} [info body [appendArgs \ [namespace current] ::eagleHasSecurity]] proc $newProcName(2) {} [info body [appendArgs \ [namespace current] ::getFileTempName]] proc $newProcName(3) {} [info body [appendArgs \ [namespace current] ::tclMustBeReady]] return [eval $script(outer)] } else { eagleMustBeReady eagle [list array set $newVarName(1) [array get metadata]] eagle [list set $newVarName(2) $script(cleanup)] eagle [list proc $newProcName(1) {} [info body [appendArgs \ [namespace current] ::eagleHasSecurity]]] eagle [list proc $newProcName(2) {} [info body [appendArgs \ [namespace current] ::getFileTempName]]] eagle [list proc $newProcName(3) {} [info body [appendArgs \ [namespace current] ::tclMustBeReady]]] return [eagle $script(outer)] } } elseif {[isPgpSignature $metadata(certificate)]} then { # # NOTE: If there is no package ifneeded script, there is nothing we # can do here. |
︙ | ︙ | |||
564 565 566 567 568 569 570 | # if {[string length $metadata(certificate)] > 0} then { writeFile $fileName(2) $metadata(certificate) } # # NOTE: Attempt to verify the PGP signature for the package script. | < | > | | < | > > | | | | < | < < | | < > > > | | < | 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 | # if {[string length $metadata(certificate)] > 0} then { writeFile $fileName(2) $metadata(certificate) } # # NOTE: Attempt to verify the PGP signature for the package script. # if {[verifyPgpSignature $fileName(2)]} then { # # NOTE: Delete the temporary files that we created for the PGP # signature verification. # eval $script(cleanup) } else { # # NOTE: Delete the temporary files that we created for the PGP # signature verification. # eval $script(cleanup) # # NOTE: PGP signature verification failed. Raise an error and # do not proceed with evaluating the package script. # error [appendArgs \ "couldn't read file \"" $fileName(1) "\": bad PGP signature"] } # # NOTE: The PGP signature was verified; use the downloaded package # script verbatim. # set script(inner) $metadata(ifNeeded) # |
︙ | ︙ |
Modified client/pkgr.eagle.harpy from [7739519f37] to [161bd759dc].
︙ | ︙ | |||
17 18 19 20 21 22 23 | THE ASSOCIATED SOFTWARE MAY NOT WORK PROPERLY IF THIS FILE IS ALTERED. --> <Certificate xmlns="https://eagle.to/2011/harpy" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Protocol>None</Protocol> <Vendor>Mistachkin Systems</Vendor> | | | | | | | | | | | | | | | | | | | | | | 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 | THE ASSOCIATED SOFTWARE MAY NOT WORK PROPERLY IF THIS FILE IS ALTERED. --> <Certificate xmlns="https://eagle.to/2011/harpy" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Protocol>None</Protocol> <Vendor>Mistachkin Systems</Vendor> <Id>6b9ca4d2-f735-4a9c-9e98-6eb4e20071e5</Id> <HashAlgorithm>SHA512</HashAlgorithm> <EntityType>Script</EntityType> <TimeStamp>2016-08-16T23:38:50.4841328Z</TimeStamp> <Duration>-1.00:00:00</Duration> <Key>0x2c322765603b5278</Key> <Signature> EXlOLQrhSslSjS2f79QWCtvY5eRmAaLsMz0bissOYcPh9ce6sNgVPaWDr/oyUiQ5kwzmOE3ehBfV xMkkTDRsjBVt/oslemlHGsidiAtXtIoQB4g/d71Vmaimwz05VynhrO6tG6rwJ8UO1lbxtYrvL1vS rdVfkCQ/yHaayHYJKWrHSLshA+Bf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