posixcaps
Dependency-free Python bindings for Linux capabilities. Read and modify
the effective, permitted, inheritable, bounding and ambient capability
sets of threads, and the file capabilities stored in the
security.capability extended attribute. Everything goes through
capget(2)/capset(2), prctl(2) and getxattr(2)/setxattr(2) via ctypes;
there are no runtime dependencies.
Requires Python 3.10+ and Linux.
Install
pip install posixcaps
Usage
from posixcaps import Cap, Capabilities, ambient, bounding
caps = Capabilities.for_self()
print(caps.effective) # frozenset of Cap
print(caps.permitted)
print(caps.inheritable)
caps.set(effective=caps.permitted) # capset(2), kernel rules enforced
print(bounding()) # prctl(PR_CAPBSET_READ) per capability
print(ambient()) # prctl(PR_CAP_AMBIENT_IS_SET) per capability
File capabilities live in the security.capability xattr:
from posixcaps import Cap, get_file_caps, set_file_caps
set_file_caps( # requires CAP_SETFCAP
"/usr/local/bin/mydaemon",
effective=True,
permitted={Cap.CAP_NET_BIND_SERVICE},
)
print(get_file_caps("/usr/local/bin/mydaemon"))
posixcaps.cap_last_cap() reports the highest capability index the
running kernel supports, from /proc/sys/kernel/cap_last_cap.
Documentation
- API: docstrings in
src/posixcaps/, mostlycaps.pyandfilecaps.py - capabilities(7): https://man7.org/linux/man-pages/man7/capabilities.7.html
- capget(2): https://man7.org/linux/man-pages/man2/capget.2.html
License: 0BSD.
Metadata
Release files for posixcaps 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| posixcaps-0.1.0.tar.gz | 78.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| posixcaps-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 88.8 kB
Release files / posixcaps-0.1.0.tar.gz
| Download URL | posixcaps-0.1.0.tar.gz |
|---|---|
| Size | 78.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6f7fba19c224761e102062699375b9bea93fdd41352d264c9e11b12c746b92b3
|
|
BLAKE2b-256 checksum How to use checksums |
2ea0c062b8deea0a295c790f634c8fdf82ac52d9f26b410d66d856c024c2db51
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 22, 2026.
Transparency logRelease files / posixcaps-0.1.0-py3-none-any.whl
| Download URL | posixcaps-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
48e49991210368ed31c2f745e42b3ea1e328069e189e7d6dac880e22121a1440
|
|
BLAKE2b-256 checksum How to use checksums |
e56e9713313cf290d645cff110030b0c53ca6d6370fff2e57aa2171ab3c44dc6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 22, 2026.
Transparency log