diff options
author | Helmut Grohne <helmut@subdivi.de> | 2024-03-01 18:51:09 +0100 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2024-03-01 18:51:09 +0100 |
commit | 802f4bf49c8b8d3776f9f8b3fb1cce6a0bbd9f76 (patch) | |
tree | 755102d1a12459824ec67ff59bf548de60eebcfe | |
parent | c091a57ece33a8fd36161c319f2fa78546467b7f (diff) | |
download | python-linuxnamespaces-802f4bf49c8b8d3776f9f8b3fb1cce6a0bbd9f76.tar.gz |
add rudimentary prctl syscall wrapper
-rwxr-xr-x | examples/withallsubuids.py | 5 | ||||
-rw-r--r-- | linuxnamespaces/syscalls.py | 5 |
2 files changed, 6 insertions, 4 deletions
diff --git a/examples/withallsubuids.py b/examples/withallsubuids.py index 8b90e9a..ead0482 100755 --- a/examples/withallsubuids.py +++ b/examples/withallsubuids.py @@ -47,13 +47,10 @@ def main() -> None: while caps: cap = caps & (~caps + 1) caps ^= cap - linuxnamespaces.call_libc( - "prctl", + linuxnamespaces.prctl( 47, # PR_CAP_AMBIENT 2, # PR_CAP_AMBIENT_RAISE cap.bit_length() - 1, - 0, - 0, ) if len(sys.argv) > 1: os.execvp(sys.argv[1], sys.argv[1:]) diff --git a/linuxnamespaces/syscalls.py b/linuxnamespaces/syscalls.py index c98d776..ab715f2 100644 --- a/linuxnamespaces/syscalls.py +++ b/linuxnamespaces/syscalls.py @@ -622,6 +622,11 @@ def pivot_root(new_root: PathConvertible, put_old: PathConvertible) -> None: """Python wrapper for pivot_root(2).""" call_libc("pivot_root", os.fsencode(new_root), os.fsencode(put_old)) +def prctl( + option: int, arg2: int = 0, arg3: int = 0, arg4: int = 0, arg5: int = 0 +) -> int: + """Python wrapper for prctl(2).""" + return call_libc("prctl", option, arg2, arg3, arg4, arg5) def setns(fd: int, nstype: CloneFlags = CloneFlags.NONE) -> None: """Python wrapper for setns(2).""" |