예제 #1
0
            def launch(self, *args, **kwargs):
                agent = self._file('setbufsize.so')
                shutil.copyfile(setbufsize_path, agent)
                env = {
                    'LD_PRELOAD': agent,
                    'CPTBOX_STDOUT_BUFFER_SIZE':
                    kwargs.get('stdout_buffer_size'),
                    'CPTBOX_STDERR_BUFFER_SIZE':
                    kwargs.get('stderr_buffer_size'),
                }
                env.update(self.get_env())

                return SecurePopen(
                    [utf8bytes(a) for a in self.get_cmdline() + list(args)],
                    executable=utf8bytes(self.get_executable()),
                    security=self.get_security(launch_kwargs=kwargs),
                    address_grace=self.get_address_grace(),
                    personality=self.personality,
                    time=kwargs.get('time'),
                    memory=kwargs.get('memory'),
                    wall_time=kwargs.get('wall_time'),
                    stderr=(PIPE
                            if kwargs.get('pipe_stderr', False) else None),
                    env=env,
                    cwd=utf8bytes(self._dir),
                    nproc=self.get_nproc())
예제 #2
0
 def launch(self, *args, **kwargs):
     return SecurePopen(self.get_cmdline() + list(args), executable=self.get_executable(),
                        security=self.get_security(), address_grace=self.get_address_grace(),
                        time=kwargs.get('time'), memory=kwargs.get('memory'),
                        stderr=(PIPE if kwargs.get('pipe_stderr', False) else None),
                        env=self.get_env(), cwd=self._dir, nproc=self.get_nproc(),
                        unbuffered=kwargs.get('unbuffered', False))
예제 #3
0
파일: mixins.py 프로젝트: zmvictor/judge
            def launch(self, *args, **kwargs):
                agent = self._file('setbufsize.so')
                shutil.copyfile(setbufsize_path, agent)
                env = {
                    # Forward LD_LIBRARY_PATH for systems (e.g. Android Termux) that require
                    # it to find shared libraries
                    'LD_LIBRARY_PATH': os.environ.get('LD_LIBRARY_PATH', ''),
                    'LD_PRELOAD': agent,
                    'CPTBOX_STDOUT_BUFFER_SIZE':
                    kwargs.get('stdout_buffer_size'),
                    'CPTBOX_STDERR_BUFFER_SIZE':
                    kwargs.get('stderr_buffer_size'),
                }
                env.update(self.get_env())

                return SecurePopen(
                    [utf8bytes(a) for a in self.get_cmdline() + list(args)],
                    executable=utf8bytes(self.get_executable()),
                    security=self.get_security(launch_kwargs=kwargs),
                    address_grace=self.get_address_grace(),
                    personality=self.personality,
                    fds=kwargs.get('fds'),
                    time=kwargs.get('time'),
                    memory=kwargs.get('memory'),
                    wall_time=kwargs.get('wall_time'),
                    stderr=(PIPE
                            if kwargs.get('pipe_stderr', False) else None),
                    env=env,
                    cwd=utf8bytes(self._dir),
                    nproc=self.get_nproc())
예제 #4
0
 def launch(self, *args, **kwargs):
     return SecurePopen([self.name] + list(args),
                        executable=self._executable,
                        security=CHROOTSecurity(ASM_FS),
                        time=kwargs.get('time'),
                        memory=kwargs.get('memory'),
                        env={},
                        cwd=self._dir)
예제 #5
0
파일: RKT.py 프로젝트: aurpine/DMOJ-judge
 def launch(self, *args, **kwargs):
     return SecurePopen(
         [env['runtime']['racket'], self._script] + list(args),
         security=self._security(),
         time=kwargs.get('time'),
         memory=kwargs.get('memory'),
         address_grace=131072,
         stderr=(PIPE if kwargs.get('pipe_stderr', False) else None),
         env={'LANG': 'C'},
         cwd=self._dir)
예제 #6
0
            def launch(self, *args, **kwargs):
                for src, dst in kwargs.get('symlinks', {}).items():
                    src = os.path.abspath(os.path.join(self._dir, src))
                    # Disallow the creation of symlinks outside the submission directory.
                    if os.path.commonprefix([src, self._dir]) == self._dir:
                        # If a link already exists under this name, it's probably from a
                        # previous case, but might point to something different.
                        if os.path.islink(src):
                            os.unlink(src)
                        os.symlink(dst, src)
                    else:
                        raise InternalError(
                            'cannot symlink outside of submission directory')

                agent = self._file('setbufsize.so')
                shutil.copyfile(setbufsize_path, agent)
                env = {
                    # Forward LD_LIBRARY_PATH for systems (e.g. Android Termux) that require
                    # it to find shared libraries
                    'LD_LIBRARY_PATH': os.environ.get('LD_LIBRARY_PATH', ''),
                    'LD_PRELOAD': agent,
                    'CPTBOX_STDOUT_BUFFER_SIZE':
                    kwargs.get('stdout_buffer_size'),
                    'CPTBOX_STDERR_BUFFER_SIZE':
                    kwargs.get('stderr_buffer_size'),
                }
                env.update(self.get_env())

                return SecurePopen(
                    [utf8bytes(a) for a in self.get_cmdline() + list(args)],
                    executable=utf8bytes(self.get_executable()),
                    security=self.get_security(launch_kwargs=kwargs),
                    address_grace=self.get_address_grace(),
                    data_grace=self.data_grace,
                    personality=self.personality,
                    fds=kwargs.get('fds'),
                    time=kwargs.get('time'),
                    memory=kwargs.get('memory'),
                    wall_time=kwargs.get('wall_time'),
                    stdin=kwargs.get('stdin'),
                    stdout=kwargs.get('stdout'),
                    stderr=kwargs.get('stderr'),
                    env=env,
                    cwd=utf8bytes(self._dir),
                    nproc=self.get_nproc(),
                    fsize=self.fsize)