diff options
Diffstat (limited to 'linuxnamespaces/__init__.py')
-rw-r--r-- | linuxnamespaces/__init__.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/linuxnamespaces/__init__.py b/linuxnamespaces/__init__.py index ab06fb7..f19503a 100644 --- a/linuxnamespaces/__init__.py +++ b/linuxnamespaces/__init__.py @@ -409,7 +409,11 @@ def unshare_user_idmap( def unshare_user_idmap_nohelper( - uid: int, gid: int, flags: CloneFlags = CloneFlags.NEWUSER + uid: int, + gid: int, + flags: CloneFlags = CloneFlags.NEWUSER, + *, + proc: AtLocationLike | None = None, ) -> None: """Unshare the given namespaces (must include user) and map the current user and group to the given uid and gid @@ -418,8 +422,9 @@ def unshare_user_idmap_nohelper( uidmap = IDMapping(uid, os.getuid(), 1) gidmap = IDMapping(gid, os.getgid(), 1) unshare(flags) - pathlib.Path("/proc/self/setgroups").write_bytes(b"deny") - newidmaps(-1, [uidmap], [gidmap], False) + proc = AtLocation("/proc" if proc is None else proc) + (proc / "self/setgroups").write_bytes(b"deny") + newidmaps(-1, [uidmap], [gidmap], False, proc=proc) class _AsyncFilesender: |