[pypy-dev] vfs.py - sandboxing with option to write

Armin Rigo arigo at tunes.org
Tue Apr 13 10:12:25 CEST 2010

Hi Soren,

On Fri, Apr 09, 2010 at 03:50:41PM +0200, Søren Laursen wrote:
> On files that do exist and I want to write to then, I do not have a clue. As
> I can see I get the error even then I open the file using open( "myFile",
> "w").

The basics is what occurs when you do  open("myfile","w")  in the
sandboxed interpreter.  First, the interpreter itself translates your
call to a call to the Posix function (man 2 open).  That call is
intercepted by the sandboxing mechanism, and translated in sandlib.py in
a call to do_ll_os__ll_os_open().  That's where you can start tweaking.
So far, do_ll_os__ll_os_open() checks that we are calling it with
O_RDONLY and always raises EPERM otherwise.  You need to change that by
carefully adding more cases there.  Note that the get_node() method in
sandlib.py translates a Posix path given by do_ll_os__ll_os_open() --
which is the "myfile" specified in the interpreter -- into a "node",
which is so far a VFS File or Dir.  You also need to add a few method,
at least do_ll_os__ll_os_write(), to handle writes.

A bientot,


More information about the Pypy-dev mailing list