diff options
Diffstat (limited to 'examples/unschroot_fs.py')
-rwxr-xr-x | examples/unschroot_fs.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/examples/unschroot_fs.py b/examples/unschroot_fs.py index cda9f93..1c72beb 100755 --- a/examples/unschroot_fs.py +++ b/examples/unschroot_fs.py @@ -107,6 +107,9 @@ class SessionChroot(ChrootBase): data["Type"] = "unshare" return data + def enter(self) -> None: + pass + def mount(self) -> pathlib.Path: raise NotImplementedError @@ -185,8 +188,11 @@ class TarSessionChroot(SessionChroot): data["Location"] = "/opt" return data + def enter(self) -> None: + os.chdir(self.path) + def mount(self) -> pathlib.Path: - linuxnamespaces.bind_mount(self.path, "/mnt", recursive=True) + linuxnamespaces.bind_mount(".", "/mnt", recursive=True) return pathlib.Path("/mnt") @@ -364,6 +370,7 @@ def do_run_session(args: argparse.Namespace) -> None: for fd in (1, 2): if stat.S_ISFIFO(os.fstat(fd).st_mode): os.fchmod(fd, 0o666) + session.enter() ns = ( linuxnamespaces.CloneFlags.NEWUSER | linuxnamespaces.CloneFlags.NEWNS |