summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2024-01-22 17:55:37 +0100
committerHelmut Grohne <helmut@subdivi.de>2024-01-22 17:55:37 +0100
commit51aac10f6ad30a787b34e61ae43d1ec4336691e6 (patch)
treea075393cb82ff829b8bb41bad88bde47233393f0
parentec0be44f5e34ed76f7f6f2eeb530682f2b096212 (diff)
downloadpython-linuxnamespaces-51aac10f6ad30a787b34e61ae43d1ec4336691e6.tar.gz
provide default for IDAllocation.allocation map arg target
Most frequently, the root user is allocated.
-rwxr-xr-xexamples/userchroot.py4
-rw-r--r--linuxnamespaces/__init__.py2
2 files changed, 3 insertions, 3 deletions
diff --git a/examples/userchroot.py b/examples/userchroot.py
index 315a437..73d52b3 100755
--- a/examples/userchroot.py
+++ b/examples/userchroot.py
@@ -34,8 +34,8 @@ def main() -> None:
subuids = linuxnamespaces.IDAllocation.loadsubid("uid")
subgids = linuxnamespaces.IDAllocation.loadsubid("gid")
- uidmap = subuids.allocatemap(65536, 0)
- gidmap = subgids.allocatemap(65536, 0)
+ uidmap = subuids.allocatemap(65536)
+ gidmap = subgids.allocatemap(65536)
linuxnamespaces.unshare_user_idmap(
[uidmap],
diff --git a/linuxnamespaces/__init__.py b/linuxnamespaces/__init__.py
index 5d810b0..f44220a 100644
--- a/linuxnamespaces/__init__.py
+++ b/linuxnamespaces/__init__.py
@@ -126,7 +126,7 @@ class IDAllocation:
return start
raise ValueError("could not satisfy allocation request")
- def allocatemap(self, count: int, target: int) -> IDMapping:
+ def allocatemap(self, count: int, target: int = 0) -> IDMapping:
"""Allocate count contiguous ids from this allocation. An IDMapping
with its innerstart set to target is returned. The allocation is
removed from this IDAllocation object.