Secure embedding of Python

Ignacio Vazquez-Abrams ignacio at openservices.net
Thu Sep 27 20:28:19 CEST 2001


On 27 Sep 2001, chris liechti wrote:

> tordj at scalado.com (Tord Jansson) wrote in
> news:605d9ec1.0109270117.4bb31eb4 at posting.google.com:
>
> > 1. Will this approach effectively lock out access to file-functions
> > etc or are some dangerous functionality built into the interpreter
> > itself?
>
> all the functions that are built in are in the module "__builtins__" which
> is imported implicitly at the beginning of every script. you could modify
> this module and remove the "open" function that allows file access.
>
> note that some modules like "os" and "sys" are staticaly linked into the
> python interpreter. you would like to exclude these modules (especialy
> because of "os.system"). some replacement for "sys.exit" and maybe other
> functions of that modules could be useful.

Actually, the os module is a separate module written in Python. That it is
built into the Python interpreter is AFAICT a common misconception.

> > 2. Is some necessary functionality (memory allocation for
> > example)placed in modules which I therefore will have to include?
>
> not that i know, except some functions and variables provided by "sys" e.g.
> "sys.exit()", "print" uses "sys.stdout", maybe others.

These abilities are built in to the Python interpreter; the sys module just
exposes them for use in programs.

-- 
Ignacio Vazquez-Abrams  <ignacio at openservices.net>






More information about the Python-list mailing list