Skip to main content

zfs-agent on pypi PyPI Downloads PyPI - Python Version Python test and package pre-commit Coverage Status AGPLv3+ License

zfs-agent

ZFS dataset management for unprivileged users via a Unix domain socket.

A host-side agent runs with ZFS privileges and executes validated zfs create requests on behalf of clients that lack ZFS tools or privileges – typically containers. Used in ftm-lakehouse.

Linux only (peer authentication relies on SO_PEERCRED), Python 3.10+, no dependencies.

Install

pip install zfs-agent

Usage

Run the agent on the host (as a user that may run zfs create, typically root):

zfs-agent --socket /run/zfs.sock --pool tank/data --owner 1000:1000 --allowed-uid 1000
  • --pool restricts requests to datasets below this path (env: ZFS_POOL)
  • --owner chowns new dataset mountpoints to this uid:gid (env: ZFS_OWNER)
  • --allowed-uid only accepts connections from this UID, verified via SO_PEERCRED; defaults to the agent's own UID (env: ZFS_ALLOWED_UID)
  • --log-level sets the agent's log verbosity, default INFO (env: ZFS_LOG_LEVEL). Only the CLI configures logging; imported as a library, the package logs through logging without attaching handlers.

Clients may only set ZFS properties from a built-in allowlist of tuning knobs (compression, recordsize, atime, quota, …). Set ZFS_EXTRA_PROPS on the agent to add more, comma separated:

ZFS_EXTRA_PROPS=canmount,readonly zfs-agent --socket /run/zfs.sock --pool tank/data

The effective allowlist is logged at startup.

Create datasets from the client side (e.g. inside a container that mounts the socket):

from zfs_agent.client import zfs_create_socket

zfs_create_socket("/run/zfs.sock", "tank/data/my_dataset", compression="zstd")

Or set ZFS_SOCKET=/run/zfs.sock in the environment and let the dispatcher choose between socket and local zfs create:

from zfs_agent import zfs_create

zfs_create("tank/data/my_dataset", compression="zstd")

Security

  • The socket is created mode 0600, owned by the allowed UID.
  • The peer's UID is verified via SO_PEERCRED before the request is read.
  • Dataset names are validated (no path traversal, restricted characters) and must live under the configured pool.
  • ZFS properties are checked against an allowlist. Properties such as mountpoint, sharenfs or setuid would otherwise let a client steer what the privileged side touches.
  • Requests are size capped and time limited, and a malformed one is answered with an error rather than taking the agent down.
  • The only supported action is create.

Tests

make test         # unit tests
make test-docker  # integration test (privileged container, ZFS on the host)

License

AGPLv3+

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zfs_agent-0.0.1.tar.gz (22.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zfs_agent-0.0.1-py3-none-any.whl (25.7 kB view details)

Uploaded Python 3

File details

Details for the file zfs_agent-0.0.1.tar.gz.

File metadata

  • Download URL: zfs_agent-0.0.1.tar.gz
  • Upload date:
  • Size: 22.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.14.4 Linux/7.0.0-28-generic

File hashes

Hashes for zfs_agent-0.0.1.tar.gz
Algorithm Hash digest
SHA256 b68e3ece30d8bc41d894706b2d564accfb5b94be21c016accc9d1fc1bd977d71
MD5 770cabb1ddb5a8af77154f8c61a947de
BLAKE2b-256 0a983d2248d92b992b0f822da815178a80f151c290d82f485cb505677d2106dc

See more details on using hashes here.

File details

Details for the file zfs_agent-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: zfs_agent-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 25.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.14.4 Linux/7.0.0-28-generic

File hashes

Hashes for zfs_agent-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 195fa645250dda296461ba014db0bd83e20faa59382ad318ce350e20ebdc98f8
MD5 8a54c623addb01058fe8161e3d353652
BLAKE2b-256 012b952150c9ef2d55621242968148dd1a7076081bc40f919bdcc52695fb8333

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page