Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch safe-bugfixes-8-6 Excluding Merge-Ins
This is equivalent to a diff from a05f28460a to 52618064a8
|
2020-08-28
| ||
| 19:24 | Merge safe-bugfixes-8-6 check-in: a638b9a73b user: kjnash tags: core-8-6-branch | |
| 19:13 | Merge 8.6 Closed-Leaf check-in: 52618064a8 user: kjnash tags: safe-bugfixes-8-6 | |
| 19:10 | Merge bug-c2dc1da315-for-8-6 check-in: a05f28460a user: kjnash tags: core-8-6-branch | |
| 18:54 | Merge http-bug-cb0373bb33-again-for-8-6 check-in: 52561981ab user: kjnash tags: core-8-6-branch | |
| 18:34 | Merge 8.6 Closed-Leaf check-in: 8342739274 user: kjnash tags: bug-c2dc1da315-for-8-6 | |
| 01:03 | Update safe.test for new error message. check-in: ed691d3950 user: kjnash tags: safe-bugfixes-8-6 | |
Changes to doc/safe.n.
| ︙ | |||
68 69 70 71 72 73 74 75 76 77 78 | 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 | + + + + + + - + + + | Creates a safe interpreter, installs the aliases described in the section \fBALIASES\fR and initializes the auto-loading and package mechanism as specified by the supplied \fIoptions\fR. See the \fBOPTIONS\fR section below for a description of the optional arguments. If the \fIslave\fR argument is omitted, a name will be generated. \fB::safe::interpCreate\fR always returns the interpreter name. .sp The interpreter name \fIslave\fR may include namespace separators, but may not have leading or trailing namespace separators, or excess colon characters in namespace separators. The interpreter name is qualified relative to the global namespace ::, not the namespace in which the \fB::safe::interpCreate\fR command is evaluated. .TP \fB::safe::interpInit\fR \fIslave\fR ?\fIoptions...\fR? This command is similar to \fBinterpCreate\fR except it that does not create the safe interpreter. \fIslave\fR must have been created by some |
| ︙ |
Changes to library/package.tcl.
| ︙ | |||
475 476 477 478 479 480 481 | 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 | - - - + + + + + + |
# Make sure we only scan each directory one time.
if {[info exists tclSeenPath($dir)]} {
set use_path [lrange $use_path 0 end-1]
continue
}
set tclSeenPath($dir) 1
|
| ︙ | |||
581 582 583 584 585 586 587 588 589 590 591 592 593 594 | 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 | + |
if {[info exists tclSeenPath($dir)]} {
set use_path [lrange $use_path 0 end-1]
continue
}
set tclSeenPath($dir) 1
# get the pkgIndex files out of the subdirectories
# Safe interpreters do not use tcl::MacOSXPkgUnknown - see init.tcl.
foreach file [glob -directory $dir -join -nocomplain \
* Resources Scripts pkgIndex.tcl] {
set dir [file dirname $file]
if {![info exists procdDirs($dir)]} {
try {
source $file
} trap {POSIX EACCES} {} {
|
| ︙ |
Changes to library/safe.tcl.
| ︙ | |||
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | 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 | + + - + |
# API entry points that needs argument parsing :
#
####
# Interface/entry point function and front end for "Create"
proc ::safe::interpCreate {args} {
set Args [::tcl::OptKeyParse ::safe::interpCreate $args]
RejectExcessColons $slave
InterpCreate $slave $accessPath \
[InterpStatics] [InterpNested] $deleteHook
}
proc ::safe::interpInit {args} {
set Args [::tcl::OptKeyParse ::safe::interpIC $args]
if {![::interp exists $slave]} {
return -code error "\"$slave\" is not an interpreter"
}
RejectExcessColons $slave
InterpInit $slave $accessPath \
[InterpStatics] [InterpNested] $deleteHook
}
# Check that the given slave is "one of us"
proc ::safe::CheckInterp {slave} {
|
| ︙ | |||
119 120 121 122 123 124 125 | 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | - + |
1 {
# If we have exactly 1 argument the semantic is to return all
# the current configuration. We still call OptKeyParse though
# we know that "slave" is our given argument because it also
# checks for the "-help" option.
set Args [::tcl::OptKeyParse ::safe::interpIC $args]
CheckInterp $slave
|
| ︙ | |||
142 143 144 145 146 147 148 | 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | - + |
set hits [::tcl::OptHits desc $arg]
if {$hits > 1} {
return -code error [::tcl::OptAmbigous $desc $arg]
} elseif {$hits == 0} {
return -code error [::tcl::OptFlagUsage $desc $arg]
}
CheckInterp $slave
|
| ︙ | |||
183 184 185 186 187 188 189 | 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | - + - + - + |
}
}
default {
# Otherwise we want to parse the arguments like init and
# create did
set Args [::tcl::OptKeyParse ::safe::interpIC $args]
CheckInterp $slave
|
| ︙ | |||
221 222 223 224 225 226 227 | 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 | - + + + + + + + + + + + + + + + + + + + + |
# auto_reset the slave (to completly synch the new access_path)
if {$doreset} {
if {[catch {::interp eval $slave {auto_reset}} msg]} {
Log $slave "auto_reset failed: $msg"
} else {
Log $slave "successful auto_reset" NOTICE
}
|
| ︙ | |||
260 261 262 263 264 265 266 267 | 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 | + + - + |
slave
access_path
staticsok
nestedok
deletehook
} {
# Create the slave.
# If evaluated in ::safe, the interpreter command for foo is ::foo;
# but for foo::bar is safe::foo::bar. So evaluate in :: instead.
if {$slave ne ""} {
|
| ︙ | |||
314 315 316 317 318 319 320 | 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 | - + |
# so by default it works the same).
set access_path [AddSubDirs $access_path]
}
Log $slave "Setting accessPath=($access_path) staticsok=$staticsok\
nestedok=$nestedok deletehook=($deletehook)" NOTICE
|
| ︙ | |||
340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 | 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 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 | + + + + + + + + + + + - + + + + + - + - + + - + |
lappend map_access_path $token $dir
lappend remap_access_path $dir $token
lappend norm_access_path [file normalize $dir]
incr i
}
set morepaths [::tcl::tm::list]
set firstpass 1
while {[llength $morepaths]} {
set addpaths $morepaths
set morepaths {}
foreach dir $addpaths {
# Prevent the addition of dirs on the tm list to the
# result if they are already known.
if {[dict exists $remap_access_path $dir]} {
if {$firstpass} {
# $dir is in [::tcl::tm::list] and belongs in the slave_tm_path.
# Later passes handle subdirectories, which belong in the
# access path but not in the module path.
lappend slave_tm_path [dict get $remap_access_path $dir]
}
continue
}
set token [PathToken $i]
lappend access_path $dir
lappend slave_access_path $token
lappend map_access_path $token $dir
lappend remap_access_path $dir $token
lappend norm_access_path [file normalize $dir]
if {$firstpass} {
# $dir is in [::tcl::tm::list] and belongs in the slave_tm_path.
# Later passes handle subdirectories, which belong in the
# access path but not in the module path.
|
| ︙ | |||
504 505 506 507 508 509 510 | 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 | - + |
}} msg opt]} {
Log $slave "can't source tm.tcl ($msg)"
return -options $opt "can't source tm.tcl into slave $slave ($msg)"
}
# Sync the paths used to search for Tcl modules. This can be done only
# now, after tm.tcl was loaded.
|
| ︙ | |||
536 537 538 539 540 541 542 | 575 576 577 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 | - + + + + + - + + + + + + + + + + + + |
}
}
}
return $res
}
# This procedure deletes a safe slave managed by Safe Tcl and cleans up
|
| ︙ | |||
613 614 615 616 617 618 619 | 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 | - + |
# ------------------- END OF PUBLIC METHODS ------------
#
# Sets the slave auto_path to the master recorded value. Also sets
# tcl_library to the first token of the virtual path.
#
proc ::safe::SyncAccessPath {slave} {
|
| ︙ | |||
640 641 642 643 644 645 646 | 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 | - + |
return "\$p(:$n:)" ;# Form tested by case 7.2
}
#
# translate virtual path into real path
#
proc ::safe::TranslatePath {slave path} {
|
| ︙ | |||
708 709 710 711 712 713 714 | 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 | - + + + + + - - - - - - - |
}
set dir {}
set virtualdir {}
while {$at < [llength $args]} {
switch -glob -- [set opt [lindex $args $at]] {
|
| ︙ | |||
756 757 758 759 760 761 762 | 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 | + + + - - - - + + + + + + + + + + + + + - + + - + - + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + |
set dir [TranslatePath $slave $virtualdir]
DirInAccessPath $slave $dir
} on error msg {
Log $slave $msg
if {$got(-nocomplain)} return
return -code error "permission denied"
}
if {$got(--)} {
set cmd [linsert $cmd end-1 -directory $dir]
} else {
|
| ︙ | |||
866 867 868 869 870 871 872 | 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 | - + + + + - + |
if {[catch {
FileInAccessPath $slave $realfile
} msg]} {
Log $slave $msg
return -code error "permission denied"
}
|
| ︙ | |||
916 917 918 919 920 921 922 | 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 | - + |
Log $slave "$msg ($argc) {$file $args}"
return -code error $msg
}
# package name (can be empty if file is not).
set package [lindex $args 0]
|
| ︙ | |||
967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 | 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 | + + + + + + + - + - + - + - + |
return -code error "permission denied (path)"
}
}
try {
return [::interp invokehidden $slave load $file $package $target]
} on error msg {
# Some packages return no error message.
set msg0 "load of binary library for package $package failed"
if {$msg eq {}} {
set msg $msg0
} else {
set msg "$msg0: $msg"
}
Log $slave $msg
return -code error $msg
}
}
# FileInAccessPath raises an error if the file is not found in the list of
# directories contained in the (master side recorded) slave's access path.
# the security here relies on "file dirname" answering the proper
# result... needs checking ?
proc ::safe::FileInAccessPath {slave file} {
|
| ︙ | |||
1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 | 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + |
}
# Various minor hiding of platform features. [Bug 2913625]
proc ::safe::AliasExeName {slave} {
return ""
}
# ------------------------------------------------------------------------------
# Using Interpreter Names with Namespace Qualifiers
# ------------------------------------------------------------------------------
# (1) We wish to preserve compatibility with existing code, in which Safe Base
# interpreter names have no namespace qualifiers.
# (2) safe::interpCreate and the rest of the Safe Base previously could not
# accept namespace qualifiers in an interpreter name.
# (3) The interp command will accept namespace qualifiers in an interpreter
# name, but accepts distinct interpreters that will have the same command
# name (e.g. foo, ::foo, and :::foo) (bug 66c2e8c974).
# (4) To satisfy these constraints, Safe Base interpreter names will be fully
# qualified namespace names with no excess colons and with the leading "::"
# omitted.
# (5) Trailing "::" implies a namespace tail {}, which interp reads as {{}}.
# Reject such names.
# (6) We could:
# (a) EITHER reject usable but non-compliant names (e.g. excess colons) in
# interpCreate, interpInit;
# (b) OR accept such names and then translate to a compliant name in every
# command.
# The problem with (b) is that the user will expect to use the name with the
# interp command and will find that it is not recognised.
# E.g "interpCreate ::foo" creates interpreter "foo", and the user's name
# "::foo" works with all the Safe Base commands, but "interp eval ::foo"
# fails.
# So we choose (a).
# (7) The command
# namespace upvar ::safe S$slave state
# becomes
# namespace upvar ::safe [VarName $slave] state
# ------------------------------------------------------------------------------
proc ::safe::RejectExcessColons {slave} {
set stripped [regsub -all -- {:::*} $slave ::]
if {[string range $stripped end-1 end] eq {::}} {
return -code error {interpreter name must not end in "::"}
}
if {$stripped ne $slave} {
set msg {interpreter name has excess colons in namespace separators}
return -code error $msg
}
if {[string range $stripped 0 1] eq {::}} {
return -code error {interpreter name must not begin "::"}
}
return
}
proc ::safe::VarName {slave} {
# return S$slave
return S[string map {:: @N @ @A} $slave]
}
proc ::safe::Setup {} {
####
#
# Setup the arguments parsing
#
####
|
| ︙ |
Changes to library/tm.tcl.
| ︙ | |||
208 209 210 211 212 213 214 | 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | - - + - - - + + + + + |
}
set currentsearchpath [file join $path $pkgroot]
if {![interp issafe] && ![file exists $currentsearchpath]} {
continue
}
set strip [llength [file split $path]]
|
| ︙ |
Added tests/auto0/auto1/file1.tcl.
|
Added tests/auto0/auto1/package1.tcl.
|
Added tests/auto0/auto1/pkgIndex.tcl.
|
Added tests/auto0/auto1/tclIndex.
|
Added tests/auto0/auto2/file2.tcl.
|
Added tests/auto0/auto2/package2.tcl.
|
Added tests/auto0/auto2/pkgIndex.tcl.
|
Added tests/auto0/auto2/tclIndex.
|
Added tests/auto0/modules/mod1/test1-1.0.tm.
|
Added tests/auto0/modules/mod2/test2-2.0.tm.
|
Added tests/auto0/modules/test0-0.5.tm.
|
Added tests/safe-stock86.test.