| 10618 | """Class for managing remote sessions with GEF. It will create a temporary environment |
| 10619 | designed to clone the remote one.""" |
| 10620 | def __init__(self, host: str, port: int, pid: int =-1, qemu: Optional[pathlib.Path] = None) -> None: |
| 10621 | super().__init__() |
| 10622 | self.__host = host |
| 10623 | self.__port = port |
| 10624 | self.__local_root_fd = tempfile.TemporaryDirectory() |
| 10625 | self.__local_root_path = pathlib.Path(self.__local_root_fd.name) |
| 10626 | self.__qemu = qemu |
| 10627 | dbg(f"[remote] initializing remote session with {self.target} under {self.root}") |
| 10628 | if not self.connect(pid): |
| 10629 | raise EnvironmentError(f"Cannot connect to remote target {self.target}") |
| 10630 | if not self.setup(): |
| 10631 | raise EnvironmentError(f"Failed to create a proper environment for {self.target}") |
| 10632 | return |
| 10633 | |
| 10634 | def close(self) -> None: |
| 10635 | self.__local_root_fd.cleanup() |