📄 safe.n
字号:
Option names are not case sensitive..TP \fB\-accessPath\fR \fIdirectoryList\fRThis option sets the list of directories from which the safe interpretercan \fBsource\fR and \fBload\fR files.If this option is not specified, or if it is given as theempty list, the safe interpreter will use the same directories as itsmaster for auto-loading.See the section \fBSECURITY\fR below for more detail about virtual paths, tokens and access control..TP\fB\-statics\fR \fIboolean\fRThis option specifies if the safe interpreter will be allowedto load statically linked packages (like \fBload {} Tk\fR).The default value is \fBtrue\fR : safe interpreters are allowed to load statically linked packages..TP\fB\-noStatics\fRThis option is a convenience shortcut for \fB-statics false\fR andthus specifies that the safe interpreter will not be allowedto load statically linked packages..TP\fB\-nested\fR \fIboolean\fRThis option specifies if the safe interpreter will be allowedto load packages into its own sub-interpreters.The default value is \fBfalse\fR : safe interpreters are not allowed to load packages intotheir own sub-interpreters..TP\fB\-nestedLoadOk\fRThis option is a convenience shortcut for \fB-nested true\fR andthus specifies the safe interpreter will be allowedto load packages into its own sub-interpreters..TP \fB\-deleteHook\fR \fIscript\fRWhen this option is given an non empty \fIscript\fR, it will beevaluated in the master with the name ofthe safe interpreter as an additional argumentjust before actually deleting the safe interpreter.Giving an empty value removes any currently installed deletion hookscript for that safe interpreter.The default value (\fB{}\fR) is not to have any deletion call back..SH ALIASESThe following aliases are provided in a safe interpreter:.TP\fBsource\fR \fIfileName\fRThe requested file, a Tcl source file, is sourced into the safe interpreterif it is found.The \fBsource\fR alias can only source files from directories inthe virtual path for the safe interpreter. The \fBsource\fR alias requiresthe safe interpreter touse one of the token names in its virtual path to denote the directory inwhich the file to be sourced can be found.See the section on \fBSECURITY\fR for more discussion of restrictions onvalid filenames..TP\fBload\fR \fIfileName\fRThe requested file, a shared object file, is dynamically loaded into thesafe interpreter if it is found.The filename must contain a token name mentioned in the virtual path forthe safe interpreter for it to be found successfully.Additionally, the shared object file must contain a safe entry point; seethe manual page for the \fBload\fR command for more details..TP\fBfile\fR ?\fIsubCmd args...\fR?The \fBfile\fR alias provides access to a safe subset of the subcommands ofthe \fBfile\fR command; it allows only \fBdirname\fR, \fBjoin\fR,\fBextension\fR, \fBroot\fR, \fBtail\fR, \fBpathname\fR and \fBsplit\fRsubcommands. For more details on what these subcommands do see the manualpage for the \fBfile\fR command..TP\fBencoding\fR ?\fIsubCmd args...\fR?The \fBencoding\fR alias provides access to a safe subset of thesubcommands of the \fBencoding\fR command; it disallows setting ofthe system encoding, but allows all other subcommands including\fBsystem\fR to check the current encoding..TP\fBexit\fRThe calling interpreter is deleted and its computation is stopped, but theTcl process in which this interpreter exists is not terminated..SH SECURITYThe Safe Base does not attempt to completely prevent annoyance anddenial of service attacks. These forms of attack prevent theapplication or user from temporarily using the computer to performuseful work, for example by consuming all available CPU time orall available screen real estate.These attacks, while aggravating, are deemed to be of lesser importancein general than integrity and privacy attacks that the Safe Baseis to prevent..PPThe commands available in a safe interpreter, in addition tothe safe set as defined in \fBinterp\fR manual page, are mediated aliasesfor \fBsource\fR, \fBload\fR, \fBexit\fR, and safe subsets of\fBfile\fR and \fBencoding\fR. The safe interpreter can also auto-loadcode and it can request that packages be loaded..PPBecause some of these commands access the local file system, there is apotential for information leakage about its directory structure.To prevent this, commands that take file names as arguments in a safeinterpreter use tokens instead of the real directory names.These tokens are translated to the real directory name while a request to,e.g., source a file is mediated by the master interpreter.This virtual path system is maintained in the master interpreter for each safeinterpreter created by \fB::safe::interpCreate\fR or initialized by\fB::safe::interpInit\fR andthe path maps tokens accessible in the safe interpreter into real pathnames on the local file system thus preventing safe interpreters from gaining knowledge about thestructure of the file system of the host on which the interpreter isexecuting.The only valid file names argumentsfor the \fBsource\fR and \fBload\fR aliases provided to the slaveare path in the form of \fB[file join \fR\fItoken filename\fR\fB]\fR (ie, when using thenative file path formats: \fItoken\fR\fB/\fR\fIfilename\fRon Unix, \fItoken\fR\fB\\\fIfilename\fR on Windows, and \fItoken\fR\fB:\fR\fIfilename\fR on the Mac),where \fItoken\fR is representing one of the directories of the \fIaccessPath\fR list and \fIfilename\fR isone file in that directory (no sub directories access are allowed)..PPWhen a token is used in a safe interpreter in a request to source orload a file, the token is checked andtranslated to a real path name and the file to besourced or loaded is located on the file system.The safe interpreter never gains knowledge of the actual path name underwhich the file is stored on the file system..PPTo further prevent potential information leakage from sensitive files thatare accidentally included in the set of files that can be sourced by a safeinterpreter, the \fBsource\fR alias restricts access to filesmeeting the following constraints: the file name mustfourteen characters or shorter, must not contain more than one dot ("\fB.\fR"),must end up with the extension \fB.tcl\fR or be called \fBtclIndex\fR..PPEach element of the initial access pathlist will be assigned a token that will be set inthe slave \fBauto_path\fR and the first element of that list will be set asthe \fBtcl_library\fR for that slave..PPIf the access path argument is not given or is the empty list, the default behavior is to let the slave access the same packagesas the master has access to (Or to be more precise: only packages written in Tcl (which by definition can't be dangerousas they run in the slave interpreter) and C extensions thatprovides a Safe_Init entry point). For that purpose, the master's \fBauto_path\fR will be used to construct the slave access path. In order that the slave successfully loads the Tcl library files(which includes the auto-loading mechanism itself) the \fBtcl_library\fR will beadded or moved to the first position if necessary, in the slave access path, so the slave\fBtcl_library\fR will be the same as the master's (its realpath will still be invisible to the slave though). In order that auto-loading works the same for the slave andthe master in this by default case, the first-levelsub directories of each directory in the master \fBauto_path\fR willalso be added (if not already included) to the slave access path.You can always specify a morerestrictive path for which sub directories will never be searched by explicitly specifying your directory list with the \fB\-accessPath\fR flaginstead of relying on this default mechanism..PPWhen the \fIaccessPath\fR is changed after the first creation orinitialization (ie through \fBinterpConfigure -accessPath \fR\fIlist\fR),an \fBauto_reset\fR is automatically evaluated in the safe interpreterto synchronize its \fBauto_index\fR with the new token list..SH "SEE ALSO"interp(n), library(n), load(n), package(n), source(n), unknown(n) .SH KEYWORDSalias, auto\-loading, auto_mkindex, load, master interpreter, safeinterpreter, slave interpreter, source
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -