diff options
author | Helmut Grohne <helmut@subdivi.de> | 2025-07-12 19:53:44 +0200 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2025-07-12 19:53:44 +0200 |
commit | a617aa2c146b529caf80b4ddb2f3a188810689a0 (patch) | |
tree | 6871741d21c81d6f146262e6c30a842e11089f97 | |
parent | d94db7bc07780bab3e438fa4c6508534ae4eeb09 (diff) | |
download | python-linuxnamespaces-a617aa2c146b529caf80b4ddb2f3a188810689a0.tar.gz |
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.
-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 |