示例#1
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
        if self.tmpdir is None:
            tmpdirnode = Dir({})
        else:
            tmpdirnode = RealDir(self.tmpdir)
        pypydist = os.path.dirname(os.path.abspath(autopath.pypydir))

        return Dir({
            'bin':
            Dir({
                'pypy-c':
                RealFile(self.executable),
                'lib-python':
                RealDir(os.path.join(pypydist, 'lib-python')),
                'pypy':
                Dir({
                    'lib': RealDir(os.path.join(pypydist, 'pypy', 'lib')),
                }),
            }),
            '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({
                '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),
            }),
            'tmp':
            tmpdirnode,
        })
示例#3
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']
        #tmpdirnode = RealDir('/tmp/sandbox-root', exclude=exclude)
        dirname = '/tmp/sandbox-root-' + self.profile_owner
        tmpdirnode = RealDir(dirname, exclude=exclude)
        libroot = str(LIB_ROOT)
        log(libroot)
        return Dir({
            'proflib.py': RealFile('zoobar/proflib.py'),
            'bin':  Dir({'pypy-c':     RealFile(self.executable),
                         'lib-python': RealDir(libroot + '/lib-python', exclude=exclude),
                         'lib_pypy':   RealDir(libroot + '/lib_pypy',   exclude=exclude),
#                         'lib_zoobar': RealDir('/zoobar', exclude=exclude)
                        }),
            'proc': Dir({'cpuinfo': RealFile('/proc/cpuinfo'), }),
            'tmp':  tmpdirnode,
            })
示例#4
0
 def build_virtual_root(self):
     excludes = [".pyc", ".pyo"]
     return Dir({
         'startup.py':
         RealFile(os.path.join(pypy_root, "startup.py")),
         'bin':
         Dir({}),
         'tmp':
         Dir({}),
         'var':
         Dir({}),
         'usr':
         Dir({
             'bin':
             Dir({
                 "python": RealFile(sandbox_binary),
             }),
             'lib-python':
             RealDir(os.path.join(pypy_root, "lib-python"),
                     exclude=excludes),
             'lib_pypy':
             RealDir(os.path.join(pypy_root, "lib_pypy"),
                     exclude=excludes),
         }),
         'etc':
         Dir({
             'passwd':
             File(
                 random.choice([
                     "just kidding!", "nope", "so close!",
                     "try again", "you're kidding, right?",
                     "fooled you!"
                 ])),
         }),
         'proc':
         Dir({
             'cpuinfo': RealFile("/proc/cpuinfo"),
         }),
     })
示例#5
0
文件: run.py 项目: sembug/choosy
        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 = ['.pyc', '.pyo']
            assert self.tmpdir
            libroot = str(LIB_ROOT)

            return Dir({
                'bin': Dir({
                    'pypy-c': RealFile(self.executable),
                    'lib-python': RealDir(os.path.join(libroot, 'lib-python'), exclude=exclude_pyc), 
                    'lib_pypy': RealDir(os.path.join(libroot, 'lib_pypy'), exclude=exclude_pyc),
                    }),
                'tmp': RealDir(self.tmpdir, exclude=exclude_pyc),
                'choosy': RealDir(os.path.dirname(self.executable)),
                })
示例#6
0
 def build_virtual_root(self):
     return Dir({
         'hi.txt': File("Hello, world!\n"),
         'this.pyc': RealFile(__file__),
     })