def _bind(self, what, where=None, force=False): if where is None: where = what where = path_join_abs(self.rpath, where) if not path.exists(what): raise RuntimeError("Binding not existing location") if force or not path.exists(path_join_abs(self.chroot.path, where)): self.options += ['-b', '%s:%s' % (what, where)] return True return False
def _proot_options(self): self._verbosity(-1) self._chroot(self.chroot.path) sh_target = path.join(os.sep, "bin", "sh") if not path.exists(path_join_abs(self.chroot.path, sh_target)): self._bind(path_join_abs(self.proot.path, sh_target), sh_target) else: # If /bin/sh exists, then bind unpatched version to it sh_patched = elf_loader_patch._get_unpatched_name(path.realpath(path_join_abs(self.chroot.path, sh_target))) if path.exists(sh_patched): self._bind(sh_patched, sh_target, force=True) self._bind(os.path.join(self.proot.path, "lib"), "lib") self._bind(os.getcwd(), "tmp", force=True) # Make absolute `outside paths' visible in sandbox self._bind(self.chroot.path, force=True) self._bind(os.getcwd(), force=True)
def _proot_options(self): self._verbosity(-1) self._chroot(self.chroot.path) sh_target = path.join(os.sep, 'bin', 'sh') if not path.exists(path_join_abs(self.chroot.path, sh_target)): self._bind(path_join_abs(self.proot.path, sh_target), sh_target) else: # If /bin/sh exists, then bind unpatched version to it sh_patched = elf_loader_patch._get_unpatched_name( path.realpath(path_join_abs(self.chroot.path, sh_target))) if path.exists(sh_patched): self._bind(sh_patched, sh_target, force=True) self._bind(os.path.join(self.proot.path, 'lib'), 'lib') self._bind(tempcwd(), 'tmp', force=True) # Make absolute `outside paths' visible in sandbox self._bind(self.chroot.path, force=True) self._bind(tempcwd(), force=True)
def _pwd(self, pwd): """Sets new process initial pwd""" self.options += ['-w', path_join_abs(self.rpath, pwd)]