Skip to content

About

Simple Python bindings for the Landlock Linux security module

Topics

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

landlockpy

PyPI CI CodeQL OpenSSF Scorecard License: 0BSD

Dependency-free Python bindings for the Landlock Linux security module. Landlock lets unprivileged processes sandbox themselves with filesystem, network and IPC restrictions enforced by the kernel. Supports ABI versions 1 through 11 with best-effort degradation on older kernels.

Requires Python 3.10+ and Linux 5.13+ with Landlock enabled in the LSM list.

Used in: MeshChatX, LXMFy

Install

pip install landlockpy

Usage

from landlockpy import AccessFS, AccessNet, Ruleset

with Ruleset() as ruleset:
    ruleset.allow_path(
        "/usr", AccessFS.READ_FILE | AccessFS.READ_DIR | AccessFS.EXECUTE
    )
    ruleset.allow_port(443, AccessNet.CONNECT_TCP)
    ruleset.restrict()

# everything not granted above is now denied for this thread and its children

landlockpy.supported() reports whether the running kernel has Landlock, and landlockpy.abi_version() returns its ABI version.

Documentation

License: 0BSD.

About

Simple Python bindings for the Landlock Linux security module

Topics

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages