summaryrefslogtreecommitdiffstats
path: root/Doc/lib
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>1999-04-23 17:26:24 (GMT)
committerFred Drake <fdrake@acm.org>1999-04-23 17:26:24 (GMT)
commit87b8f318b0d5d5d8b74c888458be6a0e8fea83f9 (patch)
tree440ecb6c3c0917ea662ac52a11054449a0e18dbf /Doc/lib
parentdeb7e096d3d84a07f6b3b7eb10d134c60eef3cd7 (diff)
downloadcpython-87b8f318b0d5d5d8b74c888458be6a0e8fea83f9.zip
cpython-87b8f318b0d5d5d8b74c888458be6a0e8fea83f9.tar.gz
cpython-87b8f318b0d5d5d8b74c888458be6a0e8fea83f9.tar.bz2
Fixed some logical markup nits.
Added a pointer to Grail in the see-also section, since it's used as an example.
Diffstat (limited to 'Doc/lib')
-rw-r--r--Doc/lib/librestricted.tex47
1 files changed, 26 insertions, 21 deletions
diff --git a/Doc/lib/librestricted.tex b/Doc/lib/librestricted.tex
index cbd38c5..2e1c11a 100644
--- a/Doc/lib/librestricted.tex
+++ b/Doc/lib/librestricted.tex
@@ -1,15 +1,14 @@
-\chapter{Restricted Execution}
-\label{restricted}
+\chapter{Restricted Execution \label{restricted}}
In general, Python programs have complete access to the underlying
operating system throug the various functions and classes, For
example, a Python program can open any file for reading and writing by
-using the \code{open()} built-in function (provided the underlying OS
-gives you permission!). This is exactly what you want for most
+using the \function{open()} built-in function (provided the underlying
+OS gives you permission!). This is exactly what you want for most
applications.
There exists a class of applications for which this ``openness'' is
-inappropriate. Take Grail: a web browser that accepts ``applets'',
+inappropriate. Take Grail: a web browser that accepts ``applets,''
snippets of Python code, from anywhere on the Internet for execution
on the local system. This can be used to improve the user interface
of forms, for instance. Since the originator of the code is unknown,
@@ -38,27 +37,28 @@ determined by the supervisor, different restrictions can be imposed,
depending on the application. For example, it might be deemed
``safe'' for untrusted code to read any file within a specified
directory, but never to write a file. In this case, the supervisor
-may redefine the built-in
-\code{open()} function so that it raises an exception whenever the
-\var{mode} parameter is \code{'w'}. It might also perform a
-\code{chroot()}-like operation on the \var{filename} parameter, such
-that root is always relative to some safe ``sandbox'' area of the
-filesystem. In this case, the untrusted code would still see an
-built-in \code{open()} function in its environment, with the same
-calling interface. The semantics would be identical too, with
-\code{IOError}s being raised when the supervisor determined that an
-unallowable parameter is being used.
+may redefine the built-in \function{open()} function so that it raises
+an exception whenever the \var{mode} parameter is \code{'w'}. It
+might also perform a \cfunction{chroot()}-like operation on the
+\var{filename} parameter, such that root is always relative to some
+safe ``sandbox'' area of the filesystem. In this case, the untrusted
+code would still see an built-in \function{open()} function in its
+environment, with the same calling interface. The semantics would be
+identical too, with \exception{IOError}s being raised when the
+supervisor determined that an unallowable parameter is being used.
The Python run-time determines whether a particular code block is
executing in restricted execution mode based on the identity of the
\code{__builtins__} object in its global variables: if this is (the
-dictionary of) the standard \code{__builtin__} module, the code is
-deemed to be unrestricted, else it is deemed to be restricted.
+dictionary of) the standard \refmodule[builtin]{__builtin__} module,
+the code is deemed to be unrestricted, else it is deemed to be
+restricted.
Python code executing in restricted mode faces a number of limitations
that are designed to prevent it from escaping from the padded cell.
-For instance, the function object attribute \code{func_globals} and the
-class and instance object attribute \code{__dict__} are unavailable.
+For instance, the function object attribute \member{func_globals} and
+the class and instance object attribute \member{__dict__} are
+unavailable.
Two modules provide the framework for setting up restricted execution
environments:
@@ -66,6 +66,11 @@ environments:
\localmoduletable
\begin{seealso}
-\seetext{Andrew Kuchling, ``Restricted Execution HOWTO.'' Available
-online at \url{http://www.python.org/doc/howto/rexec/}.}
+ \seetext{Andrew Kuchling, ``Restricted Execution HOWTO.'' Available
+ online at \url{http://www.python.org/doc/howto/rexec/}.}
+
+ \seetext{Grail, an Internet browser written in Python, is available
+ at \url{http://grail.cnri.reston.va.us/grail/}. More
+ information on the use of Python's restricted execution
+ mode in Grail is available on the Web site.}
\end{seealso}