From a617aa2c146b529caf80b4ddb2f3a188810689a0 Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Sat, 12 Jul 2025 19:53:44 +0200 Subject: examples/unschroot_fs.py: support 0700 home With the tar backend, there was a chdir(~/.cache/unschroot/...) that would fail if ~ was lacking execute permission for others. Now we chdir there before unsharing and then do relative operations to support that use case. --- examples/unschroot_fs.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3