def build_virtual_root(self):
        # build a virtual file system:
        # * can access its own executable
        # * can access the pure Python libraries
        # * can access the temporary usession directory as /tmp
        exclude = ['.pyc', '.pyo']
        if self.tmpdir is None:
            tmpdirnode = Dir({})
        else:
            tmpdirnode = RealDir(self.tmpdir, exclude=exclude)
        libroot = str(LIB_ROOT)
        
        try:
            virtualPypy = RealFile(self.executable, mode=011)
        except:
            virtualPypy = RealFile(self.executable) # for backwards compat.
        
        binDirData = {
                'pypy-c': virtualPypy,
                'lib-python': RealDir(os.path.join(libroot, 'lib-python'),
                                      exclude=exclude),
                'lib_pypy': RealDir(os.path.join(libroot, 'lib_pypy'),
                                      exclude=exclude),
                }
        for vpath, realpath in self.extraPyPackages.items():
            binDirData[vpath] = RealDir(os.path.abspath(realpath), exclude=exclude)

        return Dir({
             'bin': Dir(binDirData),
             'tmp': tmpdirnode,
             })
Пример #2
0
    def build_virtual_root(self):
        # build a virtual file system:
        # * can access its own executable
        # * can access the pure Python libraries
        # * can access the temporary usession directory as /tmp
        exclude = ['.pyc', '.pyo']
        if self.tmpdir is None:
            tmpdirnode = Dir({})
        else:
            tmpdirnode = RealDir(self.tmpdir, exclude=exclude)
        libroot = str(LIB_ROOT)

        return Dir({
            'bin':
            Dir({
                'pypy3-c':
                RealFile(self.executable),  #, mode=0111),
                'lib-python':
                RealDir(os.path.join(libroot, 'lib-python'), exclude=exclude),
                'lib_pypy':
                RealDir(os.path.join(libroot, 'lib_pypy'), exclude=exclude),
            }),
            'tmp':
            tmpdirnode,
            'dev':
            Dir({'urandom': RealFile("/dev/urandom")})
        })
Пример #3
0
    def build_virtual_root(tmppath, execpath, procdir):
        exclude = ['.pyc', '.pyo']
        if tmppath is None:
            tmpdirnode = Dir({})
        else:
            tmpdirnode = RealDir(tmppath, exclude=exclude)
        libroot = str(LIB_ROOT)

        return Dir({
            'usr':
            Dir({
                'include':
                RealDir(os.path.join(os.sep, 'usr', 'include'),
                        exclude=exclude)
            }),
            'bin':
            Dir({
                'pypy-c':
                RealFile(execpath),
                'lib-python':
                RealDir(os.path.join(libroot, 'lib-python'), exclude=exclude),
                'lib_pypy':
                RealDir(os.path.join(libroot, 'lib_pypy'), exclude=exclude),
            }),
            'tmp':
            tmpdirnode,
            'proc':
            procdir if procdir is not None else Dir({}),
        })
Пример #4
0
    def build_virtual_root(self):
        # build a virtual file system:
        # * can access its own executable
        # * can access the pure Python libraries
        # * can access the temporary usersession directory as /tmp
        exclude = ['.pyc', '.pyo']
        tmpdirnode = RealDir(self.sand_box_dir, exclude=exclude)
        libroot = str(LIB_ROOT)
        shutil.copy(BASE_BOT_FILE, self.sand_box_dir)
        shutil.copy(GAME_BOT_FILE, self.sand_box_dir)

        return Dir({
            'bin':
            Dir({
                'pypy-c':
                RealFile(self.executable, mode=0111),
                'lib-python':
                RealDir(os.path.join(libroot, 'lib-python'), exclude=exclude),
                'lib_pypy':
                RealDir(os.path.join(libroot, 'lib_pypy'), exclude=exclude),
            }),
            'tmp':
            tmpdirnode,
        })
@@ -22,11 +22,14 @@
 
 import sys, os
 sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__), '..', '..')))
+from pypy.module.sys.version import PYPY_VERSION
 from rpython.translator.sandbox.sandlib import SimpleIOSandboxedProc
 from rpython.translator.sandbox.sandlib import VirtualizedSandboxedProc
 from rpython.translator.sandbox.vfs import Dir, RealDir, RealFile
 import pypy
 LIB_ROOT = os.path.dirname(os.path.dirname(pypy.__file__))
+LIB_ROOT = os.path.join(LIB_ROOT, 'lib')
+LIB_ROOT = os.path.join(LIB_ROOT, 'pypy-%d.%d' % PYPY_VERSION[:2])
 
 class PyPySandboxedProc(VirtualizedSandboxedProc, SimpleIOSandboxedProc):
     argv0 = '/bin/pypy-c'
@@ -56,10 +59,10 @@
         return Dir({
             'bin': Dir({
                 'pypy-c': RealFile(self.executable),
-                'lib-python': RealDir(os.path.join(libroot, 'lib-python'),
-                                      exclude=exclude), 
-                'lib_pypy': RealDir(os.path.join(libroot, 'lib_pypy'),
-                                      exclude=exclude),
+                'lib': Dir({
+                    'pypy-%d.%d' % PYPY_VERSION[:2] : RealDir(libroot, 
+                                                             exclude=exclude)
+                    })
                 }),
              'tmp': tmpdirnode,
              })
Пример #6
0
 def build_virtual_root(self):
     return Dir({
         'hi.txt': File("Hello, world!\n"),
         'this.pyc': RealFile(__file__),
     })
@@ -22,11 +22,14 @@
 
 import sys, os
 sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__), '..', '..')))
+from pypy.module.sys.version import PYPY_VERSION
 from rpython.translator.sandbox.sandlib import SimpleIOSandboxedProc
 from rpython.translator.sandbox.sandlib import VirtualizedSandboxedProc
 from rpython.translator.sandbox.vfs import Dir, RealDir, RealFile
 import pypy
 LIB_ROOT = os.path.dirname(os.path.dirname(pypy.__file__))
+LIB_ROOT = os.path.join(LIB_ROOT, 'lib')
+LIB_ROOT = os.path.join(LIB_ROOT, 'pypy-%d.%d' % PYPY_VERSION[:2])
 
 class PyPySandboxedProc(VirtualizedSandboxedProc, SimpleIOSandboxedProc):
     argv0 = '/bin/pypy-c'
@@ -56,10 +59,10 @@
         return Dir({
             'bin': Dir({
                 'pypy-c': RealFile(self.executable, mode=0111),
-                'lib-python': RealDir(os.path.join(libroot, 'lib-python'),
-                                      exclude=exclude), 
-                'lib_pypy': RealDir(os.path.join(libroot, 'lib_pypy'),
-                                      exclude=exclude),
+                'lib': Dir({
+                    'pypy-%d.%d' % PYPY_VERSION[:2] : RealDir(libroot, 
+                                                             exclude=exclude)
+                    })
                 }),
              'tmp': tmpdirnode,
              })